summaryrefslogtreecommitdiff
path: root/src/test/scala/ChiselTests/ModuleVec.scala
diff options
context:
space:
mode:
authorJim Lawson2015-05-11 13:02:03 -0700
committerJim Lawson2015-07-24 15:50:53 -0700
commit2ae50411cbc5e2cd5fdc9ca4069b9c5f64919bc4 (patch)
treea656e44d86a68a7c53b159fe6c74d328a126126d /src/test/scala/ChiselTests/ModuleVec.scala
parentb208bfb5691c7b5921dd47d0b599726872acd1cd (diff)
Incorporate chisel3-tests; update Makefile.
Diffstat (limited to 'src/test/scala/ChiselTests/ModuleVec.scala')
-rw-r--r--src/test/scala/ChiselTests/ModuleVec.scala34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/scala/ChiselTests/ModuleVec.scala b/src/test/scala/ChiselTests/ModuleVec.scala
new file mode 100644
index 00000000..9d76760d
--- /dev/null
+++ b/src/test/scala/ChiselTests/ModuleVec.scala
@@ -0,0 +1,34 @@
+package ChiselTests
+import Chisel._
+
+class PlusOne extends Module {
+ val io = new Bundle {
+ val in = UInt(INPUT, 32)
+ val out = UInt(OUTPUT, 32)
+ }
+ io.out := io.in + UInt(1)
+}
+
+class ModuleVec(val n: Int) extends Module {
+ val io = new Bundle {
+ val ins = Vec(UInt(INPUT, 32), n)
+ val outs = Vec(UInt(OUTPUT, 32), n)
+ }
+ val pluses = Vec.fill(n){ Module(new PlusOne).io }
+ for (i <- 0 until n) {
+ pluses(i).in := io.ins(i)
+ io.outs(i) := pluses(i).out
+ }
+}
+
+
+class ModuleVecTester(c: ModuleVec) extends Tester(c) {
+ for (t <- 0 until 16) {
+ val test_ins = Array.fill(c.n){ rnd.nextInt(256) }
+ for (i <- 0 until c.n)
+ poke(c.io.ins(i), test_ins(i))
+ step(1)
+ for (i <- 0 until c.n)
+ expect(c.io.outs(i), test_ins(i) + 1)
+ }
+}