[FTD] Support Multi-Exit Loops#604
Merged
Merged
Conversation
AyaElAkhras
reviewed
Oct 16, 2025
Member
|
Could you also push the changes that we discussed to unify the if-else here ? |
AyaElAkhras
requested changes
Oct 23, 2025
AyaElAkhras
approved these changes
Oct 27, 2025
QinYuan2000
pushed a commit
to QinYuan2000/dynamatic
that referenced
this pull request
Feb 13, 2026
The previous fast token delivery crashed when running into loops with multiple exits (see example CFG below). This happened because gates (Mu gates in this case) stored only one block as their condition block, which fails when multiple blocks are needed as conditions. <img width="200" height="388" alt="linear_search_CFG" src="https://github.com/user-attachments/assets/d2b59e5e-a8b1-42a9-b51a-141755eeb216" /> To fix this, two new attributes were added to `Gate`: - a boolean expression for the condition - a list of cofactors, representing the variables used in the condition expression. For each Mu gate, the loop exit condition is computed by OR-ing the exit conditions of all exiting blocks. The condition of the Mu is then set as the negation of this exit condition (i.e., the loop iteration condition). For Gamma gates, the condition remains the same as before, taken from the condition block. In `FtdImplementation.cpp`, whenever the condition value of a gate/loop is needed: - If there is a single cofactor, the same process as before is used, - If there are multiple cofactors, a Binary Decision Diagram (BDD) is built, translated into a circuit, and used as the condition value. In addition, in `boolVariableToCircuit` function, conditions generated for gates with multiple exiting blocks do not require channelification.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The previous fast token delivery crashed when running into loops with multiple exits (see example CFG below).
This happened because gates (Mu gates in this case) stored only one block as their condition block, which fails when multiple blocks are needed as conditions.
To fix this, two new attributes were added to
Gate:For each Mu gate, the loop exit condition is computed by OR-ing the exit conditions of all exiting blocks. The condition of the Mu is then set as the negation of this exit condition (i.e., the loop iteration condition).
For Gamma gates, the condition remains the same as before, taken from the condition block.
In
FtdImplementation.cpp, whenever the condition value of a gate/loop is needed:In addition, in
boolVariableToCircuitfunction, conditions generated for gates with multiple exiting blocks do not require channelification.