-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParityTest.scala
More file actions
91 lines (70 loc) · 2.45 KB
/
ParityTest.scala
File metadata and controls
91 lines (70 loc) · 2.45 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package chiselexamples
package showenum
import chisel3._
import chisel3.stage.PrintFullStackTraceAnnotation
import chiseltest._
import chiseltest.iotesters.PeekPokeTester
import org.scalatest.flatspec.AnyFlatSpec
class ParityTester(c: Parity) extends PeekPokeTester(c) {
val inputs = Seq(0, 1, 1, 0, 1, 1, 0, 1, 1, 1)
// val expected = Seq(0, 0, 0, 0, 0, 1, 0, 0, 1, 0)
for (i <- inputs) {
poke(c.io.in, i.U)
step(1)
System.out.println(s"======> In: ${inputs(i)}, out: ${peek(c.io.out)}")
}
}
class ParityWrapper extends Parity {
val stateExposed = IO(Output(UInt(2.W)))
stateExposed := state
}
class ParityTest extends AnyFlatSpec with ChiselScalatestTester {
behavior of "Parity: with Enum (list of UInts)"
it should "" in {
test(new ParityWrapper())
.withAnnotations(Seq(WriteVcdAnnotation,
treadle2.VerboseAnnotation)) {
dut =>
val inputs = Seq(0, 1, 1, 0, 1, 1, 0, 1, 1, 1)
// val expected = Seq(0, 0, 0, 0, 0, 1, 0, 0, 1, 0)
for (i <- 0 until 1) {
dut.io.in.poke(inputs(i).U)
dut.clock.step(1)
println(s"======> In: ${inputs(i)}, out: ${dut.io.out.peek()}, \tstate: ${dut.stateExposed.peek()}")
}
}
}
} // end of class FSMTest
class ParityWaveformTest extends AnyFlatSpec with ChiselScalatestTester {
behavior of "ParityWaveformTest"
it should "dump Treadle VCD" in {
test(new Parity())
.withAnnotations(Seq(WriteVcdAnnotation, TreadleBackendAnnotation))
.runPeekPoke(new ParityTester(_))
}
it should "dump Verilator VCD" in {
test(new Parity())
.withAnnotations(Seq(WriteVcdAnnotation, VerilatorBackendAnnotation))
.runPeekPoke(new ParityTester(_))
}
it should "dump Icarus VCD" in {
test(new Parity())
.withAnnotations(Seq(WriteVcdAnnotation, IcarusBackendAnnotation))
.runPeekPoke(new ParityTester(_))
}
it should "dump Verilator FST" in {
test(new Parity())
.withAnnotations(Seq(WriteFstAnnotation, VerilatorBackendAnnotation))
.runPeekPoke(new ParityTester(_))
}
it should "dump Icarus FST" in {
test(new Parity())
.withAnnotations(Seq(WriteFstAnnotation, IcarusBackendAnnotation))
.runPeekPoke(new ParityTester(_))
}
it should "dump Icarus LXT" in {
test(new Parity())
.withAnnotations(Seq(new WriteLxtAnnotation, IcarusBackendAnnotation))
.runPeekPoke(new ParityTester(_))
}
} // end of class ParityWaveformTest