-
Notifications
You must be signed in to change notification settings - Fork 383
[circt-opt] Add pass --convert-core-to-fsm
#8852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the PR! I haven't properly reviewed the pass code yet (I'll try to do that soon) but in the meantime I have some high-level comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Still haven't done a detailed pass, just some things I noticed)
--convert-core-to-fsm
--convert-core-to-fsm
moduleOp.walk([&](circt::seq::CompRegOp reg) { | ||
if (reg.getName()->contains("state")) { | ||
stateRegs.push_back(reg); | ||
} else { | ||
variableRegs.push_back(reg); | ||
} | ||
}); | ||
if (stateRegs.empty()) { | ||
emitError(moduleOp.getLoc()) | ||
<< "Cannot find state register in this FSM. You might need to " | ||
"manually specify which registers are state registers.\n"; | ||
return mlir::failure(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This analysis does not look reliable. Is it possible to replace it with an analogue of fsm_detect
from yosys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's true, but I think that to have modularity, it would be fine to split up the total pipeline into fsm_detect
and fsm_extract
(like Yosys does). So, theoretically there could be a pass circt-opt --annotate-fsm-state-registers
that works in combination with circt-opt --convert-core-to-fsm
. In the meantime, it's not too difficult for the user to manually annotate the FSM state registers in an RTL design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe for now we could just require it to always have the name of the state register explicitly given by the user? That way we don't need to worry about users having it opaquely pick up a register they don't expect, and we can always later change it to a flag that will get it to look for an attribute
This PR adds a pass to
circt-opt
called--convert-core-to-fsm
. This pass converts code written in RTL (comb
+seq
) and converts it to thefsm
dialect.It recognises and extracts FSM structure from an RTL netlist. It has similar functionality to
fsm_extract
in yosys:https://yosyshq.readthedocs.io/projects/yosys/en/0.46/cmd/fsm.html