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

[ImportVerilog] Add if and loop statements #6831

Merged
merged 1 commit into from Mar 20, 2024

Conversation

fabianschuiki
Copy link
Contributor

Extend the ImportVerilog conversion to support if statements and for, repeat, while, do ... while, and forever loops. Lower them to scf.if and scf.while ops for now. In the future, since Verilog has break, continue, and return statements, we may have to switch to a different dialect or defined these ops in the Moore dialect.

Extend the `ImportVerilog` conversion to support `if` statements and
`for`, `repeat`, `while`, `do ... while`, and `forever` loops. Lower
them to `scf.if` and `scf.while` ops for now. In the future, since
Verilog has `break`, `continue`, and `return` statements, we may have to
switch to a different dialect or defined these ops in the Moore dialect.

Co-authored-by: Hailong Sun <hailong.sun@terapines.com>
Co-authored-by: ShiZuoye <albertethon@163.com>
Co-authored-by: hunterzju <hunter_ht@zju.edu.cn>
Co-authored-by: Anqi Yu <anqi.yu@terapines.com>
@fabianschuiki fabianschuiki added the Verilog/SystemVerilog Involving a Verilog dialect label Mar 14, 2024
// CHECK: } do {
// CHECK: scf.yield
// CHECK: }
do x = y; while (x);
Copy link
Member

Choose a reason for hiding this comment

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

I think the moore.blocking_assign %x, %y should occur in the "after" region, like do{ moore.blocking_assign %x, %y}.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry about that, I mixed the concept with the while and do-while 😅.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah the naming in scf is a bit adventurous at times 😁

Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

LGTM

@fabianschuiki fabianschuiki merged commit 002fe7c into main Mar 20, 2024
4 checks passed
@fabianschuiki fabianschuiki deleted the fschuiki/slang-control-flow branch March 20, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Verilog/SystemVerilog Involving a Verilog dialect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants