-
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
Add isOneOf
method to ChiselEnum
#1966
Conversation
This is a great start and thanks for picking up this issue, @chiplet ! The next step would be to add some tests for the new method here: https://github.com/chipsalliance/chisel3/blob/master/src/test/scala/chiselTests/StrongEnum.scala If you are using IntelliJ, you should see a green arrow next to each test that lets you run it. If you are using Please let me know if you have any questions. And please let me know if you need me to run the continuous integration tests. Github now requires us to give first-time contributors the OK to run CI tests. Apparently they had some problems with people mining bitcoins :( |
I've now added a test for the new method. The most use cases should be covered, but I'm not sure about how object NonIncreasingEnum extends ChiselEnum {
val x = Value(2.U)
val y = Value(2.U)
} Should @ekiwi You could try running the CI tests now 👍 |
When starting to develop the tests I forgot the |
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.
can you add some description of this to the website docs for ChiselEnum?
I think it should be They way to think about this, is that |
Upon closer inspection there's a test that disallows instantiating non-increasing enums so |
You mean in this file I think currently the |
I think the only thing that needs to be solved in this issue regarding documentation would be to add some simple javadoc comment to the two methods. ( Besides that it would be great if you could rebase your commit on the latest master branch and resolve any conflicts. Looking good! |
isOneOf
method to ChiselEnum
isOneOf
method to ChiselEnum
I've added the related documentation and rebased to latest upstream commit so AFAIK this should be ready to merge. |
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.
This is an awesome first contribution! 🚢
It will be auto-merged once the CI passes. Thanks!
* Add @ekiwi's code as a starting point * Add test for ChiselEnum isOneOf method * Make isOneOfTester naming consistent with other testers * Add scaladoc comments for isOneOf * Add isOneOf tests that use the method that takes variable number of args * Add guide level documentation example for isOneOf (cherry picked from commit bb520b8)
* Add `isOneOf` method to `ChiselEnum` (#1966) * Add @ekiwi's code as a starting point * Add test for ChiselEnum isOneOf method * Make isOneOfTester naming consistent with other testers * Add scaladoc comments for isOneOf * Add isOneOf tests that use the method that takes variable number of args * Add guide level documentation example for isOneOf (cherry picked from commit bb520b8) * Turn on autoclonetype2 for mdocs Co-authored-by: Verneri Hirvonen <11316555+chiplet@users.noreply.github.com> Co-authored-by: Jack Koenig <koenig@sifive.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Contributor Checklist
docs/src
?Type of Improvement
API Impact
isOneOf
method toChiselEnum
value type (EnumType
).Backend Code Generation Impact
Desired Merge Strategy
Release Notes
isOneOf
method toChiselEnum
to reduce boilerplate when checking if the current value is in a set of given values.Reviewer Checklist (only modified by reviewer)
Please Merge
?