-
Notifications
You must be signed in to change notification settings - Fork 281
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
[FIRRTL] Add DPI call intrinsic and lowering pass #7139
Conversation
498c824
to
cbfc483
Compare
@@ -59,7 +59,7 @@ def FatalOp : SimOp<"fatal"> { | |||
|
|||
def DPIFuncOp : SimOp<"func.dpi", | |||
[IsolatedFromAbove, Symbol, OpAsmOpInterface, | |||
FunctionOpInterface, HasParent<"mlir::ModuleOp">]> { | |||
FunctionOpInterface]> { |
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 is similar change to 09df7f5. It was necessary to put DPI func op into circuit op to make the lowering composable.
| Port | Direction | Type | Description | | ||
| ----------------- | --------- | -------- | ------------------------------- | | ||
| clock (optional) | input | Clock | Optional clock operand | | ||
| enable | input | UInt<1> | Enable signal | |
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.
enable is not optional at Chisel level to follow the same design as verification intrinsic.
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 great!!!
Thanks for the comments to point out or explain various things!
Added some feedback, minor nits.
FModuleOp module; | ||
SmallVector<DPICallIntrinsicOp> dpiOps; | ||
}; | ||
SmallVector<DpiCallCollections> results; |
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.
Consider a reserve
.
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.
Since we cannot know the actual number of FModuleOp beforehand I reserved 64.
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.
Probably 64 won't fit on the stack / small size, so maybe make the SmallVector 0-length (or 64?) or whatever seems good. Not blocking, just a stray thought since tab still open :).
@@ -0,0 +1,54 @@ | |||
; RUN: firtool %s --format=fir | FileCheck %s | |||
|
|||
FIRRTL version 4.0.0 |
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.
🤩 awesome seeing this end-to-end!!
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, this is great!!!
Consider adding a small test case for the error re:mismatched DPI signatures just to make sure that works (and continues to)?
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.
Awesome! LGTM
51c2761
to
02e489b
Compare
77745c6
to
d7675f1
Compare
Added an error test, thank you for review! |
This PR adds DPICallIntrinsicOp and its lowering pass. DPICallIntrinsicOp is lowered into sim.func.dpi.call and sim.func.dpi ops. At FIRRTL level DPICallIntrinsicOp doesn't have symbols and instead LowerDPI pass accumulates callsites and creates symbols for dpi functions. LowerDPI pass directly lowers FIRRTL intrinsic into Sim dialect since FIRRTL doesn't have DPI/Function construct. LowerDPI pass could be simplified (or migrated into LowerToHW) once FIRRTL gets 1st class support for Function. Unrealized conversion cast is used to mix FIRRTL and HW type values before LowerToHW.