From 347bd2f9b23eb8cf67089c314741d571adf82aac Mon Sep 17 00:00:00 2001 From: Richard Lin Date: Fri, 24 Mar 2017 14:08:11 -0700 Subject: Fixed fix, allow Mux of different binary points and widths (#559) Allow muxing FxP of different widths and BPs--- src/test/scala/chiselTests/FixedPointSpec.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src') 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 } + } } -- cgit v1.2.3