From 6043ede715a44992975e60990fd2924b1ea6896a Mon Sep 17 00:00:00 2001 From: chick Date: Thu, 12 Dec 2019 12:06:15 -0800 Subject: Fixed problem creating Interval literals with full ranges - boundary testing was not taking binary point into account correctly - add tests to show where things work and where they are supposed to fail --- src/test/scala/chiselTests/IntervalSpec.scala | 44 ++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/test/scala/chiselTests/IntervalSpec.scala b/src/test/scala/chiselTests/IntervalSpec.scala index 863771a3..1e56d8a3 100644 --- a/src/test/scala/chiselTests/IntervalSpec.scala +++ b/src/test/scala/chiselTests/IntervalSpec.scala @@ -456,12 +456,54 @@ class IntervalSpec extends FreeSpec with Matchers with ChiselRunners { () => new BasicTester { val x = 5.I(range"[0,4]") - } + } ).elaborate } } } + "Interval literals creation handles edge cases" - { + "value at closed boundaries works" in { + val inputRange = range"[-6, 6].2" + val in1 = (-6.0).I(inputRange) + val in2 = 6.0.I(inputRange) + BigDecimal(in1.litValue()) / (1 << inputRange.binaryPoint.get) should be (-6) + BigDecimal(in2.litValue()) / (1 << inputRange.binaryPoint.get) should be (6) + intercept[ChiselException] { + (-6.25).I(inputRange) + } + intercept[ChiselException] { + (6.25).I(inputRange) + } + } + "value at open boundaries works" in { + val inputRange = range"(-6, 6).2" + val in1 = (-5.75).I(inputRange) + val in2 = 5.75.I(inputRange) + BigDecimal(in1.litValue()) / (1 << inputRange.binaryPoint.get) should be (-5.75) + BigDecimal(in2.litValue()) / (1 << inputRange.binaryPoint.get) should be (5.75) + intercept[ChiselException] { + (-6.0).I(inputRange) + } + intercept[ChiselException] { + (6.0).I(inputRange) + } + } + "values not precisely at open boundaries works but are converted to nearest match" in { + val inputRange = range"(-6, 6).2" + val in1 = (-5.95).I(inputRange) + val in2 = 5.95.I(inputRange) + BigDecimal(in1.litValue()) / (1 << inputRange.binaryPoint.get) should be (-5.75) + BigDecimal(in2.litValue()) / (1 << inputRange.binaryPoint.get) should be (5.75) + intercept[ChiselException] { + (-6.1).I(inputRange) + } + intercept[ChiselException] { + (6.1).I(inputRange) + } + } + } + "Let's take a look at the results of squeeze over small range" in { assertTesterPasses { new ClipSqueezeWrapDemo( -- cgit v1.2.3 From 4ef91c4c43d6ab808e79edd239062f919a5bbbe3 Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Mon, 16 Dec 2019 15:07:55 -0500 Subject: Remove unused WriteEmitted phase (#1273) This removes a dead line where a WriteEmitted phase is constructed. Signed-off-by: Schuyler Eldridge --- src/main/scala/chisel3/stage/package.scala | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/main/scala/chisel3/stage/package.scala b/src/main/scala/chisel3/stage/package.scala index 67d38ae7..57766be6 100644 --- a/src/main/scala/chisel3/stage/package.scala +++ b/src/main/scala/chisel3/stage/package.scala @@ -28,7 +28,6 @@ package object stage { private[chisel3] implicit object ChiselExecutionResultView extends OptionsView[ChiselExecutionResult] { - lazy val dummyWriteEmitted = new firrtl.stage.phases.WriteEmitted lazy val dummyConvert = new Convert lazy val dummyEmitter = new Emitter -- cgit v1.2.3