2015-03-01 04:01:23 -05:00
|
|
|
from migen.fhdl.std import *
|
|
|
|
from migen.genlib.fifo import AsyncFIFO
|
|
|
|
from migen.genlib.record import layout_len
|
|
|
|
from migen.bank.description import AutoCSR
|
2015-03-02 02:24:51 -05:00
|
|
|
from migen.actorlib import structuring, spi
|
2015-03-01 04:01:23 -05:00
|
|
|
|
2015-03-02 02:24:51 -05:00
|
|
|
from misoclib.mem.sdram.frontend import dma_lasmi
|
2015-03-01 04:01:23 -05:00
|
|
|
from misoclib.video.dvisampler.edid import EDID
|
|
|
|
from misoclib.video.dvisampler.clocking import Clocking
|
|
|
|
from misoclib.video.dvisampler.datacapture import DataCapture
|
|
|
|
|
2015-04-13 10:47:22 -04:00
|
|
|
|
2015-03-01 04:01:23 -05:00
|
|
|
class RawDVISampler(Module, AutoCSR):
|
2015-04-13 10:19:55 -04:00
|
|
|
def __init__(self, pads, asmiport):
|
|
|
|
self.submodules.edid = EDID(pads)
|
|
|
|
self.submodules.clocking = Clocking(pads)
|
2015-03-01 04:01:23 -05:00
|
|
|
|
2015-04-13 10:19:55 -04:00
|
|
|
invert = False
|
|
|
|
try:
|
|
|
|
s = getattr(pads, "data0")
|
|
|
|
except AttributeError:
|
|
|
|
s = getattr(pads, "data0_n")
|
|
|
|
invert = True
|
|
|
|
self.submodules.data0_cap = DataCapture(8, invert)
|
|
|
|
self.comb += [
|
|
|
|
self.data0_cap.pad.eq(s),
|
|
|
|
self.data0_cap.serdesstrobe.eq(self.clocking.serdesstrobe)
|
|
|
|
]
|
2015-03-01 04:01:23 -05:00
|
|
|
|
2015-04-13 10:19:55 -04:00
|
|
|
fifo = RenameClockDomains(AsyncFIFO(10, 256),
|
|
|
|
{"write": "pix", "read": "sys"})
|
|
|
|
self.submodules += fifo
|
|
|
|
self.comb += [
|
|
|
|
fifo.din.eq(self.data0_cap.d),
|
|
|
|
fifo.we.eq(1)
|
|
|
|
]
|
2015-03-01 04:01:23 -05:00
|
|
|
|
2015-04-13 10:19:55 -04:00
|
|
|
pack_factor = asmiport.hub.dw//16
|
|
|
|
self.submodules.packer = structuring.Pack([("word", 10), ("pad", 6)], pack_factor)
|
|
|
|
self.submodules.cast = structuring.Cast(self.packer.source.payload.layout, asmiport.hub.dw)
|
|
|
|
self.submodules.dma = spi.DMAWriteController(dma_lasmi.Writer(lasmim), spi.MODE_SINGLE_SHOT)
|
|
|
|
self.comb += [
|
|
|
|
self.packer.sink.stb.eq(fifo.readable),
|
|
|
|
fifo.re.eq(self.packer.sink.ack),
|
|
|
|
self.packer.sink.word.eq(fifo.dout),
|
|
|
|
self.packer.source.connect_flat(self.cast.sink),
|
|
|
|
self.cast.source.connect_flat(self.dma.data)
|
|
|
|
]
|