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] Add CreateCompanionAssume pass; Decouple UNROnlyAssume generation from AssertOp lowering #6863

Merged
merged 4 commits into from Mar 28, 2024

Conversation

uenoku
Copy link
Member

@uenoku uenoku commented Mar 22, 2024

This PR separates UNROnlyAssume generation from AssertOp lowering into a dedicate op.

This commit adds:

  • LowerToHW support for UnclockedPredicateIntrinsicOp (added in [FIRRTL] Add intrinsic for UNR only assume #6867).
  • CreateCompanionAssume pass which explicitly introduces companion assumes to the IR. Normal assume and UnclockedPredicateIntrinsicOp are used based on the guard's content.

The commit is intended not to change semantics of generated verilog. This commit should only introduces cosmetic changes regarding guards(because now they are reused).

@uenoku uenoku changed the title [FIRRTL] Create an intrinsic for UNR only assume [FIRRTL] Create an intrinsic for UNR only assume and decouple UNROnlyAssume generation from AssertOp lowering Mar 22, 2024
@uenoku uenoku force-pushed the dev/hidetou/unr-only-companion-assume branch from 3eba2d5 to 9395e78 Compare March 22, 2024 18:32
@uenoku uenoku force-pushed the dev/hidetou/unr-only-companion-assume branch 2 times, most recently from dbd780e to 7708dc8 Compare March 25, 2024 10:21
@uenoku uenoku changed the base branch from main to dev/hidetou/unr-only-assume-intr March 25, 2024 10:23
@uenoku uenoku changed the title [FIRRTL] Create an intrinsic for UNR only assume and decouple UNROnlyAssume generation from AssertOp lowering [FIRRTL] Add CreateCompanionAssume pass; Decouple UNROnlyAssume generation from AssertOp lowering Mar 25, 2024
Comment on lines -4482 to -4514

// Assertions gain a companion `assume` behind a
// `USE_PROPERTY_AS_CONSTRAINT` guard.
if (isAssert) {
StringAttr assumeLabel;
if (label)
assumeLabel = StringAttr::get(builder.getContext(),
"assume__" + label.getValue());

circuitState.addMacroDecl(
builder.getStringAttr("USE_PROPERTY_AS_CONSTRAINT"));
addToIfDefBlock("USE_PROPERTY_AS_CONSTRAINT", [&]() {
if (!isUnrOnlyAssert) {
builder.create<sv::AssumeConcurrentOp>(
circt::sv::EventControlAttr::get(builder.getContext(), event),
clock, predicate, assumeLabel);
} else {
builder.create<sv::AlwaysOp>(
ArrayRef(sv::EventControl::AtEdge), ArrayRef(predicate), [&]() {
buildImmediateVerifOp(builder, "assume", predicate,
circt::sv::DeferAssertAttr::get(
builder.getContext(),
circt::sv::DeferAssert::Immediate),
assumeLabel);
});
}
});
}
Copy link
Member Author

Choose a reason for hiding this comment

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

comment for link.

Copy link
Contributor

@dtzSiFive dtzSiFive left a comment

Choose a reason for hiding this comment

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

Generally LGTM, awesome thanks!

// If so, use AssumeEdgedPredicateIntrinsicOp.
if (isUnrOnlyAssert)
assume = builder.create<firrtl::AssumeEdgedPredicateIntrinsicOp>(
assertOp.getLoc(), assertOp.getPredicate(), assertOp.getEnable(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, thank you for pointing out! For normal assume I think it's totally Ok to have substitutions. For UNROnly assume, probably they are not enabled in the normal simulation but I agree that the behavior is uncertain.

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.

Great idea to factor out the companion assume business into its own pass, and that there is a dedicated intrinsic to capture the very peculiar flavor of assumes that some formal tools require. Pushes the ugly parts to the boundary and makes for a cleaner flow. 🥳

Base automatically changed from dev/hidetou/unr-only-assume-intr to main March 28, 2024 07:50
@uenoku uenoku force-pushed the dev/hidetou/unr-only-companion-assume branch from 7708dc8 to 87fa40c Compare March 28, 2024 09:27
@uenoku uenoku merged commit 37fbe5e into main Mar 28, 2024
4 checks passed
@uenoku uenoku deleted the dev/hidetou/unr-only-companion-assume branch March 28, 2024 10:08
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.

None yet

3 participants