-
Notifications
You must be signed in to change notification settings - Fork 58
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
Signal: allow to use integral Enum for reset value. #296
Conversation
nmigen/hdl/ast.py
Outdated
@@ -834,6 +834,11 @@ def __init__(self, shape=None, *, name=None, reset=0, reset_less=False, min=None | |||
attrs=None, decoder=None, src_loc_at=0): | |||
super().__init__(src_loc_at=src_loc_at) | |||
|
|||
if isinstance(reset, Enum): | |||
reset = reset.value | |||
if not type(reset) == int: |
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 should be an isinstance(reset, int)
, or reset=True
will fail. (bool
is derived from int
in Python.)
Codecov Report
@@ Coverage Diff @@
## master #296 +/- ##
==========================================
- Coverage 82.13% 82.13% -0.01%
==========================================
Files 34 34
Lines 5647 5652 +5
Branches 1160 1162 +2
==========================================
+ Hits 4638 4642 +4
- Misses 864 865 +1
Partials 145 145
Continue to review full report at Codecov.
|
Thanks. Could you add a test as well? |
Pushed a test. |
Pushed change that removes reference to bool in docstring and extended test to check for non-integral Enum type. |
|
Thanks for the PR! |
Follow-up to #294.