summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Lawson2017-03-13 11:39:21 -1000
committerRichard Lin2017-03-13 14:39:21 -0700
commita6798adbf7567cf105f8190ebd293a4cfb3aeb11 (patch)
tree0a66072a06f9ba5bf4ccd56c6d0b6db28b53152d /src
parenta290d77ef3e88b200ab61cd41fcd1a1138321b66 (diff)
Revert "Change Vec creation to check if gen is lit (and hence needs t… (#530)
* Revert "Change Vec creation to check if gen is lit (and hence needs to be declared)" This reverts commit dc86e7e1734d6abacb739b488df1de231e6b41b2. This may address #522 - using chiselCloneType (instead of cloneType) to preserve directionality. * Add missing implicits to Vec.apply() signature. * Use correct macro (CompileOptionsTransform) for indexWhere.
Diffstat (limited to 'src')
-rw-r--r--src/test/scala/chiselTests/Vec.scala23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/test/scala/chiselTests/Vec.scala b/src/test/scala/chiselTests/Vec.scala
index c9320a96..d7c2c648 100644
--- a/src/test/scala/chiselTests/Vec.scala
+++ b/src/test/scala/chiselTests/Vec.scala
@@ -12,7 +12,7 @@ class LitTesterMod(vecSize: Int) extends Module {
val io = IO(new Bundle {
val out = Output(Vec(vecSize, UInt()))
})
- io.out := Vec(vecSize, 0.U)
+ io.out := Vec(Seq.fill(vecSize){0.U})
}
class RegTesterMod(vecSize: Int) extends Module {
@@ -20,7 +20,7 @@ class RegTesterMod(vecSize: Int) extends Module {
val in = Input(Vec(vecSize, UInt()))
val out = Output(Vec(vecSize, UInt()))
})
- val vecReg = RegNext(io.in, Vec(vecSize, 0.U))
+ val vecReg = RegNext(io.in, Vec(Seq.fill(vecSize){0.U}))
io.out := vecReg
}
@@ -32,6 +32,15 @@ class IOTesterMod(vecSize: Int) extends Module {
io.out := io.in
}
+class OneBitUnitRegVec extends Module {
+ val io = IO(new Bundle {
+ val out = Output(UInt(1.W))
+ })
+ val oneBitUnitRegVec = Reg(Vec(1, 1.U))
+ oneBitUnitRegVec(0) := 1.U(1.W)
+ io.out := oneBitUnitRegVec(0)
+}
+
class LitTester(w: Int, values: List[Int]) extends BasicTester {
val dut = Module(new LitTesterMod(values.length))
for (a <- dut.io.out)
@@ -119,6 +128,12 @@ class HugeVecTester(n: Int) extends BasicTester {
stop()
}
+class OneBitUnitRegVecTester extends BasicTester {
+ val dut = Module(new OneBitUnitRegVec)
+ assert(dut.io.out === 1.U)
+ stop()
+}
+
class VecSpec extends ChiselPropSpec {
// Disable shrinking on error.
implicit val noShrinkListVal = Shrink[List[Int]](_ => Stream.empty)
@@ -168,4 +183,8 @@ class VecSpec extends ChiselPropSpec {
property("Infering widths on huge Vecs should not cause a stack overflow") {
assertTesterPasses { new HugeVecTester(10000) }
}
+
+ property("A Reg of a Vec of a single 1 bit element should compile and work") {
+ assertTesterPasses{ new OneBitUnitRegVecTester }
+ }
}