Different interpretation of SystemVerilog (involves cast, shift, negation)

Status
Not open for further replies.

likewise

Newbie level 5
Joined
Jun 22, 2012
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,372
I have a simulator and a synthesize tool which have conflicting results in the following code / case:

lessthan = ((B << 1) <= B_t'(-N));

lessthan is "logic"
N is "logic [11:0]" and has value 53;
B is "logic signed [18:0]" and has value -26;

B_t is a typedef for "logic signed [18:0]";

The simulated design results in lessthan being 0 / false.
The synthesized design results in lessthan being 1 / true.

Which tool is right? In other words, how should the SystemVerilog be interpreted.
- There is a negation of an unsigned logic value 53, followed by a cast to logic signed, on the right hand side of the equation.
- The left hand side has a shift-left by 1, on an logic signed value -26. I expect this to result in -52.

I think B_t'(-N))) is interpreted differently by the two tools.

What is the correct interpretation? Preferably with reference to the SystemVerilog standard.

Thanks for any insight.
 

It would help instead of writing
lessthan = ((B << 1) <= B_t'(-N));

lessthan is "logic"
N is "logic [11:0]" and has value 53;
B is "logic signed [18:0]" and has value -26;

B_t is a typedef for "logic signed [18:0]";
you could write the same in legal SystemVerilog syntax
Code:
   logic lessthan;
   logic [11:0] N;
   typedef logic signed [18:0] B_t;
   B_t B;
   
   initial begin
      N = 53;
      B = -26;
      BB = -N;
      lessthan = ((B <<< 1) <= B_t'(-N));
   ...
IEEE 1800-2012 LRM said:
If the expression is assignment compatible with the casting type, then the cast shall return the value that a variable of the casting type would hold after being assigned the expression.
That means
Code:
lessthan = ((B <<< 1) <= B_t'(-N));
should behave the same as
Code:
B_t temp;
temp = -N;
lessthan = ((B <<< 1) <= temp);
That should result in false.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…