Skip to content

Commit b239f48

Browse files
committed
add tests
1 parent 68a47bc commit b239f48

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

core/src/main/scala-2/chisel3/PrintfMacros.scala

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import chisel3.experimental.SourceInfo
88
import chisel3.{layer, layers}
99
import scala.language.experimental.macros
1010
import scala.reflect.macros.blackbox
11+
import chisel3.VerifStmtMacrosCompat.resetToDisableMigrationChecks
1112

1213
object PrintfMacrosCompat {
1314
def _applyMacroWithInterpolatorCheck(
@@ -77,6 +78,7 @@ object PrintfMacrosCompat {
7778
Printable.checkScope(pable)
7879

7980
layer.block(layers.Verification, skipIfAlreadyInBlock = true, skipIfLayersEnabled = true) {
81+
resetToDisableMigrationChecks("printf")
8082
pushCommand(chisel3.internal.firrtl.ir.Printf(printfId, sourceInfo, clock.ref, pable))
8183
}
8284
printfId

src/main/scala/circt/stage/Shell.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import chisel3.stage.{
66
ChiselCircuitAnnotation,
77
ChiselGeneratorAnnotation,
88
CircuitSerializationAnnotation,
9+
EmitVerifStatementDisableProperties,
910
PrintFullStackTraceAnnotation,
1011
RemapLayer,
1112
SourceRootAnnotation,
@@ -44,7 +45,8 @@ trait CLI extends BareShell { this: BareShell =>
4445
WarningConfigurationFileAnnotation,
4546
SourceRootAnnotation,
4647
DumpFir,
47-
RemapLayer
48+
RemapLayer,
49+
EmitVerifStatementDisableProperties
4850
).foreach(_.addOptions(parser))
4951

5052
parser.note("CIRCT (MLIR FIRRTL Compiler) options")

src/test/scala/chiselTests/VerificationSpec.scala

+29-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class SimpleTest extends Module {
2121
}
2222
}
2323

24-
class VerificationSpec extends ChiselPropSpec with Matchers {
24+
class VerificationSpec extends ChiselPropSpec with FileCheck with Matchers {
2525

2626
def assertContains(s: Seq[String], x: String): Unit = {
2727
val containsLine = s.map(_.contains(x)).reduce(_ || _)
@@ -74,4 +74,32 @@ class VerificationSpec extends ChiselPropSpec with Matchers {
7474
exactly(1, svLines) should include("assume(io_in != 8'h2)")
7575
exactly(1, svLines) should include("$error(\"Assumption failed")
7676
}
77+
78+
property("verification statements should check that Disable toggles") {
79+
class DisableChecksTest extends Module {
80+
val io = IO(new Bundle {
81+
val in = Input(UInt(8.W))
82+
val out = Output(UInt(8.W))
83+
})
84+
io.out := io.in
85+
val assert = chisel3.assert(io.out === io.in)
86+
printf(cf"io: ${io.in}")
87+
}
88+
89+
val fir = ChiselStage.emitCHIRRTL(
90+
new DisableChecksTest,
91+
args = Array("--emit-verif-statement-disable-properties")
92+
)
93+
fileCheckString(fir)(
94+
"""
95+
CHECK: node assert_disable =
96+
CHECK: node [[NOT_DISABLE:[a-zA-Z0-9_]+]] = eq(assert_disable, UInt<1>(0h0))
97+
CHECK: node assert_ltl_eventually = intrinsic(circt_ltl_eventually : UInt<1>, [[NOT_DISABLE]])
98+
99+
CHECK: node disable =
100+
CHECK: node [[NOT_DISABLE_1:[a-zA-Z0-9_]+]] = eq(disable, UInt<1>(0h0))
101+
CHECK: node ltl_eventually = intrinsic(circt_ltl_eventually : UInt<1>, [[NOT_DISABLE_1]])
102+
"""
103+
)
104+
}
77105
}

0 commit comments

Comments
 (0)