litex/migen/bus/wishbone2csr.py

23 lines
701 B
Python
Raw Normal View History

2011-12-16 10:02:55 -05:00
from migen.bus import wishbone
from migen.bus import csr
2011-12-16 15:30:14 -05:00
from migen.fhdl.structure import *
2011-12-11 09:04:34 -05:00
from migen.corelogic import timeline
class Inst():
def __init__(self):
self.wishbone = wishbone.Slave("to_csr")
self.csr = csr.Master("from_wishbone")
self.timeline = timeline.Inst(self.wishbone.cyc_i & self.wishbone.stb_i,
2011-12-16 15:30:14 -05:00
[(1, [self.csr.we_o.eq(self.wishbone.we_i)]),
(2, [self.wishbone.ack_o.eq(1)]),
(3, [self.wishbone.ack_o.eq(0)])])
2011-12-11 09:04:34 -05:00
2011-12-16 10:02:55 -05:00
def get_fragment(self):
2011-12-11 09:04:34 -05:00
sync = [
2011-12-16 15:30:14 -05:00
self.csr.we_o.eq(0),
self.csr.d_o.eq(self.wishbone.dat_i),
2012-01-13 11:29:05 -05:00
self.csr.a_o.eq(self.wishbone.adr_i[:14]),
2011-12-16 15:30:14 -05:00
self.wishbone.dat_o.eq(self.csr.d_i)
2011-12-11 09:04:34 -05:00
]
2011-12-16 15:30:14 -05:00
return Fragment(sync=sync) + self.timeline.get_fragment()