litex/migen/bus/wishbone2csr.py

28 lines
730 B
Python
Raw Normal View History

from migen.fhdl.std import *
2011-12-16 10:02:55 -05:00
from migen.bus import wishbone
from migen.bus import csr
2013-02-22 17:19:37 -05:00
from migen.genlib.misc import timeline
2011-12-11 09:04:34 -05:00
class WB2CSR(Module):
2013-07-28 10:33:36 -04:00
def __init__(self, bus_wishbone=None, bus_csr=None):
if bus_wishbone is None:
bus_wishbone = wishbone.Interface()
self.wishbone = bus_wishbone
if bus_csr is None:
bus_csr = csr.Interface()
self.csr = bus_csr
2011-12-11 09:04:34 -05:00
###
self.sync += [
self.csr.we.eq(0),
2013-07-28 10:33:36 -04:00
self.csr.dat_w.eq(self.wishbone.dat_w),
self.csr.adr.eq(self.wishbone.adr),
self.wishbone.dat_r.eq(self.csr.dat_r)
2011-12-11 09:04:34 -05:00
]
self.sync += timeline(self.wishbone.cyc & self.wishbone.stb, [
(1, [self.csr.we.eq(self.wishbone.we)]),
(2, [self.wishbone.ack.eq(1)]),
(3, [self.wishbone.ack.eq(0)])
])