diff options
| author | Jim Lawson | 2015-05-11 13:02:03 -0700 |
|---|---|---|
| committer | Jim Lawson | 2015-07-24 15:50:53 -0700 |
| commit | 2ae50411cbc5e2cd5fdc9ca4069b9c5f64919bc4 (patch) | |
| tree | a656e44d86a68a7c53b159fe6c74d328a126126d /src/test/scala/ChiselTests/Mul.scala | |
| parent | b208bfb5691c7b5921dd47d0b599726872acd1cd (diff) | |
Incorporate chisel3-tests; update Makefile.
Diffstat (limited to 'src/test/scala/ChiselTests/Mul.scala')
| -rw-r--r-- | src/test/scala/ChiselTests/Mul.scala | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/scala/ChiselTests/Mul.scala b/src/test/scala/ChiselTests/Mul.scala new file mode 100644 index 00000000..9f7c604c --- /dev/null +++ b/src/test/scala/ChiselTests/Mul.scala @@ -0,0 +1,34 @@ +package ChiselTests +import Chisel._ +import scala.collection.mutable.ArrayBuffer + +class Mul(val w: Int) extends Module { + val io = new Bundle { + val x = UInt(INPUT, w) + val y = UInt(INPUT, w) + val z = UInt(OUTPUT, 2 * w) + } + val muls = new ArrayBuffer[UInt]() + + val n = 1 << w + + for (i <- 0 until n) + for (j <- 0 until n) + muls += UInt(i * j, 2 * w) + val tbl = Vec(muls) + // val ad = (io.x << w) | io.y + io.z := tbl(((io.x << w) | io.y).toUInt) +} + + +class MulTester(c: Mul) extends Tester(c) { + val maxInt = 1 << c.w + for (i <- 0 until 10) { + val x = rnd.nextInt(maxInt) + val y = rnd.nextInt(maxInt) + poke(c.io.x, x) + poke(c.io.y, y) + step(1) + expect(c.io.z, (x * y)) + } +} |
