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

From: Brad Pierce <Brad.Pierce_at_.....>
Date: Fri Jul 28 2006 - 14:11:58 PDT
I meant  

     indexed from 0 to $bits(f(x,y))-1

-----Original Message-----
From: owner-sv-bc@eda-stds.org [mailto:owner-sv-bc@eda-stds.org] On
Behalf Of Brad Pierce
Sent: Friday, July 28, 2006 2:07 PM
To: sv-bc@eda-stds.org
Subject: Re: [sv-bc] Sysfunc to ask about signedness?

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:12:03 2006

This archive was generated by hypermail 2.1.8 : Fri Jul 28 2006 - 14:12:08 PDT