diff options
| author | Paul Rigge | 2016-12-05 16:54:37 -0800 |
|---|---|---|
| committer | Paul Rigge | 2016-12-13 15:10:19 -0800 |
| commit | 53e9794ea4471d0da29d688cefdc462a9be98b63 (patch) | |
| tree | 0894f5f1d1540148fe43a1098d0da176d47c46a8 /src/test | |
| parent | 32c3c0d46dcd24ae3430ec151eacab5049bf07a9 (diff) | |
Add a test for fromBits on fixed point numbers.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/chiselTests/FixedPointSpec.scala | 16 |
1 files changed, 16 insertions, 0 deletions
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 { |
