aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJack Koenig2017-06-12 13:58:26 -0700
committerJack Koenig2017-06-12 18:52:46 -0700
commit541003c59c73ecce6d38020ecc3cf537dd214fd9 (patch)
tree22e8518a40673c408ec06c907c3f61c6449cdfab /src/test
parent317115b7a0ce21d5848e985988c777f9931af241 (diff)
Add option to disable combinational loop detection
Resolves #600
Diffstat (limited to 'src/test')
-rw-r--r--src/test/resources/features/HasLoops.fir9
-rw-r--r--src/test/scala/firrtlTests/CheckCombLoopsSpec.scala19
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/resources/features/HasLoops.fir b/src/test/resources/features/HasLoops.fir
new file mode 100644
index 00000000..e238761d
--- /dev/null
+++ b/src/test/resources/features/HasLoops.fir
@@ -0,0 +1,9 @@
+circuit HasLoops :
+ module HasLoops :
+ input i : UInt<1>
+ output o : UInt<1>
+ wire a : UInt<1>
+ wire b : UInt<1>
+ a <= and(b,i)
+ b <= not(a)
+ o <= add(a, UInt(1))
diff --git a/src/test/scala/firrtlTests/CheckCombLoopsSpec.scala b/src/test/scala/firrtlTests/CheckCombLoopsSpec.scala
index dfb61843..2c12d4ca 100644
--- a/src/test/scala/firrtlTests/CheckCombLoopsSpec.scala
+++ b/src/test/scala/firrtlTests/CheckCombLoopsSpec.scala
@@ -8,6 +8,8 @@ import firrtl.passes._
import firrtl.transforms._
import firrtl.Mappers._
import annotations._
+import java.io.File
+import java.nio.file.Paths
class CheckCombLoopsSpec extends SimpleTransformSpec {
@@ -147,5 +149,22 @@ class CheckCombLoopsSpec extends SimpleTransformSpec {
compile(CircuitState(parse(input), ChirrtlForm, None), writer)
}
}
+}
+
+class CheckCombLoopsCommandLineSpec extends FirrtlFlatSpec {
+ val testDir = createTestDirectory("CombLoopChecker")
+ val inputFile = Paths.get(getClass.getResource("/features/HasLoops.fir").toURI()).toFile()
+ val outFile = new File(testDir, "HasLoops.v")
+ val args = Array("-i", inputFile.getAbsolutePath, "-o", outFile.getAbsolutePath, "-X", "verilog")
+
+ "Combinational loops detection" should "run by default" in {
+ a [CheckCombLoops.CombLoopException] should be thrownBy {
+ firrtl.Driver.execute(args)
+ }
+ }
+
+ it should "not run when given --no-check-comb-loops option" in {
+ firrtl.Driver.execute(args :+ "--no-check-comb-loops")
+ }
}