Re: [myhdl-list] intbv.wrap()
Brought to you by:
jandecaluwe
From: Christopher L. <loz...@fr...> - 2011-04-18 21:34:33
|
I guess Jan D, and I see the world differently. On so many issues. This should be interesting ongoing discussion. Oh well here goes. Jan D said: Really? Python doesn't have 32 bit integers that yield an overflow error. If you want that, tryintbv(0)[32:]. Actually I did not even know how python implements integers. That is how it should be. So I took a look at the docs and this is what they say. http://docs.python.org/reference/datamodel.html#objects-values-and-types Plain integers These represent numbers in the range -2147483648 through 2147483647. (The range may be larger on machines with a larger natural word size, but not smaller.) When the result of an operation would fall outside this range, the result is normally returned as a long integer (in some cases, the exception OverflowError <http://docs.python.org/library/exceptions.html#exceptions.OverflowError> is raised instead). For the purpose of shift and mask operations, integers are assumed to have a binary, 2's complement notation using 32 or more bits, and hiding no bits from the user (i.e., all 4294967296 different bit patterns correspond to different values). So this is all useful. Actually I prefer returning a long integer to the overflow error. I wonder when the overflow error is raised? So, as a python guy, using MyHDL, this is how I would like integers to behave! No Wrapping please! It is not part of the python spec. Of course if others want wrapping, that is fine by me. And yes, I understand that returning a different types is not typically done in hardware! > Terrible? Ada has modular types. They wrap around. Proves my point! Regards Chris -- Regards Christopher Lozinski Check out my iPhone apps TextFaster and EmailFaster http://textfaster.com Expect a paradigm shift. http://MyHDL.org |