-
Notifications
You must be signed in to change notification settings - Fork 0
/
DemoTest.scala
57 lines (53 loc) · 1.59 KB
/
DemoTest.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import chisel3._
import chiseltest._
import chiseltest.simulator.VerilatorFlags
import firrtl2.annotations.NoTargetAnnotation
import utest._
class addWithBlackBox(val wA: Int = 4) extends Module {
require(wA >= 1, "wA must be >= 1")
val io = IO(new Bundle {
val A: UInt = Input(UInt(wA.W))
val B: UInt = Input(UInt(wA.W))
val CI: UInt = Input(UInt(1.W))
val Z: UInt = Output(UInt(wA.W))
val CO: UInt = Output(UInt(1.W))
})
protected val U1: CW_add = Module(new CW_add(wA))
U1.io.A := io.A
U1.io.B := io.B
U1.io.CI := io.CI
io.Z := U1.io.Z
io.CO := U1.io.CO
def addPath(blackBoxFileSeq: Seq[String]): Unit = {
blackBoxFileSeq.foreach(blackBoxPath => U1.addPath(blackBoxPath))
}
}
object addWithBlackBox {
def simWithBBoxVerilog(blackBoxFileSeq: Seq[String]): addWithBlackBox = {
val addWithBlackBox = new addWithBlackBox
addWithBlackBox.addPath(blackBoxFileSeq)
addWithBlackBox
}
}
object DemoTest extends TestSuite with ChiselUtestTester {
val bboxFileSeq: Seq[String] = Seq(
"chipware/test/resources/CW_add_demo.v"
)
val annotationSeq: Seq[NoTargetAnnotation] = Seq(
WriteVcdAnnotation,
VerilatorBackendAnnotation,
// Disable all lint warnings
VerilatorFlags(Seq("-Wno-lint"))
)
val tests: Tests = Tests {
test("add should work with blackbox") {
testCircuit(addWithBlackBox.simWithBBoxVerilog(bboxFileSeq), annotationSeq = annotationSeq) { dut =>
dut.io.A.poke(1.U)
dut.io.B.poke(2.U)
dut.io.CI.poke(0.U)
dut.io.Z.expect(3.U)
dut.io.CO.expect(0.U)
}
}
}
}