diff options
| author | Aditya Naik | 2023-11-23 03:11:56 -0800 |
|---|---|---|
| committer | Aditya Naik | 2023-11-23 03:11:56 -0800 |
| commit | af415532cf160e63e971ceb301833b8433c18a50 (patch) | |
| tree | 1fef70139846f57298c8e24a590490a74249f7dd /src/test/scala/chiselTests/GCD.scala | |
| parent | 8200c0cdf1d471453946d5ae24bc99757b2ef02d (diff) | |
cleanup
Diffstat (limited to 'src/test/scala/chiselTests/GCD.scala')
| -rw-r--r-- | src/test/scala/chiselTests/GCD.scala | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/src/test/scala/chiselTests/GCD.scala b/src/test/scala/chiselTests/GCD.scala deleted file mode 100644 index f03d4e61..00000000 --- a/src/test/scala/chiselTests/GCD.scala +++ /dev/null @@ -1,59 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 - -package chiselTests - -import chisel3._ -import chisel3.stage.ChiselStage -import chisel3.testers.BasicTester - -class GCD extends Module { - val io = IO(new Bundle { - val a = Input(UInt(32.W)) - val b = Input(UInt(32.W)) - val e = Input(Bool()) - val z = Output(UInt(32.W)) - val v = Output(Bool()) - }) - val x = Reg(UInt(32.W)) - val y = Reg(UInt(32.W)) - 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 === 0.U -} - -class GCDTester(a: Int, b: Int, z: Int) extends BasicTester { - val dut = Module(new GCD) - val first = RegInit(true.B) - dut.io.a := a.U - dut.io.b := b.U - dut.io.e := first - when(first) { first := false.B } - when(!first && dut.io.v) { - assert(dut.io.z === z.U) - stop() - } -} - -class GCDSpec extends ChiselPropSpec { - - //TODO: use generators and this function to make z's - def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b) - - val gcds = Table( - ("a", "b", "z"), // First tuple defines column names - (64, 48, 16), // Subsequent tuples define the data - (12, 9, 3), - (48, 64, 16) - ) - - property("GCD should elaborate") { - ChiselStage.elaborate { new GCD } - } - - property("GCDTester should return the correct result") { - forAll(gcds) { (a: Int, b: Int, z: Int) => - assertTesterPasses { new GCDTester(a, b, z) } - } - } -} |
