2013-05-22 11:11:09 -04:00
|
|
|
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
|
|
|
|
2013-05-22 11:11:09 -04:00
|
|
|
class WB2CSR(Module):
|
2011-12-11 09:04:34 -05:00
|
|
|
def __init__(self):
|
2012-02-15 10:30:16 -05:00
|
|
|
self.wishbone = wishbone.Interface()
|
|
|
|
self.csr = csr.Interface()
|
2011-12-11 09:04:34 -05:00
|
|
|
|
2013-05-22 11:11:09 -04:00
|
|
|
###
|
|
|
|
|
|
|
|
self.sync += [
|
2012-02-15 10:30:16 -05:00
|
|
|
self.csr.we.eq(0),
|
2012-08-26 15:19:34 -04:00
|
|
|
self.csr.dat_w.eq(self.wishbone.dat_w[:csr.data_width]),
|
2012-02-15 10:30:16 -05:00
|
|
|
self.csr.adr.eq(self.wishbone.adr[:14]),
|
|
|
|
self.wishbone.dat_r.eq(self.csr.dat_r)
|
2011-12-11 09:04:34 -05:00
|
|
|
]
|
2013-05-22 11:11:09 -04:00
|
|
|
self.sync += timeline(self.wishbone.cyc & self.wishbone.stb, [
|
2012-03-15 15:25:44 -04:00
|
|
|
(1, [self.csr.we.eq(self.wishbone.we)]),
|
|
|
|
(2, [self.wishbone.ack.eq(1)]),
|
|
|
|
(3, [self.wishbone.ack.eq(0)])
|
|
|
|
])
|