-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemoryTest.scala
More file actions
91 lines (69 loc) · 2.22 KB
/
MemoryTest.scala
File metadata and controls
91 lines (69 loc) · 2.22 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
package chiselexamples
package memory
import chisel3._
import chiseltest._
import chiseltest.iotesters.PeekPokeTester
import org.scalatest.flatspec.AnyFlatSpec
import treadle2.MemoryToVCD
class MemoryTester(c: Memory, packetToSend: Int = 1) extends PeekPokeTester(c) {
// Write some data to the memory
var i = 0
var readAddr = 0
var writeAddr = 0
// Simply read and write some data
for (data <- 0 until c.n) {
readAddr = i % c.n
writeAddr = (i + 1) % c.n
// Write the data
poke(c.io.writeEn, true.B)
poke(c.io.addrIn, writeAddr.U)
poke(c.io.dataIn, data.U)
step(1)
// Read the data
poke(c.io.writeEn, false.B)
poke(c.io.addrIn, readAddr.U)
step(1)
i += 1
}
}
class MemoryWaveformTest extends AnyFlatSpec with ChiselScalatestTester {
behavior of "MemoryWaveformTest"
val packetToSend = 10
val n = 16
val width = 32
it should "dump Treadle VCD" in {
test(new Memory(n, width))
.withAnnotations(Seq(WriteVcdAnnotation, TreadleBackendAnnotation))
.runPeekPoke(new MemoryTester(_))
}
it should "dump Treadle VCD with MemoryToVCD" in {
test(new Memory(n, width))
.withAnnotations(Seq(MemoryToVCD("mem:all"), WriteVcdAnnotation, TreadleBackendAnnotation))
.runPeekPoke(new MemoryTester(_))
}
it should "dump Verilator VCD" in {
test(new Memory(n, width))
.withAnnotations(Seq(WriteVcdAnnotation, VerilatorBackendAnnotation))
.runPeekPoke(new MemoryTester(_))
}
it should "dump Icarus VCD" in {
test(new Memory(n, width))
.withAnnotations(Seq(WriteVcdAnnotation, IcarusBackendAnnotation))
.runPeekPoke(new MemoryTester(_))
}
it should "dump Verilator FST" in {
test(new Memory(n, width))
.withAnnotations(Seq(WriteFstAnnotation, VerilatorBackendAnnotation))
.runPeekPoke(new MemoryTester(_))
}
it should "dump Icarus FST" in {
test(new Memory(n, width))
.withAnnotations(Seq(WriteFstAnnotation, IcarusBackendAnnotation))
.runPeekPoke(new MemoryTester(_))
}
it should "dump Icarus LXT" in {
test(new Memory(n, width))
.withAnnotations(Seq(new WriteLxtAnnotation, IcarusBackendAnnotation))
.runPeekPoke(new MemoryTester(_))
}
}