-
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
add getters to m.submodules #156
Conversation
nmigen/hdl/dsl.py
Outdated
@@ -124,7 +130,8 @@ def __init__(self): | |||
self._ctrl_stack = [] | |||
|
|||
self._driving = SignalDict() | |||
self._submodules = [] | |||
self._submodules = {} |
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.
Nit: should this be something like self._named_submodules
?
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.
Sure, let me change that
Codecov Report
@@ Coverage Diff @@
## master #156 +/- ##
==========================================
+ Coverage 80.67% 80.73% +0.05%
==========================================
Files 32 32
Lines 5217 5232 +15
Branches 1129 1133 +4
==========================================
+ Hits 4209 4224 +15
Misses 873 873
Partials 135 135
Continue to review full report at Codecov.
|
nmigen/hdl/dsl.py
Outdated
self._anon_submodules.append(submodule) | ||
else: | ||
if name in self._named_submodules: | ||
raise ValueError("Submodule named '{}' already exists".format(name)) |
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.
Actually, I wasn't sure if this should be a ValueError or an AttributeError or maybe a SyntaxError?
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.
NameError?
This allows retrieving a named submodule after assigning it:
It also disallows setting the same submodule name twice:
Item notation is also supported: