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

[FIRRTL][WireDFT] Wire test-en to ClockGateIntrinsic. #6488

Merged
merged 2 commits into from
Dec 5, 2023

Conversation

dtzSiFive
Copy link
Contributor

@dtzSiFive dtzSiFive commented Dec 4, 2023

Extend WireDFT to support wiring the test-enable signal to ClockGateIntrinsicOp's in same manner it does extmodules magically matched as the test-enable wiring targets.

@dtzSiFive
Copy link
Contributor Author

Curious, local clang-tidy doesn't report that (seems like it should). Welp.

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.

Super nice! 💯 🥳 LGTM

@@ -381,7 +402,7 @@ void WireDFTPass::runOnOperation() {

auto wireUp = [&](Value startSignal, FModuleOp signalModule,
StringAttr portName, StringRef portNameFriendly,
unsigned targetPortNo, auto &targets) -> LogicalResult {
auto &dests) -> LogicalResult {
Copy link
Contributor

Choose a reason for hiding this comment

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

Templated lambdas are magic 🌈 🙌

Comment on lines +512 to +524
auto testEnableDests = llvm::map_to_vector(clockGates, [&](auto *rec) {
return cast<InstanceOp>(*rec->getInstance()).getResult(testEnPortNo);
});
llvm::append_range(
testEnableDests,
llvm::map_range(cgIntrinsics, [&](ClockGateIntrinsicOp cgOp) {
// Insert wire to run test-enable signal to,
// and change the CG intrinsic to use it as such.
auto builder = ImplicitLocOpBuilder(cgOp.getLoc(), cgOp);
auto wire = builder.create<WireOp>(enableSignal.getType());
cgOp.getTestEnableMutable().assign(wire.getResult());
return wire.getResult();
}));
Copy link
Contributor

Choose a reason for hiding this comment

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

Clever! I was wondering how you're going to deal with the intrinsic having an actual operand instead of a wire-y thing. This is a nice low-friction way to do it!

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, it will add unnecessary wires in common case where the test-enable comes from above, but needed for some cases where it comes from below or in same module (without dominance checking). The wiring logic here isn't as robust as WiringProblem's and that has some limitations too IIRC in some corner cases. Anyway, once we don't have to handle both forms it'd be good to rework this to handle this better but low-friction indeed 👍 .

@dtzSiFive dtzSiFive merged commit 98a1afa into llvm:main Dec 5, 2023
4 checks passed
@dtzSiFive dtzSiFive deleted the feature/clock-gate-wiredft branch December 5, 2023 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants