Re: [sv-bc] Sysfunc to ask about signedness?

From: Brad Pierce <Brad.Pierce_at_.....>
Date: Fri Jul 28 2006 - 14:06:34 PDT
Cool!

>	`define IS_SIGNED(x) (((x) | ~0) < 0)

So in V2K you could also select the Nth-most-significant bit of x by

      `define MSB(x,N) ($signed((x) << (N)) < 0)

to get the effect of a non-standard bit-select like

      (f(x,y))[i]

with f(x,y) indexed from 0 to $bits(x+y)-1 by writing

      `MSB(f(x,y),i)

-- Brad

-----Original Message-----
From: Steven Sharp [mailto:sharp@cadence.com] 
Sent: Friday, July 28, 2006 11:45 AM
To: sv-bc@eda-stds.org; Brad.Pierce@synopsys.COM
Subject: Re: [sv-bc] Re: Sysfunc to ask about signedness?


>     `define IS_SIGNED(x) &(((((x) << $bits(x)) + 1'sb1) <<
>($bits(x)-1)) >>> $bits(x))


A simpler variation that should work also:

	`define IS_SIGNED(x) &(((x) | ~1'sb0) >>> $bits(x))

An even simpler version that should work in Verilog too:

	`define IS_SIGNED(x) (((x) | ~0) < 0)

Steven Sharp
sharp@cadence.com
Received on Fri Jul 28 14:07:36 2006

This archive was generated by hypermail 2.1.8 : Fri Jul 28 2006 - 14:07:58 PDT