blob: db569233196cbb836a170609d433770072da7f87 (
plain)
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
|
// See LICENSE for license details.
package chiselTests
import chisel3._
import chisel3.testers.BasicTester
class EnableShiftRegister extends Module {
val io = IO(new Bundle {
val in = Input(UInt(4.W))
val shift = Input(Bool())
val out = Output(UInt(4.W))
})
val r0 = RegInit(0.U(4.W))
val r1 = RegInit(0.U(4.W))
val r2 = RegInit(0.U(4.W))
val r3 = RegInit(0.U(4.W))
when(io.shift) {
r0 := io.in
r1 := r0
r2 := r1
r3 := r2
}
io.out := r3
}
// scalastyle:off regex
/*
class EnableShiftRegisterTester(c: EnableShiftRegister) extends Tester(c) {
val reg = Array.fill(4){ 0 }
for (t <- 0 until 16) {
val in = rnd.nextInt(16)
val shift = rnd.nextInt(2)
println("SHIFT " + shift + " IN " + in) // scalastyle:ignore regex
poke(c.io.in, in)
poke(c.io.shift, shift)
step(1)
if (shift == 1) {
for (i <- 3 to 1 by -1)
reg(i) = reg(i-1)
reg(0) = in
}
expect(c.io.out, reg(3))
}
}
*/
// scalastyle:on regex
class EnableShiftRegisterSpec extends ChiselPropSpec {
property("EnableShiftRegister should elaborate") {
elaborate { new EnableShiftRegister }
}
ignore("EnableShiftRegisterTester should return the correct result") { }
}
|