diff options
| author | Jack Koenig | 2020-01-07 19:34:29 -0800 |
|---|---|---|
| committer | GitHub | 2020-01-07 19:34:29 -0800 |
| commit | d5dd427c0267dc143d4297d5fd0716f19cd7634b (patch) | |
| tree | 589e59ef4e2563ca67e695f476ed67a8f8ef5aa5 /src/test/scala/firrtlTests/ConstantPropagationTests.scala | |
| parent | 66f354558a21cd0d339968b3665b44c17c2c16e8 (diff) | |
| parent | e27bb38cf5b3ee8135bf416c2532b2abc2fc5ae4 (diff) | |
Merge pull request #1264 from freechipsproject/cleanup-verilog-emitter-casts
Cleanup verilog emitter casts
Diffstat (limited to 'src/test/scala/firrtlTests/ConstantPropagationTests.scala')
| -rw-r--r-- | src/test/scala/firrtlTests/ConstantPropagationTests.scala | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/test/scala/firrtlTests/ConstantPropagationTests.scala b/src/test/scala/firrtlTests/ConstantPropagationTests.scala index 71709255..af186cda 100644 --- a/src/test/scala/firrtlTests/ConstantPropagationTests.scala +++ b/src/test/scala/firrtlTests/ConstantPropagationTests.scala @@ -3,8 +3,6 @@ package firrtlTests import firrtl._ -import firrtl.ir.Circuit -import firrtl.Parser.IgnoreInfo import firrtl.passes._ import firrtl.transforms._ @@ -824,6 +822,30 @@ class ConstantPropagationSingleModule extends ConstantPropagationSpec { """.stripMargin (parse(exec(input))) should be(parse(check)) } + + def castCheck(tpe: String, cast: String): Unit = { + val input = + s"""circuit Top : + | module Top : + | input x : $tpe + | output z : $tpe + | z <= $cast(x) + """.stripMargin + val check = + s"""circuit Top : + | module Top : + | input x : $tpe + | output z : $tpe + | z <= x + """.stripMargin + (parse(exec(input)).serialize) should be (parse(check).serialize) + } + it should "optimize unnecessary casts" in { + castCheck("UInt<4>", "asUInt") + castCheck("SInt<4>", "asSInt") + castCheck("Clock", "asClock") + castCheck("AsyncReset", "asAsyncReset") + } } // More sophisticated tests of the full compiler |
