[myhdl-list] intb min, max confusion
Brought to you by:
jandecaluwe
From: garyr <ga...@fi...> - 2012-10-04 00:08:50
|
It appears to me that the max limit on an intbv value should be > (greater than) rather than >= (greater than or equal). In the following code, isn't 3 a valid value for a 3-bit signal? from myhdl import * def testBench(): @instance def stimulus(): NBITS = 3 MAXV = 2**(NBITS-1) min = -MAXV max = MAXV-1 print 'NBITS=%d min=%d max=%d' % (NBITS, min, max) x = Signal(intbv(0, min=min, max=max)) x.next = min yield delay(1) print 'x', x x.next = max yield delay(1) print 'x', x raise StopSimulation return instances() tb = testBench() Simulation(tb).run(200) ====================================== >python intbTest.py NBITS=3 min=-4 max=3 x -4 Traceback (most recent call last): File "intbTest.py", line 22, in <module> Simulation(tb).run(200) File "C:\Python26\lib\site-packages\myhdl\_Simulation.py", line 132, in run waiter.next(waiters, actives, exc) File "C:\Python26\lib\site-packages\myhdl\_Waiter.py", line 128, in next clause = self.generator.next() File "intbTest.py", line 15, in stimulus x.next = max File "C:\Python26\lib\site-packages\myhdl\_Signal.py", line 200, in _set_next self._setNextVal(val) File "C:\Python26\lib\site-packages\myhdl\_Signal.py", line 266, in _setNextIntbv self._next._checkBounds() File "C:\Python26\lib\site-packages\myhdl\_intbv.py", line 79, in _checkBounds (self._val, self._max)) ValueError: intbv value 3 >= maximum 3 >Exit code: 1 |