Skip to content

Conversation

fabianschuiki
Copy link
Contributor

The LLHD Deseq pass detects clocks and optional asynchronous resets. It currently, mistakenly, creates seq.compreg ops with those clocks and resets. The seq.compreg op turns out to have a synchronous reset though, making the lowering invalid. Use the seq.firreg op instead, as it allows the reset type to be specified explicitly. This requries an additional comb.mux to be created for potential enable signals, which seq.firreg does not support directly.

We should really nail down the semantics of seq.compreg in a follow-up commit. The documentation is very vague, and Deseq is likely not the last pass mistakenly assuming the explicit reset of seq.compreg is assumed to be asynchronous.

The LLHD Deseq pass detects clocks and optional asynchronous resets. It
currently, mistakenly, creates `seq.compreg` ops with those clocks and
resets. The `seq.compreg` op turns out to have a _synchronous_ reset
though, making the lowering invalid. Use the `seq.firreg` op instead, as
it allows the reset type to be specified explicitly. This requries an
additional `comb.mux` to be created for potential enable signals, which
`seq.firreg` does not support directly.

We should really nail down the semantics of `seq.compreg` in a follow-up
commit. The documentation is very vague, and Deseq is likely not the
last pass mistakenly assuming the explicit reset of `seq.compreg` is
assumed to be asynchronous.
@fabianschuiki fabianschuiki requested review from mortbopet and uenoku July 8, 2025 02:05
@fabianschuiki fabianschuiki requested a review from maerhart as a code owner July 8, 2025 02:05
@fabianschuiki fabianschuiki added LLHD Seq Involving the `seq` dialect labels Jul 8, 2025
Copy link
Member

@maerhart maerhart left a comment

Choose a reason for hiding this comment

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

LGTM! Would be really nice to get that firreg+compreg unification over the finish line indeed.

@@ -239,7 +239,6 @@ def FirRegOp : SeqOp<"firreg",
);
let results = (outs AnyType:$data);

let skipDefaultBuilders = 1;
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary? Aren't you just using the second custom builder or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I was trying initially, but it turns out that the second custom builder requires the reset and reset value to be non-null. So you'd have to call either the first or second builder depending on whether you want a reset or not. Having the default builder available feels like a good thing.

@fabianschuiki fabianschuiki merged commit 9ef39af into main Jul 8, 2025
7 checks passed
@fabianschuiki fabianschuiki deleted the fschuiki/switch-deseq-to-firreg branch July 8, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LLHD Seq Involving the `seq` dialect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants