circt
circt copied to clipboard
[CalyxToFSM] Controller FSM outlining and instantiation
#3595 introduced FSM materialization for the Calyx control program. In this, an FSM was materialized with top-level I/O corresponding to the go, done
ports of the compiledGroups
within the control program.
The final step in control schedule lowering is to outline the FSM into module
scope and replace it with an fsm.hwinstance
operation. When doing this, we need to define the I/O of the fsm.hwinstance
operation:
- inputs will be
group_done
signals for the compiled groups - outputs will be
group_go
signals to the compiled groups
The ideal place to do this is to modify the remove-groups pass by:
- Perform the conversion as it exists now but instead by using backedges for the
group_go
signals to each group, and recording thegroup_done
signals for each group. - outline the
fsm.machine
into module scope - replace it with a
fsm.hwinstance
, withgroup_done
operands sorted by thecompiledGroups
attribute. - Replace the
group_go
backedges with the results of thefsm.hwinstance
operation.