2013-05-22 11:10:13 -04:00
|
|
|
from migen.fhdl.std import *
|
2011-12-13 11:33:12 -05:00
|
|
|
from migen.bus import wishbone
|
2013-02-24 06:31:00 -05:00
|
|
|
from migen.genlib.misc import timeline
|
2011-12-13 11:33:12 -05:00
|
|
|
|
2013-03-10 14:32:38 -04:00
|
|
|
class NorFlash(Module):
|
2013-03-26 12:57:17 -04:00
|
|
|
def __init__(self, pads, rd_timing):
|
2012-02-15 10:55:13 -05:00
|
|
|
self.bus = wishbone.Interface()
|
2011-12-13 11:33:12 -05:00
|
|
|
|
2013-03-10 14:32:38 -04:00
|
|
|
###
|
2013-03-26 12:57:17 -04:00
|
|
|
|
2013-05-22 11:10:13 -04:00
|
|
|
adr_width = flen(pads.adr) + 1
|
2013-03-26 12:57:17 -04:00
|
|
|
self.comb += [pads.oe_n.eq(0), pads.we_n.eq(1),
|
|
|
|
pads.ce_n.eq(0)]
|
2013-03-10 14:32:38 -04:00
|
|
|
self.sync += timeline(self.bus.cyc & self.bus.stb, [
|
2013-03-26 12:57:17 -04:00
|
|
|
(0, [pads.adr.eq(Cat(0, self.bus.adr[:adr_width-2]))]),
|
2013-03-10 14:32:38 -04:00
|
|
|
(rd_timing, [
|
2013-03-26 12:57:17 -04:00
|
|
|
self.bus.dat_r[16:].eq(pads.d),
|
|
|
|
pads.adr.eq(Cat(1, self.bus.adr[:adr_width-2]))]),
|
2013-03-10 14:32:38 -04:00
|
|
|
(2*rd_timing, [
|
2013-03-26 12:57:17 -04:00
|
|
|
self.bus.dat_r[:16].eq(pads.d),
|
2012-03-15 15:26:04 -04:00
|
|
|
self.bus.ack.eq(1)]),
|
2013-03-10 14:32:38 -04:00
|
|
|
(2*rd_timing + 1, [
|
2012-03-15 15:26:04 -04:00
|
|
|
self.bus.ack.eq(0)])
|
|
|
|
])
|