Re: [myhdl-list] intbv improvement?
Brought to you by:
jandecaluwe
From: Jan D. <ja...@ja...> - 2009-03-04 20:14:39
|
Neal Becker wrote: > I would find this addition to the intbv constructor helpful: > > class intbv(object): > __slots__ = ('_val', '_min', '_max', '_nrbits') > > def __init__(self, val=None, min=None, max=None, _nrbits=0, > is_signed=False): > if _nrbits: > if (is_signed): > self._min = -1 << (_nrbits-1) > self._max = ~(-1 << (_nrbits-1)) > else: > self._min = 0 > self._max = 2**_nrbits I infer that you want to use _nrbits as an end user also? This is not how the type is set up. _nrbits is intended to be a private parameter of the constructor for internal use. One of the goals of intbv is to get rid of unsigned/signed thinking as much as possible, and push the use of fine-grained range control as high-level alternative. (I'm actually writing a paper about this, almost finished.) Jan -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Python as a hardware description language: http://www.myhdl.org |