SV allows you to write signed numbers by adding "s".
The LRM says,
"numbers specified with the base format shall be treated as signed integers if the s designator is included or
as unsigned integers if the base format only is used. The s designator does not affect the bit pattern specified,
only its interpretation."
Thus,
4'hf denotes the 4-bit number '1111', interpreted as an unsigned number 15.
4'shf is also a 4-bit number '1111'. However, it is interpreted as a 2's-complement number, so it represents the value -1.
I personally find it very confusing as soon as you get past the simplest cases.
So the default is unsigned.
Note an exception: an unsigned decimal number, such as 3, is considered to be a signed positive number. This is significant, because in an operation with multiple operands, if any operand is unsigned, they are all treated as unsigned. An operation is performed as signed only if all its operands are signed.
Shalom
> -----Original Message-----
> From: owner-verilog-ams@eda.org [mailto:owner-verilog-ams@eda.org] On
> Behalf Of Floyd, Paul
> Sent: Wednesday, May 23, 2012 22:57
> To: Dave Miller
> Cc: verilog-ams@eda-stds.org
> Subject: RE: $arandom/$rdist_ seeds
>
> Hi
>
> Generally, there's no such thing as a negative number (from a language
> parsing perspective). There are only unsigned numbers and unary
> operators. The unary minus and the unsigned number are two tokens. SV
> has added the notion of signed and unsigned numbers. I can't remember
> offhand which is the default. It does seem strange having both an
> unsigned_number and a decimal_number that doesn't seem to have a sign.
>
> Regards
> Paul
---------------------------------------------------------------------
Intel Israel (74) Limited
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
-- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Mon May 28 06:57:28 2012
This archive was generated by hypermail 2.1.8 : Mon May 28 2012 - 06:57:40 PDT