diff options
| author | Chick Markley | 2020-01-23 12:06:53 -0800 |
|---|---|---|
| committer | GitHub | 2020-01-23 12:06:53 -0800 |
| commit | 37e2b8fee3c9d583fa9d023637e8bc327dc9866f (patch) | |
| tree | 56de0ff88ae71326064ef9ec033594b89a84ff70 /src/test/scala/chiselTests/IntervalSpec.scala | |
| parent | 993ee4ed8b95e2c78f6fc54ecbd828ac06a32b8b (diff) | |
| parent | 481736c3ebce29932b54ac72e01d6656e4995fca (diff) | |
Merge pull request #1284 from freechipsproject/big-decimal-methods-for-num-types
Provides Double and BigDecimal methods to access literal values for FixedPoint and Interval
Diffstat (limited to 'src/test/scala/chiselTests/IntervalSpec.scala')
| -rw-r--r-- | src/test/scala/chiselTests/IntervalSpec.scala | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/test/scala/chiselTests/IntervalSpec.scala b/src/test/scala/chiselTests/IntervalSpec.scala index 1e56d8a3..ee704c83 100644 --- a/src/test/scala/chiselTests/IntervalSpec.scala +++ b/src/test/scala/chiselTests/IntervalSpec.scala @@ -456,12 +456,27 @@ class IntervalSpec extends FreeSpec with Matchers with ChiselRunners { () => new BasicTester { val x = 5.I(range"[0,4]") - } + } ).elaborate } } } + "Interval literals support to double and to BigDecimal" in { + val d = -7.125 + val lit1 = d.I(3.BP) + lit1.litToDouble should be (d) + + val d2 = BigDecimal("1232123213131123.125") + val lit2 = d2.I(3.BP) + lit2.litToBigDecimal should be (d2) + + // Numbers that are too big will throw exception + intercept[ChiselException] { + lit2.litToDouble + } + } + "Interval literals creation handles edge cases" - { "value at closed boundaries works" in { val inputRange = range"[-6, 6].2" |
