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

Small constants can make C compiler assume signing #773

Closed
veripoolbot opened this issue May 23, 2014 · 2 comments
Closed

Small constants can make C compiler assume signing #773

veripoolbot opened this issue May 23, 2014 · 2 comments
Assignees
Labels
area: wrong runtime result Issue involves an incorrect runtine result from Verilated model resolution: fixed Closed; fixed

Comments

@veripoolbot
Copy link
Contributor


Author Name: Clifford Wolf (@cliffordwolf)
Original Redmine Issue: 773 from https://www.veripool.org
Original Date: 2014-05-23
Original Assignee: Wilson Snyder (@wsnyder)


This should return y=0 for a=31, but Verilator 06744b6 returns y=31 instead:

 module issue_050(a, y);
   input [4:0] a;
   output [4:0] y;
   assign y = a >> ((a ? 1 : 2) << a);
 endmodule

Self-contained test case:

http://svn.clifford.at/handicraft/2014/verilatortest/test017.v

http://svn.clifford.at/handicraft/2014/verilatortest/test017.cc

http://svn.clifford.at/handicraft/2014/verilatortest/test017.sh

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2014-05-24T12:04:05Z


Fixed in git towards 3.861.

Interesting as this precise use of small constants caused the emitted code to be such that the C compiler saw a small constant on both sides of a comparison, so it used a signed compare instead of the intended unsigned compare. Now forcing unsigned.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2014-06-11T00:58:32Z


In 3.862.

@veripoolbot veripoolbot added area: wrong runtime result Issue involves an incorrect runtine result from Verilated model resolution: fixed Closed; fixed labels Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: wrong runtime result Issue involves an incorrect runtine result from Verilated model resolution: fixed Closed; fixed
Projects
None yet
Development

No branches or pull requests

2 participants