8ee79b0c03fc2e0ff216c3636835d77c428488d6
1 """Wishbone read/write utility routines
5 def wb_write(bus
, addr
, data
, sel
=True):
11 yield bus
.sel
.eq(0b1111 if sel
else 0b1) # 32-bit / 8-bit
12 yield bus
.adr
.eq(addr
)
13 yield bus
.dat_w
.eq(data
)
15 # wait for ack to go high
21 yield # loop until ack
22 yield bus
.stb
.eq(0) # drop stb so only 1 thing into pipeline
24 # leave cyc/stb valid for 1 cycle while writing
27 # clear out before returning data
36 def wb_read(bus
, addr
, sel
=True):
42 yield bus
.sel
.eq(0b1111 if sel
else 0b1) # 32-bit / 8-bit
43 yield bus
.adr
.eq(addr
)
45 # wait for ack to go high
51 yield # loop until ack
52 yield bus
.stb
.eq(0) # drop stb so only 1 thing into pipeline
54 # get data on same cycle that ack raises
55 data
= yield bus
.dat_r
57 # leave cyc/stb valid for 1 cycle while reading
60 # clear out before returning data