Skip to content

Commit

Permalink
[FIRRTL] Cleanup SiTest BBox Metadata tests, NFC
Browse files Browse the repository at this point in the history
Minor polishing of existing SiTest Blackbox metadata tests.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
  • Loading branch information
seldridge committed Nov 12, 2024
1 parent 78afda8 commit 1c0606e
Showing 1 changed file with 49 additions and 23 deletions.
72 changes: 49 additions & 23 deletions test/Dialect/FIRRTL/emit-metadata.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ firrtl.circuit "TestBlackboxes" attributes {

// -----

// CHECK-LABEL: firrtl.circuit "BasicBlackboxes" {
firrtl.circuit "BasicBlackboxes" attributes {
annotations = [
{
Expand Down Expand Up @@ -180,39 +179,66 @@ firrtl.circuit "BasicBlackboxes" attributes {
defname = "ignored4"
}

// CHECK: firrtl.class @SitestBlackBoxModulesSchema(in %[[moduleName_in:.+]]: !firrtl.string, out %moduleName: !firrtl.string) {
// CHECK: firrtl.propassign %moduleName, %[[moduleName_in]]
// CHECK: }

// CHECK: firrtl.class @SitestBlackBoxMetadata(out %TestBlackbox_field: !firrtl.class<@SitestBlackBoxModulesSchema(in moduleName_in: !firrtl.string, out moduleName: !firrtl.string)>, out %DUTBlackbox_0_field: !firrtl.class<@SitestBlackBoxModulesSchema(in moduleName_in: !firrtl.string, out moduleName: !firrtl.string)>, out %DUTBlackbox_1_field: !firrtl.class<@SitestBlackBoxModulesSchema(in moduleName_in: !firrtl.string, out moduleName: !firrtl.string)>) attributes {portAnnotations = []} {
// CHECK: firrtl.string "TestBlackbox"
// CHECK: %TestBlackbox = firrtl.object @SitestBlackBoxModulesSchema
// CHECK: firrtl.propassign %TestBlackbox_field, %TestBlackbox
// CHECK: firrtl.string "DUTBlackbox2"
// CHECK: %DUTBlackbox_0 = firrtl.object @SitestBlackBoxModulesSchema
// CHECK: firrtl.propassign %DUTBlackbox_0_field, %DUTBlackbox_0
// CHECK: firrtl.string "DUTBlackbox1"
// CHECK: %DUTBlackbox_1 = firrtl.object @SitestBlackBoxModulesSchema
// CHECK: firrtl.propassign %DUTBlackbox_1_field, %DUTBlackbox_1
// CHECK: }
// Gracefully handle missing defnames.
firrtl.extmodule @NoDefName()

firrtl.extmodule @TestBlackbox() attributes {defname = "TestBlackbox"}

// CHECK: emit.file "test_blackboxes.json" {
// CHECK-NEXT{LITERAL}: emit.verbatim "[\0A \22TestBlackbox\22\0A]"
// CHECK-NEXT: }

// Should be de-duplicated and sorted.
firrtl.extmodule @DUTBlackbox_0() attributes {defname = "DUTBlackbox2"}
firrtl.extmodule @DUTBlackbox_1() attributes {defname = "DUTBlackbox1"}
firrtl.extmodule @DUTBlackbox_2() attributes {defname = "DUTBlackbox1"}
// CHECK: emit.file "dut_blackboxes.json" {
// CHECK-NEXT{LITERAL}: emit.verbatim "[\0A \22DUTBlackbox1\22,\0A \22DUTBlackbox2\22\0A]"
// CHECK-NEXT: }
}

// (1) Class-based metadata ----------------------------------------------------
//
// CHECK: firrtl.class @SitestBlackBoxModulesSchema(
// CHECK-SAME: in %[[moduleName_in:.+]]: !firrtl.string,
// CHECK-SAME: out %moduleName: !firrtl.string
// CHECK-SAME: ) {
// CHECK-NEXT: firrtl.propassign %moduleName, %[[moduleName_in]]
// CHECK: }
//
// CHECK: firrtl.class @SitestBlackBoxMetadata(
// CHECK-SAME: out %TestBlackbox_field: !firrtl.class<@SitestBlackBoxModulesSchema(
// CHECK-SAME: out %DUTBlackbox_0_field: !firrtl.class<@SitestBlackBoxModulesSchema(
// CHECK-SAME: out %DUTBlackbox_1_field: !firrtl.class<@SitestBlackBoxModulesSchema(
//
// CHECK-NEXT: %[[#defname:]] = firrtl.string "TestBlackbox"
// CHECK-NEXT: %[[object:.+]] = firrtl.object @SitestBlackBoxModulesSchema
// CHECK-NEXT: %[[#moduleName:]] = firrtl.object.subfield %[[object]][moduleName_in]
// CHECK-NEXT: firrtl.propassign %[[#moduleName]], %[[#defname:]] : !firrtl.string
// CHECK-NEXT: firrtl.propassign %TestBlackbox_field, %[[object]]
//
// CHECK-NEXT: %[[#defname:]] = firrtl.string "DUTBlackbox2"
// CHECK-NEXT: %[[object:.+]] = firrtl.object @SitestBlackBoxModulesSchema
// CHECK-NEXT: %[[#moduleName:]] = firrtl.object.subfield %[[object]][moduleName_in]
// CHECK-NEXT: firrtl.propassign %[[#moduleName]], %[[#defname:]] : !firrtl.string
// CHECK-NEXT: firrtl.propassign %DUTBlackbox_0_field, %[[object]]
//
// CHECK-NEXT: %[[#defname:]] = firrtl.string "DUTBlackbox1"
// CHECK-NEXT: %[[object:.+]] = firrtl.object @SitestBlackBoxModulesSchema
// CHECK-NEXT: %[[#moduleName:]] = firrtl.object.subfield %[[object]][moduleName_in]
// CHECK-NEXT: firrtl.propassign %[[#moduleName]], %[[#defname:]] : !firrtl.string
// CHECK-NEXT: firrtl.propassign %DUTBlackbox_1_field, %[[object]]
//
// CHECK-NOT: firrtl.object

// (2) JSON file-based metadata ------------------------------------------------
//
// CHECK: emit.file "test_blackboxes.json" {
// CHECK-NEXT{LITERAL}: emit.verbatim "[\0A
// CHECK-SAME: \22TestBlackbox\22\0A
// CHECK-SAME: ]"
// CHECK-NEXT: }
//
// CHECK: emit.file "dut_blackboxes.json" {
// CHECK-NEXT{LITERAL}: emit.verbatim "[\0A
// CHECK-SAME: \22DUTBlackbox1\22,\0A
// CHECK-SAME: \22DUTBlackbox2\22\0A
// CHECK-SAME: ]"
// CHECK-NEXT: }

// -----

//===----------------------------------------------------------------------===//
Expand Down

0 comments on commit 1c0606e

Please sign in to comment.