diff options
| author | Kevin Laeufer | 2021-01-19 13:14:24 -0800 |
|---|---|---|
| committer | GitHub | 2021-01-19 21:14:24 +0000 |
| commit | 2882912385c744389092b4f8d426379908d01ed7 (patch) | |
| tree | 2529e0bdc9c76dd9e9754fbeb2d797609cab212a /src/test | |
| parent | bbd7fc4115728ecc7cf88bf0524f2126d8220c34 (diff) | |
smt: run DeadCodeElimination after PropagatePresetAnnotations (#2036)
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/firrtl/backends/experimental/smt/FirrtlToTransitionSystemPassSpec.scala | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/scala/firrtl/backends/experimental/smt/FirrtlToTransitionSystemPassSpec.scala b/src/test/scala/firrtl/backends/experimental/smt/FirrtlToTransitionSystemPassSpec.scala new file mode 100644 index 00000000..7dc5298c --- /dev/null +++ b/src/test/scala/firrtl/backends/experimental/smt/FirrtlToTransitionSystemPassSpec.scala @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: Apache-2.0 + +package firrtl.backends.experimental.smt + +import firrtl.annotations.{CircuitTarget, PresetAnnotation} +import firrtl.options.Dependency +import firrtl.testutils.LeanTransformSpec + +class FirrtlToTransitionSystemPassSpec extends LeanTransformSpec(Seq(Dependency(firrtl.backends.experimental.smt.FirrtlToTransitionSystem))) { + behavior of "FirrtlToTransitionSystem" + + it should "support preset wires" in { + // In order to give registers an initial wire, we use preset annotated resets. + // When using a wire instead of an input (which has the advantage of working regardless of the + // module hierarchy), we need to initialize it in order to get through the wire initialization check. + // In Chisel this generates a node which needs to be removed. + + val src = """circuit ModuleAB : + | module ModuleAB : + | input clock : Clock + | node _T = asAsyncReset(UInt<1>("h0")) + | node preset = _T + | reg REG : UInt<1>, clock with : + | reset => (preset, UInt<1>("h0")) + | assert(clock, UInt(1), not(REG), "REG == 0") + |""".stripMargin + val anno = PresetAnnotation(CircuitTarget("ModuleAB").module("ModuleAB").ref("preset")) + + val result = compile(src, List(anno)) + val sys = result.annotations.collectFirst{ case TransitionSystemAnnotation(sys) => sys }.get + assert(sys.states.head.init.isDefined) + } +} |
