aboutsummaryrefslogtreecommitdiff
path: root/src/test/resources
diff options
context:
space:
mode:
authorJack Koenig2021-03-19 13:59:52 -0700
committerGitHub2021-03-19 13:59:52 -0700
commit49b823244732e8d3a4b0fe91d0f10625fea34eec (patch)
treef47edb75d158b9654b5ea60c8aa95176caf7dd70 /src/test/resources
parentb274b319d4a4014c154f06bfc174beba461d6fce (diff)
Legalize neg: -x becomes 0 - x (#2128)
This fixes an error with negating a negative SInt literal and a [debatable] lint warning in Verilator when negating any value. This behavior matches that of Chisel (which directly emits the 0 - x already).
Diffstat (limited to 'src/test/resources')
-rw-r--r--src/test/resources/passes/Legalize/Legalize.fir22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/resources/passes/Legalize/Legalize.fir b/src/test/resources/passes/Legalize/Legalize.fir
index 7e538695..a0a39845 100644
--- a/src/test/resources/passes/Legalize/Legalize.fir
+++ b/src/test/resources/passes/Legalize/Legalize.fir
@@ -39,3 +39,25 @@ circuit Legalize :
when neq(bar_15, UInt(1)) :
printf(clock, UInt(1), "Assertion failed!\n bar_15 != 0\n")
stop(clock, UInt(1), 1)
+
+ ; Check neg of literals
+ node negUInt0 = neg(UInt(123))
+ when neq(negUInt0, SInt(-123)) :
+ printf(clock, UInt(1), "Assertion failed!\n negUInt0 != -123\n")
+ stop(clock, UInt(1), 1)
+ node negUInt1 = neg(UInt<8>(0))
+ when neq(negUInt1, SInt<8>(0)) :
+ printf(clock, UInt(1), "Assertion failed!\n negUInt1 != 0\n")
+ stop(clock, UInt(1), 1)
+ node negSInt0 = neg(SInt(123))
+ when neq(negSInt0, SInt(-123)) :
+ printf(clock, UInt(1), "Assertion failed!\n negSInt0 != -123\n")
+ stop(clock, UInt(1), 1)
+ node negSInt1 = neg(SInt(-123))
+ when neq(negSInt1, SInt(123)) :
+ printf(clock, UInt(1), "Assertion failed!\n negSInt1 != 123\n")
+ stop(clock, UInt(1), 1)
+ node negSInt2 = neg(SInt(0))
+ when neq(negSInt2, SInt(0)) :
+ printf(clock, UInt(1), "Assertion failed!\n negSInt2 != 0\n")
+ stop(clock, UInt(1), 1)