From 2ae50411cbc5e2cd5fdc9ca4069b9c5f64919bc4 Mon Sep 17 00:00:00 2001 From: Jim Lawson Date: Mon, 11 May 2015 13:02:03 -0700 Subject: Incorporate chisel3-tests; update Makefile. --- src/test/scala/ChiselTests/GCD.scala | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/test/scala/ChiselTests/GCD.scala (limited to 'src/test/scala/ChiselTests/GCD.scala') 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) +} -- cgit v1.2.3