Re: [myhdl-list] intbv improvement?
Brought to you by:
jandecaluwe
|
From: Neal B. <ndb...@gm...> - 2009-03-04 20:25:07
|
Jan Decaluwe wrote:
> 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
>
I want to make sure my value is converted to verilog signed. AFAICT, the
only way I have now to do this is with intbv specifying min and max, rather
than nrbits? That's OK, but a little inconvenient.
|