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

WIdth bug related to size casting #925

Closed
veripoolbot opened this issue Jun 1, 2015 · 6 comments
Closed

WIdth bug related to size casting #925

veripoolbot opened this issue Jun 1, 2015 · 6 comments
Assignees
Labels
resolution: fixed Closed; fixed

Comments

@veripoolbot
Copy link
Contributor


Author Name: Jonathon Donaldson
Original Redmine Issue: 925 from https://www.veripool.org
Original Date: 2015-06-01
Original Assignee: Wilson Snyder (@wsnyder)


Verilator calculates the incorrect result for the following equation:

localparam [6:0] RESULT = 7'((6*9+92)%96);

Verilator calculates a value of 18. However, the correct result is 50.

After a bit of investigation I determined that the issue is that verilator is truncating the internal (69+92) quantity to 7 bits. However, the entire ((69+92)%96) quantity should be calculated as a 32-bit expression and only truncated to 7 bits just before the assignment.

Altera and Xilinx synthesis tools both calculate the result as 50. Modelsim also calculates the result as 50. I believe that you (Wilson) use VCS - it would be interesting to know what result it calculates.

I have attached an example in test regress format.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Jonathon Donaldson
Original Date: 2015-06-01T06:40:44Z


I found another example of this bug that seems to be very similar. I'm not sure if it's the exact same issue or not so I decided just to append to this bug report. I have attached the example in test regress format.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Jonathon Donaldson
Original Date: 2015-06-04T01:58:17Z


Just FYI, I did a quick test with t_math_arith2 in Aldec Active-HDL earlier today and it also got the expected answer. I didn't have time to test t_math_arith3 and I don't have access to the simulator anymore, but I imagine it would also get the same expected result (obviously I can't say for certain though).

I'm still interested in what VCS has to say as well. :) Wish I had access to all the simulator/synthesis tools to see if there was a general consensus on a particular result. Seems that way from the 4 that I've tested so far...but there's so many out there... If there is a mainstream simulator/synthesis tool that generates a different result it would start to make me think there is some ambiguity in the standard.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-06-04T02:59:51Z


I confirmed this in VCS, and fixed it, however it breaks other tests because casts don't seem to expand quite as simply as the spec suggests. Stay tuned.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Jonathon Donaldson
Original Date: 2015-06-04T06:35:01Z


Very interesting stuff. Thanks for the update. I'm eager to see what you find out.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-06-06T17:47:17Z


Fixed in git towards 3.873.

The IEEE spec doesn't say that casts should be treated like assignments to a variable of the appropriate cast size, followed by appropriate extension/truncation, but that's what seems to need to happen.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2015-06-06T18:05:11Z


In 3.874.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution: fixed Closed; fixed
Projects
None yet
Development

No branches or pull requests

2 participants