-
Notifications
You must be signed in to change notification settings - Fork 643
Preserve literals across .asTypeOf #4168
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
Conversation
d285777 to
78a7e9a
Compare
|
I was hoping to backport this because I think it's potentially a very useful feature for ChiselSim and 6.x is closer to 3.6.x which makes for easier porting, but alas it seems that it is a really common pattern to use This change is still good and worth making, but it needs to be on a major version since it will break those uses (they just need to add a |
|
Converted to draft temporarily. I want to deprecate assigning to the wire returned by |
78a7e9a to
88f93e7
Compare
|
This is ready to go |
88f93e7 to
982664d
Compare
|
|
||
| it("should number AsTypeOfReadOnly as 8") { | ||
| val args = Array("--warn-conf", "id=8:e,any:s", "--throw-on-first-error") | ||
| it("should now error on AsTypeOfReadOnly") { | ||
| val args = Array("--throw-on-first-error") | ||
| val e = the[Exception] thrownBy ChiselStage.emitCHIRRTL(new AsTypeOfReadOnly, args) | ||
| e.getMessage should include("[W008] Return values of asTypeOf will soon be read-only") | ||
| e.getMessage should include("Return values of asTypeOf are now read-only") | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is the first time we'll be elevating a warning to an error. I haven't really worked through it all, we could add a corresponding E008 for the old W008, but no other errors are numbered yet (and of course, unlike warnings, you will not be allowed to configure errors). Any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like if we want to add error numbers we should do that more holistically? separately from this PR?
982664d to
de6d98e
Compare
de6d98e to
ca5062c
Compare
Casting a literal (of any type) to another type with .asTypeOf will result in a literal of the new type. For non-literals, the FIRRTL representation will now be a little bit more efficient.
ca5062c to
f487c92
Compare
`UnknownWidth` became a `case object` in this Chisel PR: chipsalliance/chisel#4242 The `connectFromBits` method was removed in this Chisel PR: chipsalliance/chisel#4168
`UnknownWidth` became a `case object` in this Chisel PR: chipsalliance/chisel#4242 The `connectFromBits` method was removed in this Chisel PR: chipsalliance/chisel#4168
`UnknownWidth` became a `case object` in this Chisel PR: chipsalliance/chisel#4242 The `connectFromBits` method was removed in this Chisel PR: chipsalliance/chisel#4168
`UnknownWidth` became a `case object` in this Chisel PR: chipsalliance/chisel#4242 The `connectFromBits` method was removed in this Chisel PR: chipsalliance/chisel#4168 The `connectFromBits` API was replaced with the `_fromUInt` API in this Chisel PR: chipsalliance/chisel#4782 The sbt update is necessary to maintain compatibility with the latest Scala compiler version.
`UnknownWidth` became a `case object` in this Chisel PR: chipsalliance/chisel#4242 The `connectFromBits` method was removed in this Chisel PR: chipsalliance/chisel#4168 The `connectFromBits` API was replaced with the `_fromUInt` API in this Chisel PR: chipsalliance/chisel#4782 The sbt update is necessary to maintain compatibility with the latest Scala compiler version.
`UnknownWidth` became a `case object` in this Chisel PR: chipsalliance/chisel#4242 The `connectFromBits` method was removed in this Chisel PR: chipsalliance/chisel#4168 The `connectFromBits` API was replaced with the `_fromUInt` API in this Chisel PR: chipsalliance/chisel#4782 The `NumObject` trait was replaced by the `Num` object in this PR: chipsalliance/chisel#4768 The sbt update is necessary to maintain compatibility with the latest Scala compiler version.
`UnknownWidth` became a `case object` in this Chisel PR: chipsalliance/chisel#4242 The `connectFromBits` method was removed in this Chisel PR: chipsalliance/chisel#4168 The `connectFromBits` API was replaced with the `_fromUInt` API in this Chisel PR: chipsalliance/chisel#4782 The `NumObject` trait was replaced by the `Num` object in this PR: chipsalliance/chisel#4768 The sbt update is necessary to maintain compatibility with the latest Scala compiler version.
`UnknownWidth` became a `case object` in this Chisel PR: chipsalliance/chisel#4242 The `connectFromBits` method was removed in this Chisel PR: chipsalliance/chisel#4168 The `connectFromBits` API was replaced with the `_fromUInt` API in this Chisel PR: chipsalliance/chisel#4782 The `NumObject` trait was replaced by the `Num` object in this PR: chipsalliance/chisel#4768 Wrapping unary negation (`unary_-%`) was deprecated in this PR: chipsalliance/chisel#4829 The sbt update is necessary to maintain compatibility with the latest Scala compiler version.
`UnknownWidth` became a `case object` in this Chisel PR: chipsalliance/chisel#4242 The `connectFromBits` method was removed in this Chisel PR: chipsalliance/chisel#4168 The `connectFromBits` API was replaced with the `_fromUInt` API in this Chisel PR: chipsalliance/chisel#4782 Wrapping unary negation (`unary_-%`) was deprecated in this PR: chipsalliance/chisel#4829 The sbt update is necessary to maintain compatibility with the latest Scala compiler version.
* Update Chisel from 6.5.0 to 7.0.0 `UnknownWidth` became a `case object` in this Chisel PR: chipsalliance/chisel#4242 The `connectFromBits` method was removed in this Chisel PR: chipsalliance/chisel#4168 The `connectFromBits` API was replaced with the `_fromUInt` API in this Chisel PR: chipsalliance/chisel#4782 Wrapping unary negation (`unary_-%`) was deprecated in this PR: chipsalliance/chisel#4829 The sbt update is necessary to maintain compatibility with the latest Scala compiler version. * Migrate from Chisel testers to ChiselSim The `chisel3.testers` package was removed here: chipsalliance/chisel#4746 It doesn't look like ChiselSim has the same `Boolean` result from `simulate`, so we must check for simulation errors by catching exceptions. * Replace ChiselRunners trait with direct use of ChiselSim * Update to latest scalafmt * lint: Apply latest scalafmt settings * Update to latest scalatest version * Fix missing sbt command in GitHub CI For background: actions/setup-java#712 Also updated JDK to 21 (latest LTS), updated some GitHub actions to their latest versions, and using install-circt GitHub action to get firtool. * Fix out-of-range literals in tests An 8-bit signed integer with a binary point at 2 effectively has a 6-bit signed number for the value to the left of the decimal point. That means it can represent values in the range [-2^5, 2^5-1], or [-32, 31]. After chipsalliance/chisel#4786 was merged, the `55` and `56` literals are now correctly flagged as being out-of-range for this type. I've subtracted 32 from these out-of-range values (changing the MSB from 1 to 0), and the tests now pass. * Update Chisel 7 snapshot from 639-5df5515f to 678-dca5fc11 This update includes this Chisel PR, which deprecated everything in the `firrtl` package: chipsalliance/chisel#4878 Bump `firtool` version to latest as well. * Update Chisel version to 7.0.0-RC1 Also update CI versions of firtool and verilator to latest. * Update Chisel version to 7.5.0
Built on top of #4160 so should merge this one after that one (might need rebase but git seems smarter about cherry-picks these days).
This is very valuable for ChiselSim-style testing because it means that you can much more easily construct literals in tests.
Contributor Checklist
docs/src?Type of Improvement
Desired Merge Strategy
Release Notes
Casting a literal (of any type) to another type with .asTypeOf will result in a literal of the new type. For non-literals, the FIRRTL representation will now be a little bit more efficient.
Reviewer Checklist (only modified by reviewer)
3.6.x,5.x, or6.xdepending on impact, API modification or big change:7.0)?Enable auto-merge (squash), clean up the commit message, and label withPlease Merge.Create a merge commit.