diff options
| author | John Ingalls | 2020-01-06 18:47:19 -0800 |
|---|---|---|
| committer | Jack Koenig | 2020-01-06 18:47:19 -0800 |
| commit | f77487d37bd7c61be231a8000a3197d37cf55499 (patch) | |
| tree | 99208af73baad6fef176ce86d14a17e790e15d10 /src/test/scala/firrtlTests/ConstantPropagationTests.scala | |
| parent | dcf0076ca9b4b3c094d2d082717265fb4e326ae0 (diff) | |
Verilog emitter transform InlineNots (#1270)
[skip formal checks]
* ConstProp FoldEqual/FoldNotEqual propagate boolean (non-)equality with true/false
* transform InlineNots
* transform back-to-back Nots into straight rename
* swap mux with inverted select
Co-authored-by: Jack Koenig <jack.koenig3@gmail.com>
Diffstat (limited to 'src/test/scala/firrtlTests/ConstantPropagationTests.scala')
| -rw-r--r-- | src/test/scala/firrtlTests/ConstantPropagationTests.scala | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/ConstantPropagationTests.scala b/src/test/scala/firrtlTests/ConstantPropagationTests.scala index 79e73c80..71709255 100644 --- a/src/test/scala/firrtlTests/ConstantPropagationTests.scala +++ b/src/test/scala/firrtlTests/ConstantPropagationTests.scala @@ -735,6 +735,78 @@ class ConstantPropagationSingleModule extends ConstantPropagationSpec { (parse(exec(input))) should be(parse(check)) } + "ConstProp" should "propagate boolean equality with true" in { + val input = + """circuit Top : + | module Top : + | input x : UInt<1> + | output z : UInt<1> + | z <= eq(x, UInt<1>("h1")) + """.stripMargin + val check = + """circuit Top : + | module Top : + | input x : UInt<1> + | output z : UInt<1> + | z <= x + """.stripMargin + (parse(exec(input))) should be(parse(check)) + } + + "ConstProp" should "propagate boolean equality with false" in { + val input = + """circuit Top : + | module Top : + | input x : UInt<1> + | output z : UInt<1> + | z <= eq(x, UInt<1>("h0")) + """.stripMargin + val check = + """circuit Top : + | module Top : + | input x : UInt<1> + | output z : UInt<1> + | z <= not(x) + """.stripMargin + (parse(exec(input))) should be(parse(check)) + } + + "ConstProp" should "propagate boolean non-equality with true" in { + val input = + """circuit Top : + | module Top : + | input x : UInt<1> + | output z : UInt<1> + | z <= neq(x, UInt<1>("h1")) + """.stripMargin + val check = + """circuit Top : + | module Top : + | input x : UInt<1> + | output z : UInt<1> + | z <= not(x) + """.stripMargin + (parse(exec(input))) should be(parse(check)) + } + + "ConstProp" should "propagate boolean non-equality with false" in { + val input = + """circuit Top : + | module Top : + | input x : UInt<1> + | output z : UInt<1> + | z <= neq(x, UInt<1>("h0")) + """.stripMargin + val check = + """circuit Top : + | module Top : + | input x : UInt<1> + | output z : UInt<1> + | z <= x + """.stripMargin + (parse(exec(input))) should be(parse(check)) + } + // Optimizing this mux gives: z <= pad(UInt<2>(0), 4) // Thus this checks that we then optimize that pad "ConstProp" should "optimize nested Expressions" in { |
