|
From: Stephen W. <st...@ic...> - 2014-01-21 18:17:11
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 01/21/2014 09:24 AM, Sébastien Bourdeauducq wrote:
> Hi,
>
> Running the following:
>
> $display("%b", 2'd2 + 2'd2);
I'm actually surprised that this displays 100, as that is 3 bits,
and the expression is only 2 bits.
> $display("%b", 3'd4 >= 2'd1);
Yeah, that's fine. 3'b100 >= 2'b01 ---> 1'b1
> $display("%b", (2'd2 + 2'd2) >= 2'd1);
This is right: (2'b10 + 2'b10) >= 2'b01
Both sides are 2bits wide, and 10+10 == (1)00 == 2'b00, which
is not >= 01. The size of arithmetic expressions is the size
of the largest operand, in the case of "+" in your example,
that is 2bits.
- --
Steve Williams "The woods are lovely, dark and deep.
steve at icarus.com But I have promises to keep,
http://www.icarus.com and lines to code before I sleep,
http://www.picturel.com And lines to code before I sleep."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iEYEARECAAYFAlLeuZ8ACgkQrPt1Sc2b3inRUACbBOFpRSYxmmGU7r1bA2/c2vC+
AOMAn0amhMEf5WAMMMkzUJLTAxeglOr2
=7kdu
-----END PGP SIGNATURE-----
|