summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChick Markley2021-10-07 14:31:16 -0700
committerGitHub2021-10-07 21:31:16 +0000
commitbaaa2adcbfcf4fb508d8e5e71345afd1d7e5a352 (patch)
tree047ce2d70ec2cb2f63aa6b3ac06df0d6a213edeb /src
parentcba0ba65e9a4f95430087a13627bc6b3c5ae5885 (diff)
Fixed bug with unary minus on FixedPoint and Interval (#2154)
In `Bits.scala`, `FixedPoint` and `Interval` did not defeine the `do_unary_-` methods (the `do_`) was missing The recent PR #2124 combined with the above fact made DspTools break. This fix is necessary to get that repo to build.
Diffstat (limited to 'src')
-rw-r--r--src/test/scala/chiselTests/FixedPointSpec.scala3
-rw-r--r--src/test/scala/chiselTests/IntervalSpec.scala7
2 files changed, 10 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/FixedPointSpec.scala b/src/test/scala/chiselTests/FixedPointSpec.scala
index a1acdb17..2530bb13 100644
--- a/src/test/scala/chiselTests/FixedPointSpec.scala
+++ b/src/test/scala/chiselTests/FixedPointSpec.scala
@@ -60,6 +60,9 @@ class FixedPointFromBitsTester extends BasicTester {
val negativefp = (-3.5).F(4.BP)
val positivefp = 3.5.F(4.BP)
+ assert(- positivefp === negativefp)
+ assert(positivefp === -negativefp)
+
assert(uint2fp === uint_result)
assert(sint2fp === sint_result)
assert(fp2fp === fp_result)
diff --git a/src/test/scala/chiselTests/IntervalSpec.scala b/src/test/scala/chiselTests/IntervalSpec.scala
index abc619e5..a33cedc1 100644
--- a/src/test/scala/chiselTests/IntervalSpec.scala
+++ b/src/test/scala/chiselTests/IntervalSpec.scala
@@ -406,6 +406,13 @@ class IntervalChainedSubTester extends BasicTester {
assert(intervalResult1 === 5.I)
assert(intervalResult2 === 5.I)
+ val negativeInterval = (-3.5).I(4.BP)
+ val positiveInterval = 3.5.I(4.BP)
+
+ assert(negativeInterval =/= positiveInterval)
+ assert(-negativeInterval === positiveInterval)
+ assert(negativeInterval === -positiveInterval)
+
stop()
}