diff options
| author | Jack Koenig | 2019-11-29 23:08:38 -0800 |
|---|---|---|
| committer | Jack Koenig | 2020-01-07 18:35:42 -0800 |
| commit | df48d61c3e1cb476f51762b1f009ecc9391221c6 (patch) | |
| tree | 4991282dac9f3511c71af9435936a29551de6617 /src/test | |
| parent | 66f354558a21cd0d339968b3665b44c17c2c16e8 (diff) | |
Remove unnecessary casts in Constant Propagation
Diffstat (limited to 'src/test')
| -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 |
