From 53e9794ea4471d0da29d688cefdc462a9be98b63 Mon Sep 17 00:00:00 2001 From: Paul Rigge Date: Mon, 5 Dec 2016 16:54:37 -0800 Subject: Add a test for fromBits on fixed point numbers. --- src/test/scala/chiselTests/FixedPointSpec.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/test/scala/chiselTests') diff --git a/src/test/scala/chiselTests/FixedPointSpec.scala b/src/test/scala/chiselTests/FixedPointSpec.scala index 69015e42..b3ea30b5 100644 --- a/src/test/scala/chiselTests/FixedPointSpec.scala +++ b/src/test/scala/chiselTests/FixedPointSpec.scala @@ -17,6 +17,22 @@ class FixedPointSpec extends FlatSpec with Matchers { initialDouble should be(finalDouble) } + + behavior of "fixed point" + + they should "allow fromBits from now fixed point types" in { + val uint = 3.U + val sint = -3.S + val fp_tpe = FixedPoint(width = 4, binaryPoint = 1) + val uint_result = FixedPoint.fromDouble(1.5, width = 4, binaryPoint = 1) + val sint_result = FixedPoint.fromDouble(-1.5, width = 4, binaryPoint = 1) + + val uint2fp = fp_tpe.fromBits(uint) + val sint2fp = fp_tpe.fromBits(sint) + + uint2fp should be (uint_result) + sint2fp should be (sint_result) + } } class SBP extends Module { -- cgit v1.2.3