diff options
| author | Henry Cook | 2015-08-13 15:47:02 -0700 |
|---|---|---|
| committer | Henry Cook | 2015-08-13 15:51:53 -0700 |
| commit | ad96b03f84d0182f5e74f11117331d69752ea0a0 (patch) | |
| tree | 0d4ed1e56c054fe0ac7d2ef8739fb28c18be2b76 /src/test/scala/chiselTests/BundleWire.scala | |
| parent | ed69bdea87f7f60cc6b3bac7b6cdd7b6bc787f1d (diff) | |
testing improvements
Diffstat (limited to 'src/test/scala/chiselTests/BundleWire.scala')
| -rw-r--r-- | src/test/scala/chiselTests/BundleWire.scala | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/BundleWire.scala b/src/test/scala/chiselTests/BundleWire.scala new file mode 100644 index 00000000..99455608 --- /dev/null +++ b/src/test/scala/chiselTests/BundleWire.scala @@ -0,0 +1,39 @@ +package chiselTests +import Chisel._ +import org.scalatest._ +import org.scalatest.prop._ +import Chisel.testers.BasicTester + +class Coord extends Bundle { + val x = UInt(width = 32) + val y = UInt(width = 32) +} + +class BundleWire(n: Int) extends Module { + val io = new Bundle { + val in = (new Coord).asInput + val outs = Vec(new Coord, n).asOutput + } + val coords = Wire(Vec(new Coord, n)) + for (i <- 0 until n) { + coords(i) := io.in + io.outs(i) := coords(i) + } +} + +class BundleWireSpec extends ChiselPropSpec { + + class BundleWireTester(n: Int, x: Int, y: Int) extends BasicTester { + val dut = Module(new BundleWire(n)) + io.done := Bool(true) + dut.io.in.x := UInt(x) + dut.io.in.y := UInt(y) + io.error := dut.io.outs.map(o => o.x != UInt(x) || o.y != UInt(y)).foldLeft(UInt(0))(_##_) + } + + property("All vec elems should match the inputs") { + forAll(vecSizes, safeUInts, safeUInts) { (n: Int, x: Int, y: Int) => + assert(execute{ new BundleWireTester(n, x, y) }) + } + } +} |
