@@ -29,14 +29,16 @@ class FixedRing1(val width: Int, val binaryPoint: Int) extends Module {
29
29
30
30
class FixedRing1Tester (c : FixedRing1 ) extends DspTester (c) {
31
31
val increment : Double = if (c.binaryPoint == 0 ) 1.0 else 1.0 / (1 << c.binaryPoint)
32
- for (i <- - 2.0 to 3.0 by increment) {
33
- poke(c.io.in, i)
34
-
35
- expect(c.io.floor, breeze.numerics.floor(i), s " floor of $i should be ${breeze.numerics.floor(i)}" )
36
- expect(c.io.ceil, breeze.numerics.ceil(i), s " ceil of $i should be ${breeze.numerics.ceil(i)}" )
37
- expect(c.io.isWhole, breeze.numerics.floor(i) == i , s " isWhole of $i should be ${breeze.numerics.floor(i) == i}" )
38
- expect(c.io.round, breeze.numerics.round(i), s " round of $i should be ${breeze.numerics.round(i)}" )
39
- step(1 )
32
+ updatableDspVerbose.withValue(false ) {
33
+ for (i <- - 2.0 to 3.0 by increment) {
34
+ poke(c.io.in, i)
35
+
36
+ expect(c.io.floor, breeze.numerics.floor(i), s " floor of $i should be ${breeze.numerics.floor(i)}" )
37
+ expect(c.io.ceil, breeze.numerics.ceil(i), s " ceil of $i should be ${breeze.numerics.ceil(i)}" )
38
+ expect(c.io.isWhole, breeze.numerics.floor(i) == i , s " isWhole of $i should be ${breeze.numerics.floor(i) == i}" )
39
+ expect(c.io.round, breeze.numerics.round(i), s " round of $i should be ${breeze.numerics.round(i)}" )
40
+ step(1 )
41
+ }
40
42
}
41
43
}
42
44
@@ -95,34 +97,38 @@ class FixedPointShiftTester(c: FixedPointShifter) extends DspTester(c) {
95
97
val z = y / factor
96
98
z
97
99
}
98
- poke(c.io.dynamicShiftValue, 0 )
100
+ updatableDspVerbose.withValue( false ) {
99
101
100
- private val (minSIntValue, maxSIntValue) = firrtl_interpreter.extremaOfSIntOfWidth(c.width )
102
+ poke(c.io.dynamicShiftValue, 0 )
101
103
102
- private val minValue = minSIntValue.toDouble * increment
103
- private val maxValue = maxSIntValue.toDouble * increment
104
+ val (minSIntValue, maxSIntValue) = firrtl_interpreter.extremaOfSIntOfWidth(c.width)
104
105
105
- for (value <- minValue to maxValue by increment) {
106
- poke(c.io.inValue, value)
107
- expect(c.io.shiftLeftResult, expectedValue(value, left = true , c.fixedShiftSize),
108
- s " shift left ${c.fixedShiftSize} of $value should be ${expectedValue(value, left = true , c.fixedShiftSize)}" )
109
- c.io.shiftRightResult.foreach { sro =>
110
- expect(sro, expectedValue(value, left = false , c.fixedShiftSize),
111
- s " shift right ${c.fixedShiftSize} of $value should be ${expectedValue(value, left = false , c.fixedShiftSize)}" )
112
- }
106
+ val minValue = minSIntValue.toDouble * increment
107
+ val maxValue = maxSIntValue.toDouble * increment
113
108
114
- step(1 )
109
+ for (value <- minValue to maxValue by increment) {
110
+ poke(c.io.inValue, value)
111
+ expect(c.io.shiftLeftResult, expectedValue(value, left = true , c.fixedShiftSize),
112
+ s " shift left ${c.fixedShiftSize} of $value should be ${expectedValue(value, left = true , c.fixedShiftSize)}" )
113
+ c.io.shiftRightResult.foreach { sro =>
114
+ expect(sro, expectedValue(value, left = false , c.fixedShiftSize),
115
+ s " shift right ${c.fixedShiftSize} of $value should be ${expectedValue(value, left = false , c.fixedShiftSize)}" )
116
+ }
115
117
116
- for (dynamicShiftValue <- 0 until c.width) {
117
- poke(c.io.dynamicShiftValue, dynamicShiftValue)
118
118
step(1 )
119
- expect(c.io.dynamicShiftLeftResult, expectedValue(value, left = true , dynamicShiftValue),
120
- s " dynamic shift left $dynamicShiftValue of $value should " +
121
- s " be ${expectedValue(value, left = true , dynamicShiftValue)}" )
122
- expect(c.io.dynamicShiftRightResult, expectedValue(value, left = false , dynamicShiftValue),
123
- s " dynamic shift right $dynamicShiftValue of $value should " +
124
- s " be ${expectedValue(value, left = false , dynamicShiftValue)}" )
119
+
120
+ for (dynamicShiftValue <- 0 until c.width) {
121
+ poke(c.io.dynamicShiftValue, dynamicShiftValue)
122
+ step(1 )
123
+ expect(c.io.dynamicShiftLeftResult, expectedValue(value, left = true , dynamicShiftValue),
124
+ s " dynamic shift left $dynamicShiftValue of $value should " +
125
+ s " be ${expectedValue(value, left = true , dynamicShiftValue)}" )
126
+ expect(c.io.dynamicShiftRightResult, expectedValue(value, left = false , dynamicShiftValue),
127
+ s " dynamic shift right $dynamicShiftValue of $value should " +
128
+ s " be ${expectedValue(value, left = false , dynamicShiftValue)}" )
129
+ }
125
130
}
131
+
126
132
}
127
133
}
128
134
@@ -138,10 +144,12 @@ class BrokenShifter(n: Int) extends Module {
138
144
}
139
145
140
146
class BrokenShifterTester (c : BrokenShifter ) extends DspTester (c) {
141
- poke(c.io.i, 1.5 )
142
- peek(c.io.o)
143
- poke(c.io.si, 6 )
144
- peek(c.io.so)
147
+ updatableDspVerbose.withValue(false ) {
148
+ poke(c.io.i, 1.5 )
149
+ peek(c.io.o)
150
+ poke(c.io.si, 6 )
151
+ peek(c.io.so)
152
+ }
145
153
}
146
154
147
155
class FixedPointSpec extends FreeSpec with Matchers {
0 commit comments