diff options
| author | Jack Koenig | 2016-12-05 12:24:04 -0800 |
|---|---|---|
| committer | GitHub | 2016-12-05 12:24:04 -0800 |
| commit | a34f2265c9bfed4eb1d72d611e435df5d57e86e3 (patch) | |
| tree | 884e00c51c9012ec960b3165533172eec56acb68 /src/test | |
| parent | ad36788b79f8b63be59d9612134889aef874c286 (diff) | |
Add check for muxing between clocks (#360)
Also run CheckTypes after ExpandWhens
Fixes #330
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/firrtlTests/FirrtlSpec.scala | 8 | ||||
| -rw-r--r-- | src/test/scala/firrtlTests/UnitTests.scala | 17 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/FirrtlSpec.scala b/src/test/scala/firrtlTests/FirrtlSpec.scala index 90db3524..a2c880c3 100644 --- a/src/test/scala/firrtlTests/FirrtlSpec.scala +++ b/src/test/scala/firrtlTests/FirrtlSpec.scala @@ -109,6 +109,14 @@ trait BackendCompilationUtilities { trait FirrtlRunners extends BackendCompilationUtilities { def parse(str: String) = Parser.parse(str.split("\n").toIterator, IgnoreInfo) lazy val cppHarness = new File(s"/top.cpp") + /** Compiles input Firrtl to Verilog */ + def compileToVerilog(input: String, annotations: AnnotationMap = AnnotationMap(Seq.empty)): String = { + val circuit = Parser.parse(input.split("\n").toIterator) + val compiler = new VerilogCompiler + val writer = new java.io.StringWriter + compiler.compile(CircuitState(circuit, HighForm, Some(annotations)), writer) + writer.toString + } /** Compile a Firrtl file * * @param prefix is the name of the Firrtl file without path or file extension diff --git a/src/test/scala/firrtlTests/UnitTests.scala b/src/test/scala/firrtlTests/UnitTests.scala index e2f8f729..cb07448f 100644 --- a/src/test/scala/firrtlTests/UnitTests.scala +++ b/src/test/scala/firrtlTests/UnitTests.scala @@ -304,4 +304,21 @@ class UnitTests extends FirrtlFlatSpec { } } + + "Conditional conection of clocks" should "throw an exception" in { + val input = + """circuit Unit : + | module Unit : + | input clock1 : Clock + | input clock2 : Clock + | input sel : UInt<1> + | output clock3 : Clock + | clock3 <= clock1 + | when sel : + | clock3 <= clock2 + |""".stripMargin + intercept[PassExceptions] { // Both MuxClock and InvalidConnect are thrown + compileToVerilog(input) + } + } } |
