-
Notifications
You must be signed in to change notification settings - Fork 299
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
[SV] Added DPI import and call ops #4856
base: main
Are you sure you want to change the base?
Conversation
cab2b12
to
0a63652
Compare
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.
It seems this is treating calls more like modules than functions. We do need to represent functions, it would be worth doing so now, rather than have to rip this out later.
A couple other things:
- I think output values from a call should be able to use the same forced-spilling code as modules use. I guess it's not as sometimes you use a reg. I assume that is because the output argument of a call is not a continuous assignment? But maybe not? "For output and inout arguments, the value propagation (i.e., value change events) happens as if an actual argument was assigned a formal argument immediately after control returns from imported functions." I can't tell from that if it's suppose to be blocking or non-blocking. Implicit sensitivity are function aware, fwiw.
- BPAssign probably shouldn't care what the source of a value is.
@@ -3091,6 +3094,9 @@ LogicalResult StmtEmitter::visitSV(AssignOp op) { | |||
} | |||
|
|||
LogicalResult StmtEmitter::visitSV(BPAssignOp op) { | |||
if (dyn_cast_or_null<DPICallOp>(op.getSrc().getDefiningOp())) |
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 you assume that structs won't have accessors prior to assign?
I'll re-work this to separately indicate which arguments are inputs and outputs, requiring inout types for outputs. |
From talking to @nandor, will handle return types too and make calls expressions. Marking this draft for now. |
Is there any update on the DPI import and export functions? This is common used in the DV flow, wondering if there are outstanding work on it. |
This PR introduces DPI import and call operations.
To import a function, the following can be declared at the module level:
sv.dpi.import @test(%arg0: i32) -> (res0: i5, res1: i6)
This is hard-wire to contextual functions.
To call a function, an op can be added to procedural scopes.
%res0, %res1 = sv.dpi.call @test(%arg0) : (i32) -> (i5, i6)
The emission is similar to instances. Temporary registers will be added to capture the results of DPI calls.
In the future, constraints should be relaxed to allow for return types and to place calls in arbitrary contexts.