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/BitsOps.scala | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/test/scala/ChiselTests/BitsOps.scala (limited to 'src/test/scala/ChiselTests/BitsOps.scala') diff --git a/src/test/scala/ChiselTests/BitsOps.scala b/src/test/scala/ChiselTests/BitsOps.scala new file mode 100644 index 00000000..bfcbaf49 --- /dev/null +++ b/src/test/scala/ChiselTests/BitsOps.scala @@ -0,0 +1,33 @@ +package ChiselTests +import Chisel._ + +class BitsOps extends Module { + val io = new Bundle { + val a = Bits(INPUT, 16) + val b = Bits(INPUT, 16) + val notout = Bits(OUTPUT, 16) + val andout = Bits(OUTPUT, 16) + val orout = Bits(OUTPUT, 16) + val xorout = Bits(OUTPUT, 16) + } + + io.notout := ~io.a + io.andout := io.a & io.b + io.orout := io.a | io.b + io.xorout := io.a ^ io.b +} + +class BitsOpsTester(c: BitsOps) extends Tester(c) { + val mask = (1 << 16)-1; + for (t <- 0 until 16) { + val test_a = rnd.nextInt(1 << 16) + val test_b = rnd.nextInt(1 << 16) + poke(c.io.a, test_a) + poke(c.io.b, test_b) + step(1) + expect(c.io.notout, mask & (~test_a)) + expect(c.io.andout, mask & (test_a & test_b)) + expect(c.io.orout, mask & (test_a | test_b)) + expect(c.io.xorout, mask & (test_a ^ test_b)) + } +} -- cgit v1.2.3