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

[MooreToCore] Add nested moore.conditional support #8125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AndreyVV-100
Copy link
Contributor

Hi! This code adds correct lowering for nested ternary operators like this:

module Mod(input a, input b, output logic [1:0] c);
always_comb
    c = a ? b ? 2'd0 : 2'd1 : 2'd2;
endmodule

This code adds correct lowering for nested ternary operators like this:

```verilog
module Mod(input a, input b, output logic [1:0] c);
always_comb
    c = a ? b ? 2'd0 : 2'd1 : 2'd2;
endmodule
```
Comment on lines +1349 to +1350
if (operation->hasTrait<OpTrait::HasRecursiveMemoryEffects>())
return WalkResult::advance();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice one!

Comment on lines +1010 to +1020
%5 = moore.conditional %4 : l1 -> l2 {
%6 = moore.read %b_1 : <l1>
%7 = moore.conditional %6 : l1 -> l2 {
moore.yield %2 : l2
} {
moore.yield %1 : l2
}
moore.yield %7 : l2
} {
moore.yield %0 : l2
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This test uses quite a few other supporting operations (module, nets, variables, procedure, blocking assigns) to test the conditional lowering. Would it be possible to move just the conditionals and the corresponding checks into a func.func, similar to @Conversions just below? It might be possible to even move it inside of @Conversions. That would make the test less brittle if any of the module and procedure lowerings change, which are unrelated to the conditionals.

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.

2 participants