-
Notifications
You must be signed in to change notification settings - Fork 603
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
Fix ChiselEnum warnings and use Logger for warnings instead of println #1999
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It also uses the same logger as the Builder so that if we ever refactor that to be passed as an argument, it will be the same logger for both Builder and warning reporting.
jackkoenig
force-pushed
the
fix-chiselenum-warnings
branch
from
July 1, 2021 23:53
a99bd9d
to
135d9b5
Compare
seldridge
approved these changes
Jul 2, 2021
* @param n the UInt to cast | ||
* @return the equivalent Enum to the value of the cast UInt | ||
*/ | ||
def apply(n: UInt)(implicit sourceInfo: SourceInfo, connectionCompileOptions: CompileOptions): Type = castImpl(n, warn = true) |
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.
I like the clear use of warn = true
. 👍
deprecations.foreach { case ((message, sourceLoc), count) => | ||
println(s"${ErrorLog.depTag} $sourceLoc ($count calls): $message") | ||
logger.warn(s"${ErrorLog.depTag} $sourceLoc ($count calls): $message") |
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.
❤️ ❤️ ❤️
Previously, ChiselEnum would warn any time a UInt is converted to an Enum. There was no way to suppress this warning. Now there is a factory method (`.safe`) that does not warn and returns (Enum, Bool) where the Bool is the result of calling .isValid on an Enum object. The regular UInt cast is also now smarter and will not warn if all bitvectors of the width of the Enum are legal states.
jackkoenig
force-pushed
the
fix-chiselenum-warnings
branch
from
July 2, 2021 01:04
135d9b5
to
bfb77d4
Compare
I pushed some docs updates too. |
seldridge
approved these changes
Jul 2, 2021
This was referenced Jul 2, 2021
Closed
Closed
mergify bot
added a commit
that referenced
this pull request
Jul 7, 2021
…n (backport #1999) (#2002) * Change Chisel warnings to use logger instead of println It also uses the same logger as the Builder so that if we ever refactor that to be passed as an argument, it will be the same logger for both Builder and warning reporting. (cherry picked from commit 04caf39) * Add ChiselEnum.safe factory method and avoid warning Previously, ChiselEnum would warn any time a UInt is converted to an Enum. There was no way to suppress this warning. Now there is a factory method (`.safe`) that does not warn and returns (Enum, Bool) where the Bool is the result of calling .isValid on an Enum object. The regular UInt cast is also now smarter and will not warn if all bitvectors of the width of the Enum are legal states. (cherry picked from commit 5fe539c) # Conflicts: # src/test/scala/chiselTests/ChiselSpec.scala * Update docs for ChiselEnum (cherry picked from commit bfb77d4) * Resolve merge conflicts and waive false bincompat issue Co-authored-by: Jack Koenig <koenig@sifive.com>
jackkoenig
added a commit
that referenced
this pull request
Feb 28, 2023
sbt-ci-release changes the commands required to publish to Sonatype. While this may be a desirable change at some point, it is inconsistent with other repos. Reverting for the time being.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add ChiselEnum.safe factory method and avoid warning
Previously, ChiselEnum would warn any time a UInt is converted to an
Enum. There was no way to suppress this warning. Now there is a factory
method (
.safe
) that does not warn and returns (Enum, Bool) where theBool is the result of calling .isValid on an Enum object. The regular
UInt cast is also now smarter and will not warn if all bitvectors of the
width of the Enum are legal states.
I also added a useful testing utility to capture Logging information
I need to update the mdoc to include this information (and a few stylistic changes), will push another commit with that.
Contributor Checklist
docs/src
?Type of Improvement
API Impact
Adds
ChiselEnum.safe
for safely casting fromUInt
to an EnumBackend Code Generation Impact
No impact
Desired Merge Strategy
Release Notes
Stop warning when casting from
UInt
to aChiselEnum
if all bitvectors of the given width are legal states. Also provideChiselEnum.safe
for safely casting fromUInt
to an enum if some states are illegal.Reviewer Checklist (only modified by reviewer)
Please Merge
?