-
Notifications
You must be signed in to change notification settings - Fork 0
/
PixelReg.scala
40 lines (32 loc) · 927 Bytes
/
PixelReg.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
package Core
import Chisel._
class PixelReg(data_width: Int) extends Module {
val io = new Bundle {
val data_in = UInt(INPUT, data_width)
val enable_in = Bool(INPUT)
val data_out = UInt(OUTPUT, data_width)
val enable_out = Bool(OUTPUT)
}
val data = Reg(init=UInt(0, width = data_width))
val enable = Reg(init=Bool(false))
val read_switch = Reg(init=Bool(false))
// Wire read enable
io.enable_out := enable
enable := io.enable_in
io.data_out := data
when (enable){
data := io.data_in
}
}
class PixelRegTest(c: PixelReg, data_width: Int) extends Tester(c) {
println("PixelRegTest")
for(i <- 0 until 20){
step(1)
poke(c.io.data_in, i)
peek(c.io.data_out)
peek(c.io.enable_out)
if(i%9 == 0){
poke(c.io.enable_in, true)
}else{poke(c.io.enable_in,false)}
}
}