Skip to content

Conversation

mvpant
Copy link
Contributor

@mvpant mvpant commented Sep 2, 2025

This simplifies an llhd.process that has only a single basic block with an llhd.halt terminator.

  1. Lifts constant-like yield operands of llhd.halt operation and replaces uses of llhd.process results with them directly.
  2. Deduplicates the yield operands of llhd.halt.

@mvpant
Copy link
Contributor Author

mvpant commented Sep 2, 2025

Regarding the initial process that just ends in an llhd.halt:

    %2:2 = llhd.process -> i1, i1 {
      llhd.halt %false, %reset : i1, i1
    }
    llhd.drv %reg_0, %2#0 after %0 if %2#1 : !hw.inout<i1>

This should actually be pretty straightforward to handle. I think we're just missing a folder or canonicalizer that replaces llhd.process results with the corresponding llhd.halt constant operand, if there's only a single llhd.halt in the last block.

It's important to only do this for constant operands, since the process runs only once at very beginning. This means that any non-constant value would basically be "snapshot" at that specific point in time and produced as a result from the process. This result won't change throughout the simulation, even if the original non-constant value does. Doing this only for constants works around this problem.

This is a follow up to the discussion

Copy link
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

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

Very cool! Thanks a lot for adding this 👍 🙌

@fabianschuiki
Copy link
Contributor

Want me to merge this, @mvpant?

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

Successfully merging this pull request may close these issues.

2 participants