Skip to content

Commit

Permalink
[Emit] Copy fragments into modules created by ExtractTestCode (#6843)
Browse files Browse the repository at this point in the history
  • Loading branch information
nandor authored Mar 18, 2024
1 parent 83a8292 commit 6d40b28
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 2 additions & 0 deletions lib/Dialect/SV/Transforms/SVExtractTestCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ static hw::HWModuleOp createModuleForCut(hw::HWModuleOp op,
b.getStringAttr(getVerilogModuleNameAttr(op).getValue() + suffix), ports);
if (path)
newMod->setAttr("output_file", path);
if (auto fragments = op->getAttr("emit.fragments"))
newMod->setAttr("emit.fragments", fragments);
newMod.setCommentAttr(b.getStringAttr("VCS coverage exclude_file"));
newMod.setPrivate();

Expand Down
22 changes: 16 additions & 6 deletions test/Dialect/SV/hw-extract-test-code.mlir
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
// RUN: circt-opt --sv-extract-test-code --split-input-file %s | FileCheck %s
// CHECK-LABEL: module attributes {firrtl.extract.assert = #hw.output_file<"dir3{{/|\\\\}}"
// CHECK-NEXT: sv.macro.decl @SYNTHESIS
// CHECK-NEXT: emit.fragment @some_fragment {
// CHECK-NEXT: sv.verbatim "foo"
// CHECK-NEXT: }
// CHECK-NEXT: hw.module.extern @foo_cover
// CHECK-NOT: attributes
// CHECK-NEXT: hw.module.extern @foo_assume
// CHECK-NOT: attributes
// CHECK-NEXT: hw.module.extern @foo_assert
// CHECK-NOT: attributes
// CHECK: hw.module private @issue1246_assert(in %clock : i1) attributes {comment = "VCS coverage exclude_file", output_file = #hw.output_file<"dir3{{/|\\\\}}", excludeFromFileList, includeReplicatedOps>}
// CHECK: hw.module private @issue1246_assert(in %clock : i1) attributes {comment = "VCS coverage exclude_file", emit.fragments = [@some_fragment], output_file = #hw.output_file<"dir3{{/|\\\\}}", excludeFromFileList, includeReplicatedOps>}
// CHECK: sv.assert
// CHECK: sv.error "Assertion failed"
// CHECK: sv.error "assert:"
// CHECK: sv.error "assertNotX:"
// CHECK: sv.error "check [verif-library-assert] is included"
// CHECK: sv.fatal 1
// CHECK: foo_assert
// CHECK: hw.module private @issue1246_assume(in %clock : i1)
// CHECK-SAME: attributes {comment = "VCS coverage exclude_file"}
// CHECK: hw.module private @issue1246_assume(in %clock : i1) attributes {
// CHECK-SAME: comment = "VCS coverage exclude_file"
// CHECK-SAME: emit.fragments = [@some_fragment]
// CEHCK-SAME: }
// CHECK: sv.assume
// CHECK: foo_assume
// CHECK: hw.module private @issue1246_cover(in %clock : i1)
// CHECK-SAME: attributes {comment = "VCS coverage exclude_file"}
// CHECK: hw.module private @issue1246_cover(in %clock : i1) attributes {
// CHECK-SAME: comment = "VCS coverage exclude_file"
// CHECK-SAME: emit.fragments = [@some_fragment]
// CEHCK-SAME: }
// CHECK: sv.cover
// CHECK: foo_cover
// CHECK: hw.module @issue1246
Expand All @@ -35,10 +42,13 @@
// CHECK: sv.bind <@issue1246::@__ETC_issue1246_cover>
module attributes {firrtl.extract.assert = #hw.output_file<"dir3/", excludeFromFileList, includeReplicatedOps>, firrtl.extract.assume.bindfile = #hw.output_file<"file4", excludeFromFileList>} {
sv.macro.decl @SYNTHESIS
emit.fragment @some_fragment {
sv.verbatim "foo"
}
hw.module.extern @foo_cover(in %a : i1) attributes {"firrtl.extract.cover.extra"}
hw.module.extern @foo_assume(in %a : i1) attributes {"firrtl.extract.assume.extra"}
hw.module.extern @foo_assert(in %a : i1) attributes {"firrtl.extract.assert.extra"}
hw.module @issue1246(in %clock: i1) {
hw.module @issue1246(in %clock: i1) attributes {emit.fragments = [@some_fragment]} {
sv.always posedge %clock {
sv.ifdef.procedural @SYNTHESIS {
} else {
Expand Down

0 comments on commit 6d40b28

Please sign in to comment.