RE: [sv-ac] Re: [sv-bc] Re: if-else

From: Steven Sharp <sharp_at_.....>
Date: Thu Nov 01 2007 - 14:48:18 PDT
>From: "Rich, Dave" <Dave_Rich@mentor.com>

>Has anyone come up with a case where 1'b0 would not work? What about '0?

You mean for the "equivalent" comparison?  Sure:

module top;
initial
begin
  if (1'sb1>>>1)
        $display("expression true");
  if ((1'sb1>>>1) != 1'b0)
        $display("(expression != 1'b0) true");
  if ((1'sb1>>>1) != '0)
        $display("(expression != '0) true");
  if ((1'sb1>>>1) != 1'sb0)
        $display("(expression != 1'sb0) true");
end
endmodule

In a correct implementation, this prints

expression true
(expression != 1'sb0) true

and none of the others.  Using an unsigned zero gives incorrect results.

Steven Sharp
sharp@cadence.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Thu Nov 1 14:48:36 2007

This archive was generated by hypermail 2.1.8 : Thu Nov 01 2007 - 14:48:44 PDT