From c9a320b00ec31bc971cba0f09d1bbf3851733c46 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Wed, 26 Aug 2020 10:36:31 -0700 Subject: Emit parentheses in Verilog for nested unary ops (#1865) --- src/test/scala/firrtlTests/VerilogEmitterTests.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/test') diff --git a/src/test/scala/firrtlTests/VerilogEmitterTests.scala b/src/test/scala/firrtlTests/VerilogEmitterTests.scala index 42f0bf85..0a5c2c29 100644 --- a/src/test/scala/firrtlTests/VerilogEmitterTests.scala +++ b/src/test/scala/firrtlTests/VerilogEmitterTests.scala @@ -754,6 +754,24 @@ class VerilogEmitterSpec extends FirrtlFlatSpec { result("test \uD83D\uDE0E") should containLine(" assign z = x; // @[test \\uD83D\\uDE0E]") } + + it should "emit repeated unary operators with parentheses" in { + val result1 = compileBody( + """input x : UInt<1> + |output z : UInt<1> + |z <= not(not(x)) + |""".stripMargin + ) + result1 should containLine("assign z = ~(~x);") + + val result2 = compileBody( + """input x : UInt<8> + |output z : UInt<1> + |z <= not(andr(x)) + |""".stripMargin + ) + result2 should containLine("assign z = ~(&x);") + } } class VerilogDescriptionEmitterSpec extends FirrtlFlatSpec { -- cgit v1.2.3