litex/milkymist/norflash/__init__.py

33 lines
1.0 KiB
Python
Raw Normal View History

2011-12-16 10:02:49 -05:00
from functools import partial
2011-12-13 11:33:12 -05:00
from migen.fhdl import structure as f
from migen.bus import wishbone
from migen.corelogic import timeline
class Inst:
def __init__(self, adr_width, rd_timing):
self.bus = wishbone.Slave("norflash")
2011-12-16 10:02:49 -05:00
d = partial(f.declare_signal, self)
2011-12-13 11:33:12 -05:00
d("adr", f.BV(adr_width-1))
d("d", f.BV(16))
d("oe_n")
d("we_n")
d("ce_n")
d("rst_n")
self.timeline = timeline.Inst(self.bus.cyc_i & self.bus.stb_i,
[(0, [f.Assign(self.adr, f.Cat(0, self.bus.adr_i[2:adr_width]))]),
(rd_timing, [
f.Assign(self.bus.dat_o[16:], self.d),
f.Assign(self.adr, f.Cat(1, self.bus.adr_i[2:adr_width]))]),
(2*rd_timing, [
f.Assign(self.bus.dat_o[:16], self.d),
f.Assign(self.bus.ack_o, 1)]),
(2*rd_timing+1, [
f.Assign(self.bus.ack_o, 0)])])
2011-12-16 10:02:49 -05:00
def get_fragment(self):
2011-12-13 11:33:12 -05:00
comb = [f.Assign(self.oe_n, 0), f.Assign(self.we_n, 1),
f.Assign(self.ce_n, 0), f.Assign(self.rst_n, 1)]
return f.Fragment(comb, pads={self.adr, self.d, self.oe_n, self.we_n, self.ce_n, self.rst_n}) \
2011-12-16 10:02:49 -05:00
+ self.timeline.get_fragment()