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/GCD.scala | |
| parent | b208bfb5691c7b5921dd47d0b599726872acd1cd (diff) | |
Incorporate chisel3-tests; update Makefile.
Diffstat (limited to 'src/test/scala/ChiselTests/GCD.scala')
| -rw-r--r-- | src/test/scala/ChiselTests/GCD.scala | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/test/scala/ChiselTests/GCD.scala b/src/test/scala/ChiselTests/GCD.scala new file mode 100644 index 00000000..2702aaec --- /dev/null +++ b/src/test/scala/ChiselTests/GCD.scala @@ -0,0 +1,31 @@ +package ChiselTests +import Chisel._ + +class GCD extends Module { + val io = new Bundle { + val a = Bits(INPUT, 16) + val b = Bits(INPUT, 16) + val e = Bool(INPUT) + val z = Bits(OUTPUT, 16) + val v = Bool(OUTPUT) + } + val x = Reg(Bits(width = 16)) + val y = Reg(Bits(width = 16)) + when (x > y) { x := x -% y } + .otherwise { y := y -% x } + when (io.e) { x := io.a; y := io.b } + io.z := x + io.v := y === Bits(0) +} + +class GCDTester(c: GCD) extends Tester(c) { + val (a, b, z) = (64, 48, 16) + do { + val first = if (t == 0) 1 else 0; + poke(c.io.a, a) + poke(c.io.b, b) + poke(c.io.e, first) + step(1) + } while (t <= 1 || peek(c.io.v) == 0) + expect(c.io.z, z) +} |
