summaryrefslogtreecommitdiff
path: root/src/test/scala/ChiselTests/UIntOps.scala
diff options
context:
space:
mode:
authorHenry Cook2015-08-12 19:32:43 -0700
committerHenry Cook2015-08-12 19:32:57 -0700
commit85d7403f9bf7bc2b3520f924736c237f21f70ebd (patch)
tree64560f779063a419395a2fb8a31ea52c52af4404 /src/test/scala/ChiselTests/UIntOps.scala
parent7e69966362b1dbd9835695250494857f3a3767c8 (diff)
being to convert tests to scala-test; tests compile and run
Diffstat (limited to 'src/test/scala/ChiselTests/UIntOps.scala')
-rw-r--r--src/test/scala/ChiselTests/UIntOps.scala72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/test/scala/ChiselTests/UIntOps.scala b/src/test/scala/ChiselTests/UIntOps.scala
deleted file mode 100644
index 5215b454..00000000
--- a/src/test/scala/ChiselTests/UIntOps.scala
+++ /dev/null
@@ -1,72 +0,0 @@
-package ChiselTests
-import Chisel._
-import Chisel.testers._
-
-class UIntOps extends Module {
- val io = new Bundle {
- val a = UInt(INPUT, 16)
- val b = UInt(INPUT, 16)
- val addout = UInt(OUTPUT, 16)
- val subout = UInt(OUTPUT, 16)
- val timesout = UInt(OUTPUT, 16)
- val divout = UInt(OUTPUT, 16)
- val modout = UInt(OUTPUT, 16)
- val lshiftout = UInt(OUTPUT, 16)
- val rshiftout = UInt(OUTPUT, 16)
- val lessout = Bool(OUTPUT)
- val greatout = Bool(OUTPUT)
- val eqout = Bool(OUTPUT)
- val noteqout = Bool(OUTPUT)
- val lesseqout = Bool(OUTPUT)
- val greateqout = Bool(OUTPUT)
- }
-
- val a = io.a
- val b = io.b
-
- io.addout := a +% b
- io.subout := a -% b
- io.timesout := (a * b)(15, 0)
- io.divout := a / Mux(b === UInt(0), UInt(1), b)
- // io.modout := a % b
- // TODO:
- io.modout := UInt(0)
- io.lshiftout := (a << b(3, 0))(15, 0)
- io.rshiftout := a >> b
- io.lessout := a < b
- io.greatout := a > b
- io.eqout := a === b
- io.noteqout := (a != b)
- io.lesseqout := a <= b
- io.greateqout := a >= b
-}
-
-class UIntOpsTester(c: UIntOps) extends Tester(c) {
- def uintExpect(d: Bits, x: BigInt) {
- val mask = (1 << 16) - 1
- println(" E = " + x + " X&M = " + (x & mask))
- expect(d, x & mask)
- }
- for (t <- 0 until 16) {
- val test_a = rnd.nextInt(1 << 16)
- val test_b = rnd.nextInt(1 << 16)
- println("A = " + test_a + " B = " + test_b)
- poke(c.io.a, test_a)
- poke(c.io.b, test_b)
- step(1)
- uintExpect(c.io.addout, test_a + test_b)
- uintExpect(c.io.subout, test_a - test_b)
- uintExpect(c.io.divout, if (test_b == 0) 0 else test_a / test_b)
- uintExpect(c.io.timesout, test_a * test_b)
- // uintExpect(c.io.modout, test_a % test_b)
- uintExpect(c.io.lshiftout, test_a << (test_b&15))
- uintExpect(c.io.rshiftout, test_a >> test_b)
- expect(c.io.lessout, int(test_a < test_b))
- expect(c.io.greatout, int(test_a > test_b))
- expect(c.io.eqout, int(test_a == test_b))
- expect(c.io.noteqout, int(test_a != test_b))
- expect(c.io.lessout, int(test_a <= test_b))
- expect(c.io.greateqout, int(test_a >= test_b))
- }
-}
-