Skip to content
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

[Seq] Add clock gate conversion to extern module #5364

Merged
merged 1 commit into from
Jun 13, 2023

Conversation

fabianschuiki
Copy link
Contributor

Add the ExternalizeClockGate pass which converts all seq.clock_gate ops in a design into instances of a hw.module.extern. The name and ports of the extern module can be configured through pass options. In case the module has no test enable port, the conversion adds a comb.or to fold the enable and test enable operands of the seq.clock_gate into a single enable port.

@fabianschuiki fabianschuiki added the Seq Involving the `seq` dialect label Jun 12, 2023
Comment on lines +228 to +250
llvm::cl::opt<std::string, true> ckgModuleName{
"ckg-name", llvm::cl::desc("Clock gate module name"),
llvm::cl::location(clockGateOpts.moduleName),
llvm::cl::init("EICG_wrapper"), llvm::cl::cat(category)};

llvm::cl::opt<std::string, true> ckgInputName{
"ckg-input", llvm::cl::desc("Clock gate input port name"),
llvm::cl::location(clockGateOpts.inputName), llvm::cl::init("in"),
llvm::cl::cat(category)};

llvm::cl::opt<std::string, true> ckgOutputName{
"ckg-output", llvm::cl::desc("Clock gate output port name"),
llvm::cl::location(clockGateOpts.outputName), llvm::cl::init("out"),
llvm::cl::cat(category)};

llvm::cl::opt<std::string, true> ckgEnableName{
"ckg-enable", llvm::cl::desc("Clock gate enable port name"),
llvm::cl::location(clockGateOpts.enableName), llvm::cl::init("en"),
llvm::cl::cat(category)};

llvm::cl::opt<std::string, true> ckgTestEnableName{
"ckg-test-enable",
llvm::cl::desc("Clock gate test enable port name (optional)"),
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering whether there is a better way to handle this. I think practically it looks fine as is, but maybe? in the feature we might want to mix different flavors of clock gates. Another direction would be to introduce dedicated attributes into clock gate ops regarding mapped modules but even with that direction it'll be necessary to add similar options to LowerToHW. So probably the current implementation would be simpler. I guess this is a general problem about intrinsic lowering (how to map intrinsic to external modules, legalize to SV/Comb constructs) so perhaps we might want to revisit in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's a great point; we'll want to revisit this sometime down the road to see if we need more localized lowering specifications. For example, being able to specify a clock gate for some subhierarchy of the design.

My rationale for the current approach is that we currently have no options and no lowering, and this introduces at least a global option and some lowering. Hopefully we can expand this in the future!

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there/does there need to be support for the clock divider DFT signal thing too? cc #5219 . Haven't paged this in yet, apologies if that doesn't make sense 👍 .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good point, that's definitely something that needs to go into a follow-up PR. Right now this just handles emission of the seq.clock_gate op, which lowers from the firrtl.int.clock_gate intrinsic. The FIRRTL pipeline doesn't support that intrinsic yet in its passes (ExtractTestCode, WireDFT, etc.) -- on my todo list 😏 I totally expect that there will be some extensions to the intrinsic or seq.clock_gate op definitions.

Base automatically changed from fschuiki/lower-firrtl-clock-gate to main June 13, 2023 15:58
Add the `ExternalizeClockGate` pass which converts all `seq.clock_gate`
ops in a design into instances of a `hw.module.extern`. The name and
ports of the extern module can be configured through pass options. In
case the module has no test enable port, the conversion adds a `comb.or`
to fold the enable and test enable operands of the `seq.clock_gate` into
a single enable port.
Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

LGTM

@fabianschuiki fabianschuiki merged commit 5271822 into main Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Seq Involving the `seq` dialect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants