Skip to content

Commit

Permalink
Fuse tests. Not recommended though.
Browse files Browse the repository at this point in the history
```
ALUSpec:
- should ALL
Run completed in 2 seconds, 368 milliseconds.
```
  • Loading branch information
uenoku committed Jun 23, 2024
1 parent 514990d commit 7209bd5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 49 deletions.
3 changes: 2 additions & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ trait BaseProject extends ScalaModule with ScalafixModule with ScalafmtModule {
"UTF-8",
"-feature",
"-Xcheckinit",
"-Xfatal-warnings",
// "-Xfatal-warnings",
// "-Ywarn-unused-import",
"-Ywarn-dead-code",
"-Ywarn-unused",
"-Ymacro-annotations",
Expand Down
60 changes: 12 additions & 48 deletions chiselv/test/src/ALUSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,49 +51,11 @@ class ALUSpec extends AnyFlatSpec with should.Matchers {
Array[BigInt](1, 2, 4, 123, -1, -2, -4, 0, 0x7fffffffL, 0x80000000L, max, min_signed, max_signed) ++ Seq.fill(10)(
BigInt(scala.util.Random.nextInt())
)

it should "ADD" in {
testCycle(ADD)
}
it should "SUB" in {
testCycle(SUB)
}
it should "AND" in {
testCycle(AND)
}
it should "OR" in {
testCycle(OR)
}
it should "XOR" in {
testCycle(XOR)
}
it should "SRA" in {
testCycle(SRA)
}
it should "SRL" in {
testCycle(SRL)
}
it should "SLL" in {
testCycle(SLL)
}
it should "SLT" in {
testCycle(SLT)
}
it should "SLTU" in {
testCycle(SLTU)
}
it should "EQ" in {
testCycle(EQ)
}
it should "NEQ" in {
testCycle(NEQ)
}
it should "GT" in {
testCycle(GTE)
}
it should "GTU" in {
testCycle(GTEU)
val ops = Seq(ADD, SUB, AND, OR, XOR, SRA, SRL, SLL, SLT, SLTU, EQ, NEQ, GTE, NEQ)
it should "ALL work" in {
testCycle()
}

// --------------------- Test Helpers ---------------------
def aluHelper(
a: BigInt,
Expand Down Expand Up @@ -132,16 +94,18 @@ class ALUSpec extends AnyFlatSpec with should.Matchers {
dut.clock.step()
dut.io.ALUPort.x.peek().litValue should be(out)
}
def testCycle(
op: Type
) =
def testCycle() = {

simulate(new ALU) { c =>
cases.foreach { i =>
cases.foreach { j =>
testDut(i, j, aluHelper(i, j, op).to32Bit, op, c)
ops.foreach { op =>
cases.foreach { i =>
cases.foreach { j =>
testDut(i, j, aluHelper(i, j, op).to32Bit, op, c)
}
}
}
}
}

def toUInt(
i: BigInt
Expand Down

0 comments on commit 7209bd5

Please sign in to comment.