calyx icon indicating copy to clipboard operation
calyx copied to clipboard

Generate or-and trees for guarded assignments

Open rachitnigam opened this issue 1 year ago • 3 comments
trafficstars

Instead of generating:

in = g0 ? o1 : 
       g1 ? o2 : 'x

This generates:

in = ({WIDTH{g0}} & o1) |
       ({WIDTH{g1}} & o2) | 0

Note that we have to generate 0 instead of 'x because otherwise the &-| chain will produce an 'x value.

The --emit-mux option simulates the old behavior.

I'm also noticing that a lot of optimizations around guards are now happening within the Verilog backend which is bad. We should move that logic into a pass if possible.

rachitnigam avatar Apr 25 '24 17:04 rachitnigam

Fixes #1423

rachitnigam avatar Apr 25 '24 17:04 rachitnigam

I think if/when this gets merged this should not be made the default yet. As mentioned on slack I have concerns that this will have unintended effects on resource utilization because it makes it harder for synthesis to optimize away guards.

andrewb1999 avatar Apr 25 '24 17:04 andrewb1999

Good point! The alternative is generating casex statements which might not have the best support in the simulators we use but should otherwise support the optimization and generation of non-priority logic.

rachitnigam avatar Apr 26 '24 16:04 rachitnigam

This pull request has been marked as stale due to inactivity.

github-actions[bot] avatar Oct 10 '24 00:10 github-actions[bot]