-
Notifications
You must be signed in to change notification settings - Fork 646
Fix SInt literals to reject too small of widths #4786
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -284,4 +284,18 @@ class SIntOpsSpec extends AnyPropSpec with Matchers with ShiftRightWidthBehavior | |
| blit.x.litOption should be(Some(2)) | ||
| blit.y.litOption should be(Some(9)) | ||
| } | ||
|
|
||
| property("SInt literals with too small of a width should be rejected") { | ||
| // Sanity checks. | ||
| 0.S.getWidth should be(1) | ||
| 0.S(0.W).getWidth should be(0) | ||
| -1.S.getWidth should be(1) | ||
| 1.S.getWidth should be(2) | ||
| // The real check. | ||
| -2.S.getWidth should be(2) | ||
| an[IllegalArgumentException] shouldBe thrownBy(-2.S(1.W)) | ||
| 0xde.S.getWidth should be(9) | ||
| an[IllegalArgumentException] shouldBe thrownBy(0xde.S(8.W)) | ||
| an[IllegalArgumentException] shouldBe thrownBy(0xde.S(4.W)) | ||
| } | ||
|
Comment on lines
+288
to
+300
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests look right! I haven't thought through the other ramifications of this change, other than that the existing tests in the repo all pass.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I'm confident it's correct. Note that even before this change |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.