RE: [sv-bc] Erratum and proposal in casting BNF

From: Steven Sharp <sharp@cadence.com>
Date: Tue Jun 15 2004 - 14:37:11 PDT

>I think casting the signedness of a concatenation does make sense. The
>result of a concatenation is always unsigned, even if its members are
>signed. If the concatenation is in a compound expression, I may still wish
>to treat the msb of the resultant concatenation as a sign bit, instead of a
>significant bit. E.g.:
>
> reg signed [31:0] a;
> reg [15:0] b;
> reg signed [47:0] c;
>
> if ( c < signed'{a,b} ) ...

Note that this can be done in Verilog-2001 by using the $signed() system
function.

Is the operand of a cast self-determined? I assume so.

Note that C does not support casting just the signedness of a value without
providing a full type. You cannot use a "signed" cast that will cast an
unsigned int to a signed int and an unsigned long to a signed long. If you
try, you will find that (signed) is just shorthand for (signed int).

Steven Sharp
sharp@cadence.com
Received on Tue Jun 15 14:39:00 2004

This archive was generated by hypermail 2.1.8 : Tue Jun 15 2004 - 14:39:13 PDT