summaryrefslogtreecommitdiff
path: root/src/test/scala/chiselTests/GCD.scala
diff options
context:
space:
mode:
authorJack Koenig2022-01-10 10:39:52 -0800
committerJack Koenig2022-01-10 15:53:55 -0800
commit3131c0daad41dea78bede4517669e376c41a325a (patch)
tree55baed78a6a01f80ff3952a08233ca553a19964f /src/test/scala/chiselTests/GCD.scala
parentdd36f97a82746cec0b25b94651581fe799e24579 (diff)
Apply scalafmt
Command: sbt scalafmtAll
Diffstat (limited to 'src/test/scala/chiselTests/GCD.scala')
-rw-r--r--src/test/scala/chiselTests/GCD.scala30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/test/scala/chiselTests/GCD.scala b/src/test/scala/chiselTests/GCD.scala
index 1e40c6f4..f03d4e61 100644
--- a/src/test/scala/chiselTests/GCD.scala
+++ b/src/test/scala/chiselTests/GCD.scala
@@ -8,17 +8,16 @@ 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 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 }
+ 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
}
@@ -39,21 +38,22 @@ class GCDTester(a: Int, b: Int, z: Int) extends BasicTester {
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)
+ 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))
+ ("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) }
+ forAll(gcds) { (a: Int, b: Int, z: Int) =>
+ assertTesterPasses { new GCDTester(a, b, z) }
}
}
}