diff options
| author | David Biancolin | 2019-01-21 18:50:51 -0500 |
|---|---|---|
| committer | GitHub | 2019-01-21 18:50:51 -0500 |
| commit | 10586d6a141859b843057ec9979011e26ad207f1 (patch) | |
| tree | ff23c30013159cdd1879b1e5c3dd5baca5bf4867 /src/test/scala/firrtlTests/CheckCombLoopsSpec.scala | |
| parent | 73ae6257fce586ac145b6ab348ce1b47634e7a46 (diff) | |
| parent | df3a34f01d227ff9ad0e63a41ff10001ac01c01d (diff) | |
Merge branch 'master' into top-wiring-aggregates
Diffstat (limited to 'src/test/scala/firrtlTests/CheckCombLoopsSpec.scala')
| -rw-r--r-- | src/test/scala/firrtlTests/CheckCombLoopsSpec.scala | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/CheckCombLoopsSpec.scala b/src/test/scala/firrtlTests/CheckCombLoopsSpec.scala index 8fc7dda9..98472f14 100644 --- a/src/test/scala/firrtlTests/CheckCombLoopsSpec.scala +++ b/src/test/scala/firrtlTests/CheckCombLoopsSpec.scala @@ -165,6 +165,92 @@ class CheckCombLoopsSpec extends SimpleTransformSpec { } } + "Combinational loop through an annotated ExtModule" should "throw an exception" in { + val input = """circuit hasloops : + | extmodule blackbox : + | input in : UInt<1> + | output out : UInt<1> + | module hasloops : + | input clk : Clock + | input a : UInt<1> + | input b : UInt<1> + | output c : UInt<1> + | output d : UInt<1> + | wire y : UInt<1> + | wire z : UInt<1> + | c <= b + | inst inner of blackbox + | inner.in <= y + | z <= inner.out + | y <= z + | d <= z + |""".stripMargin + + val mt = ModuleTarget("hasloops", "blackbox") + val annos = AnnotationSeq(Seq(ExtModulePathAnnotation(mt.ref("in"), mt.ref("out")))) + val writer = new java.io.StringWriter + intercept[CheckCombLoops.CombLoopException] { + compile(CircuitState(parse(input), ChirrtlForm, annos), writer) + } + } + + "Loop-free circuit with ExtModulePathAnnotations" should "not throw an exception" in { + val input = """circuit hasnoloops : + | extmodule blackbox : + | input in1 : UInt<1> + | input in2 : UInt<1> + | output out1 : UInt<1> + | output out2 : UInt<1> + | module hasnoloops : + | input clk : Clock + | input a : UInt<1> + | output b : UInt<1> + | wire x : UInt<1> + | inst inner of blackbox + | inner.in1 <= a + | x <= inner.out1 + | inner.in2 <= x + | b <= inner.out2 + |""".stripMargin + + val mt = ModuleTarget("hasnoloops", "blackbox") + val annos = AnnotationSeq(Seq( + ExtModulePathAnnotation(mt.ref("in1"), mt.ref("out1")), + ExtModulePathAnnotation(mt.ref("in2"), mt.ref("out2")))) + val writer = new java.io.StringWriter + compile(CircuitState(parse(input), ChirrtlForm, annos), writer) + } + + "Combinational loop through an output RHS reference" should "throw an exception" in { + val input = """circuit hasloops : + | module thru : + | input in : UInt<1> + | output tmp : UInt<1> + | output out : UInt<1> + | tmp <= in + | out <= tmp + | module hasloops : + | input clk : Clock + | input a : UInt<1> + | input b : UInt<1> + | output c : UInt<1> + | output d : UInt<1> + | wire y : UInt<1> + | wire z : UInt<1> + | c <= b + | inst inner of thru + | inner.in <= y + | z <= inner.out + | y <= z + | d <= z + |""".stripMargin + + val writer = new java.io.StringWriter + intercept[CheckCombLoops.CombLoopException] { + compile(CircuitState(parse(input), ChirrtlForm), writer) + } + } + "Multiple simple loops in one SCC" should "throw an exception" in { val input = """circuit hasloops : | module hasloops : |
