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

Signedness handling in binary bitwise operations of constants #8

Closed
cliffordwolf opened this issue Jan 6, 2014 · 2 comments
Closed

Signedness handling in binary bitwise operations of constants #8

cliffordwolf opened this issue Jan 6, 2014 · 2 comments

Comments

@cliffordwolf
Copy link
Contributor

@cliffordwolf cliffordwolf commented Jan 6, 2014

Bitwise operations of signed values should yield a signed value (see sec. 5.5.1 of IEEE Std 1365-2005). This is implemented correctly in Icarus Verilog for operations involving at least one variable, but bit-wise boolean operations of two signed constants yield an unsigned constant.

For example the following test case:

module issue_013(a, y);
  input signed [3:0] a;
  output [1:0] y;
  assign y[0] = a > (4'sb1010 | 4'sd0);
  assign y[1] = (a | 4'sd0) > 4'sb1010;
endmodule

For "a=0" this will assign y[0]=0 and y[1]=1. The value for y[1] is correct (this is an all-signed expression). The value for y[0] is incorrect. (Tested with git d1c9dd5.)

@caryr
Copy link
Collaborator

@caryr caryr commented Jan 6, 2014

It looks like the constant evaluation code in the compiler is not correctly handling sign information for numerous operators. I am assuming the base sign/width test code is correct.

@martinwhitaker
Copy link
Collaborator

@martinwhitaker martinwhitaker commented Feb 15, 2014

I've just pushed a fix for this bug to the master branch.

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
3 participants