Re: [myhdl-list] Error in Intbv class?
Brought to you by:
jandecaluwe
From: Samuele D. <sm...@gm...> - 2016-03-03 13:25:08
|
Hello, Last message was empty, my mistake. On Thu, Mar 3, 2016 at 2:10 PM, Samuele Disegna <sm...@gm...> wrote: > > > On Thu, Mar 3, 2016 at 1:14 PM, Forumulator Bing <for...@gm...> > wrote: > >> Hello, >> >> I may have found a potential bug in intbv: >> >> >>> a=intbv(5)[4:0] >> >>> a[6:0]=20 >> Traceback (most recent call last): >> File "<stdin>", line 1, in <module> >> File "/usr/local/lib/python3.4/dist-packages/myhdl/_intbv.py", line >> 180, in __setitem__ >> self._handleBounds() >> File "/usr/local/lib/python3.4/dist-packages/myhdl/_intbv.py", line 77, >> in _handleBounds >> (self._val, self._max)) >> ValueError: intbv value 20 >= maximum 16 >> >>> a >> intbv(20) >> >> It gives a ValueError, but still sets the value of a to 20. Would this be >> considered a bug since an exception is thrown? >> >> > From what I see on myhdl code min/max bounds handling is done later than assignment and it seems independent. Therefore I would say it is not a bug. We could document this behaviour. Is it possible to subclass the exception to a documented ValueBoundError that define the behaviour? You can find the related code at https://github.com/jandecaluwe/myhdl/blob/master/myhdl/_intbv.py def __setitem__(self, key, val): Regards |