diff options
| author | Jack Koenig | 2020-10-05 10:53:02 -0700 |
|---|---|---|
| committer | GitHub | 2020-10-05 10:53:02 -0700 |
| commit | 630d6dfd5a35842e7331f86b4bcbdffbcc35d5d9 (patch) | |
| tree | 9256ba6d3323eb49ac54b1f608aa28ec5a763074 /src/test | |
| parent | c1c2fb99b0bbbaedcd4138e7dfdd04e3910167f0 (diff) | |
| parent | a7a5030d9af1b504fd373e5060f66a859cb972dc (diff) | |
Merge pull request #1915 from freechipsproject/fix-negative-literal-fixup
Fix "fix" for negative literals > 32 bits
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/firrtlTests/VerilogEmitterTests.scala | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/VerilogEmitterTests.scala b/src/test/scala/firrtlTests/VerilogEmitterTests.scala index 7001a724..4a3686fa 100644 --- a/src/test/scala/firrtlTests/VerilogEmitterTests.scala +++ b/src/test/scala/firrtlTests/VerilogEmitterTests.scala @@ -735,6 +735,26 @@ class VerilogEmitterSpec extends FirrtlFlatSpec { result should containLine("assign z = _GEN_0[1:0];") } + it should "correctly emit addition with a negative literal with width > 32" in { + val result = compileBody( + """input x : SInt<34> + |output z : SInt<34> + |z <= asSInt(tail(add(x, SInt<34>(-2)), 1)) + |""".stripMargin + ) + result should containLine("assign z = $signed(x) - 34'sh2;") + } + + it should "correctly emit conjunction with a negative literal with width > 32" in { + val result = compileBody( + """input x : SInt<34> + |output z : SInt<34> + |z <= asSInt(and(x, SInt<34>(-2))) + |""".stripMargin + ) + result should containLine("assign z = $signed(x) & -34'sh2;") + } + it should "emit FileInfo as Verilog comment" in { def result(info: String): CircuitState = compileBody( s"""input x : UInt<2> |
