[myhdl-list] another intbv question
Brought to you by:
jandecaluwe
From: Neal B. <ndb...@gm...> - 2009-03-05 12:40:19
|
I noticed that x = intbv (5, -16, 15) print x._min > -16 print (x >> 1)._min None This is surprising. I would have expected that arithmetic operations on intbv would result in an intbv with the same #bits. I have implemented a fixed pt arithmetic class in c++ (based on boost::constrained_value). What I did there is all operations result in the same # bits. If you want something different, first convert operands to the desired result size. For example, multiplying 2 8-bit values will give an 8-bit result. If you wanted a 16-bit result, first convert the inputs to the wider field. Others have argued that these conversions should be automatic (e.g., 8 x 8 - > 16), but I prefer explicit. In any case, I think the intbv behavior is surprising. Is this really desirable? |