diff options
| author | Richard Lin | 2017-03-24 14:08:11 -0700 |
|---|---|---|
| committer | GitHub | 2017-03-24 14:08:11 -0700 |
| commit | 347bd2f9b23eb8cf67089c314741d571adf82aac (patch) | |
| tree | 747726947f73242a80a997f7993071bacce217a1 /src/test/scala/chiselTests | |
| parent | b572319a15bfdbefd535c0ea5c3767535c19707c (diff) | |
Fixed fix, allow Mux of different binary points and widths (#559)
Allow muxing FxP of different widths and BPs
Diffstat (limited to 'src/test/scala/chiselTests')
| -rw-r--r-- | src/test/scala/chiselTests/FixedPointSpec.scala | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/FixedPointSpec.scala b/src/test/scala/chiselTests/FixedPointSpec.scala index 85f20d97..5047ac62 100644 --- a/src/test/scala/chiselTests/FixedPointSpec.scala +++ b/src/test/scala/chiselTests/FixedPointSpec.scala @@ -78,6 +78,21 @@ class FixedPointFromBitsTester extends BasicTester { stop() } +class FixedPointMuxTester extends BasicTester { + val largeWidthLowPrecision = 6.0.F(3.W, 0.BP) + val smallWidthHighPrecision = 0.25.F(2.W, 2.BP) + val unknownWidthLowPrecision = 6.0.F(0.BP) + val unknownFixed = Wire(FixedPoint()) + unknownFixed := smallWidthHighPrecision + + assert(Mux(true.B, largeWidthLowPrecision, smallWidthHighPrecision) === 6.0.F(0.BP)) + assert(Mux(false.B, largeWidthLowPrecision, smallWidthHighPrecision) === 0.25.F(2.BP)) + assert(Mux(false.B, largeWidthLowPrecision, unknownFixed) === 0.25.F(2.BP)) + assert(Mux(true.B, unknownWidthLowPrecision, smallWidthHighPrecision) === 6.0.F(0.BP)) + + stop() +} + class SBP extends Module { val io = IO(new Bundle { val in = Input(FixedPoint(6.W, 2.BP)) @@ -106,4 +121,7 @@ class FixedPointSpec extends ChiselPropSpec { property("should allow fromBits") { assertTesterPasses { new FixedPointFromBitsTester } } + property("should mux different widths and binary points") { + assertTesterPasses { new FixedPointMuxTester } + } } |
