-
Notifications
You must be signed in to change notification settings - Fork 643
Create method for marking all ports of a Module with DontTouchAnnotation
#3866
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
base: main
Are you sure you want to change the base?
Conversation
|
Is this necessary now that |
jackkoenig
left a comment
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 LGTM, I don't love the name dontTouch.modulePorts but I also don't have a better idea so 🤷♀️
@seldridge @azidar do you have any opinions on the name? Also this API makes it such that it will dontTouch any ports added via BoringUtils even after the function is called (because the call to DataMirror.fullModulePorts is delayed
| * | ||
| * @param module whose ports shouldl not get optimized away | ||
| */ | ||
| def modulePorts(module: BaseModule): BaseModule = { |
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.
You need an implicit SourceInfo here for DataMirror.fullModulePorts, that's why compilation is failing (incremental compile often hides this particular problem, that you can't materialize source locators in chisel core).
| def toFirrtl: Seq[Annotation] = (DataMirror.fullModulePorts(module).map { | ||
| case (_, data) => DontTouchAnnotation(data.toNamed) | ||
| }) |
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.
fullModulePorts is returns every Aggregate and Element so this will result in dontTouching things multiple times. Can we instead maybe just use .modulePorts and call dontTouch.apply above (which does the recursion and only marks Elements)?
I agree with moving away from dontTouch generally but Public does impose additional constraints w.r.t. inferred resets and port widths that dontTouch doesn't. |
|
|
||
| /** Mark a module so that its ports will not get optimized away. | ||
| * | ||
| * @param module whose ports shouldl not get optimized away |
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.
| * @param module whose ports shouldl not get optimized away | |
| * @param module whose ports should not get optimized away |
| data | ||
| } | ||
|
|
||
| /** Mark a module so that its ports will not get optimized away. |
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.
does this already do the right thing w.r.t. property ports and probe ports?
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.
As we discussed in dev, we're fine to add this API but we should direct users to Public and Probe here in the API docs depending on the use case.
Is not enforcing those constraints a requirement? I'm trying to conserve concepts here and if this API is being used to create testable units, then I think those also probably want public and what it entails. I won't hold this up as don't touch is a thing and having a utility to don't touch all the ports is generally useful. However, this is an intermediate API that I think we generally want to move off of. |
|
I think there are 3 main historical use cases of this API:
(1) and (2) are what you should do in code that actually hits main, but (3) is still important IMO. |
|
I think that makes sense. Is there anyway that we can prevent users using (3) in situations where they should be using (1) or (2)? Annoyingly, all I could think of is not providing this API. 🙃 |
| } | ||
|
|
||
| "dontTouch.modulePorts" should "mark all ports of a module" in { | ||
| class ModuleWithPorts extends Module { |
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 we add a test for a Module with property and/or Probe ports? Im unclear if those are expected to be annotated, or there is supposed to be an error, or...?
Contributor Checklist
docs/src?Type of Improvement
Desired Merge Strategy
Release Notes
Create
dontTouch.modulePortsmethod for marking all ports of aModulewithDontTouchAnnotation.Reviewer Checklist (only modified by reviewer)
3.6.x,5.x, or6.xdepending 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.