forked from M-Labs/artiq
rtio/phy: add wishbone adapter
This commit is contained in:
parent
c1f9fc2ae4
commit
30dffb6644
42
artiq/gateware/rtio/phy/wishbone.py
Normal file
42
artiq/gateware/rtio/phy/wishbone.py
Normal file
@ -0,0 +1,42 @@
|
||||
from migen.fhdl.std import *
|
||||
|
||||
from artiq.gateware.rtio import rtlink
|
||||
|
||||
|
||||
class RT2WB(Module):
|
||||
def __init__(self, wb, address_width, o_latency=0, i_latency=0):
|
||||
self.rtlink = rtlink.Interface(
|
||||
rtlink.OInterface(
|
||||
flen(wb.dat_w),
|
||||
address_width + 1,
|
||||
latency=o_latency,
|
||||
suppress_nop=False),
|
||||
rtlink.IInterface(
|
||||
flen(wb.dat_r),
|
||||
timestamped=False,
|
||||
latency=i_latency)
|
||||
)
|
||||
|
||||
# # #
|
||||
|
||||
active = Signal()
|
||||
self.sync.rio += [
|
||||
If(self.rtlink.o.stb,
|
||||
active.eq(1),
|
||||
wb.adr.eq(self.rtlink.o.address[:address_width]),
|
||||
wb.we.eq(~self.rtlink.o.address[address_width]),
|
||||
wb.dat_w.eq(self.rtlink.o.data),
|
||||
wb.sel.eq(2**flen(wb.sel) - 1)
|
||||
),
|
||||
If(wb.ack,
|
||||
active.eq(0)
|
||||
)
|
||||
]
|
||||
self.comb += [
|
||||
self.rtlink.o.busy.eq(active),
|
||||
wb.cyc.eq(active),
|
||||
wb.stb.eq(active),
|
||||
|
||||
self.i.stb.eq(wb.ack & ~wb.we),
|
||||
self.i.data.eq(wb.dat_r)
|
||||
]
|
Loading…
Reference in New Issue
Block a user