In the following simplified Verilog code:
wire [31:0] depth;
wire mode_u2 = 1'h0;
assign depth = 'h80 + (~mode_u2);
if I do a display on depth, and simulate it with VCS (2014.12-1)
$display("depth is 0x%2x", depth);
i'm getting 0x7f
, instead of expected 0x81
. it seems like ~mode_u2 is treated as minus 1.
If I change ~mode_u2
to !mode_u2
. I get 0x81 as expected.
what's more interesting is if i do wire mode = ~mode_u2
and then assign depth = 'h80 + (~mode)
instead of 0x80
, i get 0x7e
Am I missing something here?
Can someone explain why ~
behaves this way in a +
operation? Or is this one of those simulation and synthesis being different situation?
Many thanks!!
Willie