[Sim] Add DPI func/call and lowering #7042
Open
+455
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds DPI func/call op and SimToSV lowering.
sim.dpi.func
is a just bridge tosv.func
. This op can be lowered intofunc.func
in the future for Arc integration.sim.func.dpi.call
represents SystemVerilog DPI function call. There are two optional operandsclock
andenable
.If
clock
is not provided, the callee is invoked when input values are changed. If provided, the dpi function is called at clock's posedge. The result values behave like registers and the DPI function is used as a state transfer function of them.enable
operand is used to conditionally call the DPI since DPI call could be quite more expensive than native constructs. Whenenable
is low, results of unclocked calls are undefined and in SV results they are lowered intoX
. Users are expected to gate result values by anotherenable
to model a default value of results. For clocked calls, a low enable means that its register state transfer function is not called. Hence their values will not be modify in that clock.A function that returns an explicit return is not supported yet. I'll follow-up.