-
Notifications
You must be signed in to change notification settings - Fork 637
Add withModulePrefix
#4487
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 withModulePrefix
#4487
Conversation
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.
Generally looks good, 1 question about _
.
Also we need to define and test the behavior for Definition
and Instance
. Instance
should have no interaction with the prefix but should Definition
? My initial reaction is "no" since Definition
is essentially a separate Chisel elaboration, but I'm unsure. Any thoughts @mwachs5, @azidar, @seldridge?
We also probably need a way to remove the prefix, e.g. withNoModulePrefix
or withOverrideModulePrefix("")
or something.
Co-authored-by: Jack Koenig <jack.koenig3@gmail.com>
Co-authored-by: Jack Koenig <jack.koenig3@gmail.com>
Co-authored-by: Jack Koenig <jack.koenig3@gmail.com>
Co-authored-by: Jack Koenig <jack.koenig3@gmail.com>
Well, for definitions I think you do want the module prefix baked into it somehow. Is it a Val def = withModulePrefix (Definition(new Foo)) or perhaps it's better something one adds as an argument the Definition/Module/Instantiate APIs directly? |
Actually now that I wrote the above comment I really think it's a more natural thing to do than withModulePrefix(...) even for Module. For the latter why would we be doing it for more than one child ever, isn't it always started at one module or definition instantiation? |
I agree that we should instead make it an argument to So let's proceed with adding prefix as an optional (well optional via overloading) argument to
|
Hm, very good point. I guess it's almost like you are forced to opt-in to making your component a valid 'top level' component that gets to control the prefixing.
This makes me wonder, what is the behavior of doing something like:
Do you get an error? Is it the same as |
Right, how should we do this? Maybe the answer depends on how we want to do linking.
I don't think it's the answer to question (2) though since we're moving to making the prefix an argument to |
Yes it has changed because as you pointed out it will not be so uncommon to call
so if we need withModulePrefix anyway not sure we should expose it on the others |
core/src/main/scala/chisel3/experimental/hierarchy/InstantiateImpl.scala
Show resolved
Hide resolved
…without prefixing it
Co-authored-by: Megan Wachs <megan@sifive.com>
Co-authored-by: Megan Wachs <megan@sifive.com>
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.
approving with minor comments! Thanks for adding this great feature
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.
LGTM, consider fixing nit
Head branch was pushed to by a user without write access
Introduces a new API
withModulePrefix
.Example:
This will result in the definition of the following modules:
Only module definitions are prefixed. Other circuit components, such as wires and registers, are unaffected.
Module prefixes nest, where
Foo_Bar_Submod
indicating that a prefixFoo
exists in the grantparent or higher of the instance ofSubmod
.When using this API with
Instantiate
, two instantiations under two distinct module prefix blocks will result in two "copies" of the definition, one for each prefix. Conversely, two instantiations under the same module prefix block will share the same prefixed definition.Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending 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
.