-
Notifications
You must be signed in to change notification settings - Fork 298
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
[HW][SV] Transition "HWToSV" to "ProceduralCoreToSV" pass. #7335
base: main
Are you sure you want to change the base?
Conversation
I like the idea of |
Yeah. The way I lower
A motivation for having |
+1 for sim.triggered! In that case maybe we can just implement ProceduralRegion to sim.triggered regarding dialect dependecy? |
I think we can allow scf.if to have results. We can lowered that to sv.reg + sv.if + sv.bpassign in ProceduralCoreToSV. |
rewriter.setInsertionPoint(triggeredOp); | ||
auto alwaysOp = rewriter.create<sv::AlwaysOp>( | ||
triggeredOp.getLoc(), | ||
ArrayRef<sv::EventControl>{hwToSvEventControl(triggeredOp.getEvent())}, | ||
ArrayRef<Value>{triggeredOp.getTrigger()}); | ||
rewriter.mergeBlocks(triggeredOp.getBodyBlock(), alwaysOp.getBodyBlock(), | ||
triggeredOp.getInputs()); | ||
rewriter.eraseOp(triggeredOp); | ||
// Don't recurse into the body. |
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.
Was a there specific reason that removes OpConversion pattern and does manual walk? I think we generally prefer OpConversion pattern for the maintainability.
if (!!getOperation()->getParentOfType<hw::TriggeredOp>()) | ||
return emitOpError("must not be nested under another TriggeredOp."); |
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 `hasParentOp<"hw::HWModuleOp"> to TriggeredOp instead?
Thank you for your comments.
Would you keep the declaration of
Good point. I guess that should work.
The drawbacks of the Dialect Conversion framework listed in the linked Discourse thread have made me skeptical about it. This may be an overreaction. Of course there is benefit in keeping the code idiomatic. But is it worth it if it is a "bad" idiom and we don't actually need its features? I have also implemented the lowering of the TriggeredOp's body as a single walk and it seemed pretty straightforward to me. But this is not a hill I am going die on. If the consensus is that we prefer the conversion framework (or alternatively the GreedyPatternRewriteDriver) I'll change it.
I'd say this depends on how we want to deal with ifdef guards. The FIRRTL frontend wraps print operations in |
Yeah moving ProceduralRegion to Sim looks direction to me.
That's fair. In that case I think we don't have to define ProceduralOpRewriter since it's just a wrapper of OpBuilder if it's not used in the rewriter framework.
Hmm, I see. In that case the current implementation looks reasonable to me. |
This PR replaces the "HWToSV" conversion pass with the functionally identical "ProceduralCoreToSV". For the moment, it only converts the
hw.triggered
operation tosv.always
.The motivation for this change is to allow the lowering of the
sim.proc.print
operations added in #7292 without using the dialect conversion framework, due to its limitations, and without having to mix procedural core operations with procedural SV operations (cc #7314).On a more general note, I understand the concerns about having procedural regions in the core dialects voiced by @uenoku in the linked PRs. I also think we should keep the synthesizable portions of the design as dataflow-ish as possible. But I don't really see a viable option of pretending there is no control-flow in simulation. Maybe the answer here is to just turn
hw.triggered
intosim.triggered
?