Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icarus confused about signed/unsigned in strange ?: example #20

Closed
cliffordwolf opened this issue Mar 6, 2014 · 1 comment
Closed

Icarus confused about signed/unsigned in strange ?: example #20

cliffordwolf opened this issue Mar 6, 2014 · 1 comment

Comments

@cliffordwolf
Copy link
Contributor

@cliffordwolf cliffordwolf commented Mar 6, 2014

The following module should set the output to constant 0, because the 4'b0 makes the whole expression unsigned.

module issue_032(y);
  wire signed [3:0] a = -5;
  wire signed [3:0] b =  0;
  output y;
  assign y = (1 ? a : 4'b0) < (1 ? b : b); 
  initial #1 $display("%b", y);
endmodule

But Icarus Verilog (git 3e41a93) assigns 1 instead. Interestingly the bug goes away if the (1 ? b : b) is replaced by b.

@martinwhitaker
Copy link
Collaborator

@martinwhitaker martinwhitaker commented Mar 6, 2014

I've pushed a fix for this to the git master branch. The compiler was correctly determining that the expression was unsigned, but losing this information during optimisation of the ternary expressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants