--- good.v 2019-07-24 20:20:50.179566232 +0000
+++ bad.v 2019-07-24 20:21:05.291656753 +0000
@@ -1190,7 +1190,7 @@
i2cmastersubtarget_sda_o_i2cmaster_next_value_ce4 <= 1'd1;
end else begin
if ((i2cmastersubtarget_sda_o == 1'd1)) begin
- if ((1'd1 | (i2cmastersubtarget_sda_i == 1'd1))) begin
+ if ((1'sd1 | $signed({1'd0, (i2cmastersubtarget_sda_i == 1'd1)}))) begin
i2cmaster_next_state <= 2'd3;
end
end
Given that (n)Migen signals can be negated only with ~ and booleans can be negated only with not, this seems to be a potential source of serious bugs. Unfortunately I'm not sure what can be done to fix it (since by the time the value is coerced to an nMigen constant, its boolean-ness is long lost), and nMigen is indeed still susceptible to this issue:
Issue by whitequark Wednesday Jul 24, 2019 at 20:28 GMT Originally opened as https://github.com/m-labs/nmigen/issues/159
I just discovered this bug in some oMigen code:
It translates to this Verilog:
Given that (n)Migen signals can be negated only with
~
and booleans can be negated only withnot
, this seems to be a potential source of serious bugs. Unfortunately I'm not sure what can be done to fix it (since by the time the value is coerced to an nMigen constant, its boolean-ness is long lost), and nMigen is indeed still susceptible to this issue: