8000 [FIRRTL] InferResets: properly lower FART'd registers by youngar · Pull Request #7680 · llvm/circt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[FIRRTL] InferResets: properly lower FART'd registers #7680

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

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/Dialect/FIRRTL/Transforms/InferResets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1685,6 +1685,14 @@ LogicalResult InferResetsPass::implementFullReset(FModuleOp module,
return success();
}

// Add an annotation indicating that this module belongs to a reset domain.
auto *context = module.getContext();
AnnotationSet annotations(module);
annotations.addAnnotations(DictionaryAttr::get(
context, NamedAttribute(StringAttr::get(context, "class"),
StringAttr::get(context, fullResetAnnoClass))));
annotations.applyToOperation(module);

// If needed, add a reset port to the module.
Value actualReset = domain.existingValue;
if (domain.newPortName) {
Expand Down
27 changes: 27 additions & 0 deletions test/Dialect/FIRRTL/infer-resets.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,33 @@ firrtl.circuit "ZeroWidthRegister" {

// -----

// Every module which is contained inside a reset domain should be annotated as
// such, so that internal registers can be lowered later correctly.
// https://github.com/llvm/circt/issues/7675
firrtl.circuit "top" {
// CHECK: firrtl.module private @test
// CHECK-SAME: annotations = [{class = "circt.FullResetAnnotation"}]
firrtl.module private @test(in %clock: !firrtl.clock, in %reset: !firrtl.asyncreset, in %in: !firrtl.uint<8>, out %out: !firrtl.uint<8>) {
%resetvalue = firrtl.wire : !firrtl.uint<8>
%invalid_ui8 = firrtl.invalidvalue : !firrtl.uint<8>
firrtl.matchingconnect %resetvalue, %invalid_ui8 : !firrtl.uint<8>
%reg1 = firrtl.regreset %clock, %reset, %resetvalue : !firrtl.clock, !firrtl.asyncreset, !firrtl.uint<8>, !firrtl.uint<8>
firrtl.matchingconnect %reg1, %in : !firrtl.uint<8>
firrtl.matchingconnect %out, %reg1 : !firrtl.uint<8>
}
// CHECK: firrtl.module @top
// CHECK-SAME: annotations = [{class = "circt.FullResetAnnotation"}]
firrtl.module @top(in %clock: !firrtl.clock, in %reset: !firrtl.asyncreset [{class = "circt.FullResetAnnotation", resetType = "async"}], in %in: !firrtl.uint<8>, out %out: !firrtl.uint<8>) attributes {convention = #firrtl<convention scalarized>} {
%child_clock, %child_reset, %child_in, %child_out = firrtl.instance child @test(in clock: !firrtl.clock, in reset: !firrtl.asyncreset, in in: !firrtl.uint<8>, out out: !firrtl.uint<8>)
firrtl.matchingconnect %child_clock, %clock : !firrtl.clock
firrtl.matchingconnect %child_reset, %reset : !firrtl.asyncreset
firrtl.matchingconnect %child_in, %in : !firrtl.uint<8>
firrtl.matchingconnect %out, %child_out : !firrtl.uint<8>
}
}

// -----

// Check that unaffected fields ("data") are not being affected by width
// inference. See https://github.com/llvm/circt/issues/2857.
// CHECK-LABEL: firrtl.module @ZeroLengthVectorInBundle1
Expand Down
Loading
0