Re: [myhdl-list] Slicing an unsigned intbv to a signed one
Brought to you by:
jandecaluwe
From: Jan D. <ja...@ja...> - 2008-06-13 14:51:26
|
Christopher L. Felton wrote: > Ok, below was my quick test to double check if it could be done. A > real implementation probably need more thought (if feasible at all). > > With that said, I do think this approach will work. Even if you have > a non power of 2 limit you still need N bits to represent the max and > min values. If the msb of the "bit container" is modified it will > change the sign. I meant non-power of 2 values, not the limits, and I don't think it works: --- >>> x = intbv(7, min=-8, max=8) >>> bin(x) '111' >>> x[3] = 1 1 1 15 -8 8 4 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/jand/dev/myhdl/myhdl/_intbv.py", line 173, in __setitem__ self._checkBounds() File "/home/jand/dev/myhdl/myhdl/_intbv.py", line 89, in _checkBounds (self._val, self._min)) ValueError: intbv value -15 < minimum -8 --- Should give -1, right? Jan -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Kaboutermansstraat 97, B-3000 Leuven, Belgium From Python to silicon: http://myhdl.jandecaluwe.com |