Skip to content
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

[Sim] Add DPI func/call and lowering #7042

Open
wants to merge 1 commit into
base: dev/hidetou/func-export
Choose a base branch
from

Conversation

uenoku
Copy link
Member

@uenoku uenoku commented May 15, 2024

This PR adds DPI func/call op and SimToSV lowering.

sim.dpi.func is a just bridge to sv.func. This op can be lowered into func.func in the future for Arc integration.

sim.func.dpi.call represents SystemVerilog DPI function call. There are two optional operands clock and enable.

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. When enable is low, results of unclocked calls are undefined and in SV results they are lowered into X. Users are expected to gate result values by another enable 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.

@uenoku uenoku force-pushed the dev/hidetou/func-export branch 3 times, most recently from ef06699 to 3767a5b Compare June 4, 2024 14:32
@uenoku uenoku force-pushed the dev/hidetou/dpi-sim branch 4 times, most recently from c3ec8a7 to 7de08da Compare June 4, 2024 14:41
@uenoku uenoku marked this pull request as ready for review June 4, 2024 14:45
Comment on lines +91 to +95
p, op->getRegion(0), op.getModuleType(),
op.getPerArgumentAttrsAttr()
? ArrayRef<Attribute>(op.getPerArgumentAttrsAttr().getValue())
: ArrayRef<Attribute>{},
SmallVector<Location>(getArgumentLocs().value().getAsRange<Location>()));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll refactor this ugly part...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant