Re: [myhdl-list] Slicing an unsigned intbv to a signed one
Brought to you by:
jandecaluwe
From: Christopher F. <cf...@uc...> - 2008-06-12 20:39:55
|
Yes I will send the patch when I get home. I believe you are correct my quick implementation probably only covers the power of 2 cases. For the non-power of 2 cases, I think it still works cause you have to have a power of 2 (can't have fraction of a bit) the msb of the least number of bits (which is the _nrbits) is still the sign bit? Just thinking out loud. Thanks On Thu, 12 Jun 2008 20:45:12 +0200 Jan Decaluwe <ja...@ja...> wrote: > 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 > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list |