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

Another strange icarus expression eval bug (large shifts) #22

Closed
cliffordwolf opened this issue May 19, 2014 · 4 comments
Closed

Another strange icarus expression eval bug (large shifts) #22

cliffordwolf opened this issue May 19, 2014 · 4 comments

Comments

@cliffordwolf
Copy link
Contributor

@cliffordwolf cliffordwolf commented May 19, 2014

For b != 0 this should return y[3:2] == 0.

module issue_048(a, b, y);
  input [1:0] a;
  input [2:0] b;
  output [3:0] y;
  assign y = {a >> {22{b}}, a << (0 <<< b)};
endmodule

But iverilog 020e280 returns y[3:2] == y[1:0] instead.

@martinwhitaker
Copy link
Collaborator

@martinwhitaker martinwhitaker commented May 19, 2014

I can't reproduce this. The following test

module tb();

reg  [1:0] a;
reg  [2:0] b;
wire [3:0] y;

issue_048 dut(a, b, y);

initial begin
  a = 2;
  b = 1;
  #0 $display("%b", y);
end

endmodule

outputs "0010", which seems right. What values of 'a' and 'b' are you using?

@cliffordwolf
Copy link
Contributor Author

@cliffordwolf cliffordwolf commented May 19, 2014

Now this is funny...

The following code (based on your test bench) outputs "11 111 0011":

initial begin
  a = 3; b = 7;
  #0 $display("%b %b %b", a, b, y);
end   

But the following outputs "11 111 1111":

initial begin
  { a, b } = ~0;
  #0 $display("%b %b %b", a, b, y);
end   
@martinwhitaker
Copy link
Collaborator

@martinwhitaker martinwhitaker commented May 19, 2014

Turns out it is sensitive to the order you assign to a and b. So

a = 3; b = 7;

is OK but

b = 7; a = 3;

causes it to fail.

@martinwhitaker
Copy link
Collaborator

@martinwhitaker martinwhitaker commented May 19, 2014

Blame this on my fix for large shifts at run-time. Should be fixed now.

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