Re: [myhdl-list] Slicing an unsigned intbv to a signed one
Brought to you by:
jandecaluwe
From: Jan D. <ja...@ja...> - 2008-06-12 19:45:58
|
Christopher L. Felton wrote: > Below is the output example for a small change that I made to the bit > vector class >>>> from myhdl import * >>>> x = intbv(0, min=-8, max=8) >>>> x[3] = 1 >>>> x > intbv(-8L) >>>> x[3] = 0 >>>> x > intbv(0L) > > To implement the above I simply modified __setitems__ and used the _min > and _nrbits values determine what type of number is being represented. > If the number is signed multiply the value by -1 if the msb is being > modified. Could you show your patch (just a diff)? I don't see how this would be correct for non-powers of 2. Jan -- Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com Kaboutermansstraat 97, B-3000 Leuven, Belgium From Python to silicon: http://myhdl.jandecaluwe.com |