litex/misoclib/dvisampler/__init__.py

80 lines
2.6 KiB
Python
Raw Normal View History

2013-05-22 11:10:13 -04:00
from migen.fhdl.std import *
from migen.bank.description import AutoCSR
2013-03-13 14:56:26 -04:00
2013-11-09 09:27:32 -05:00
from misoclib.dvisampler.edid import EDID
from misoclib.dvisampler.clocking import Clocking
from misoclib.dvisampler.datacapture import DataCapture
from misoclib.dvisampler.charsync import CharSync
from misoclib.dvisampler.wer import WER
from misoclib.dvisampler.decoding import Decoding
from misoclib.dvisampler.chansync import ChanSync
from misoclib.dvisampler.analysis import SyncPolarity, ResolutionDetection, FrameExtraction
from misoclib.dvisampler.dma import DMA
2013-03-13 14:56:26 -04:00
2013-03-30 12:28:15 -04:00
class DVISampler(Module, AutoCSR):
def __init__(self, pads, lasmim, n_dma_slots=2):
2013-03-26 12:57:17 -04:00
self.submodules.edid = EDID(pads)
self.submodules.clocking = Clocking(pads)
2013-03-26 12:57:17 -04:00
for datan in range(3):
2013-03-13 14:56:26 -04:00
name = "data" + str(datan)
2013-03-21 17:56:13 -04:00
cap = DataCapture(getattr(pads, name + "_p"), getattr(pads, name + "_n"), 8)
setattr(self.submodules, name + "_cap", cap)
self.comb += cap.serdesstrobe.eq(self.clocking.serdesstrobe)
2013-03-21 17:56:13 -04:00
charsync = CharSync()
setattr(self.submodules, name + "_charsync", charsync)
self.comb += charsync.raw_data.eq(cap.d)
2013-03-22 13:37:10 -04:00
2013-05-16 16:38:55 -04:00
wer = WER()
setattr(self.submodules, name + "_wer", wer)
self.comb += wer.data.eq(charsync.data)
2013-03-22 18:49:25 -04:00
decoding = Decoding()
setattr(self.submodules, name + "_decod", decoding)
self.comb += [
decoding.valid_i.eq(charsync.synced),
decoding.input.eq(charsync.data)
]
2013-03-22 13:37:10 -04:00
self.submodules.chansync = ChanSync()
self.comb += [
2013-03-22 18:49:25 -04:00
self.chansync.valid_i.eq(self.data0_decod.valid_o & \
self.data1_decod.valid_o & self.data2_decod.valid_o),
self.chansync.data_in0.eq(self.data0_decod.output),
self.chansync.data_in1.eq(self.data1_decod.output),
self.chansync.data_in2.eq(self.data2_decod.output),
2013-03-22 13:37:10 -04:00
]
2013-03-22 18:49:25 -04:00
self.submodules.syncpol = SyncPolarity()
self.comb += [
self.syncpol.valid_i.eq(self.chansync.chan_synced),
self.syncpol.data_in0.eq(self.chansync.data_out0),
self.syncpol.data_in1.eq(self.chansync.data_out1),
self.syncpol.data_in2.eq(self.chansync.data_out2)
]
2013-03-23 19:45:29 -04:00
self.submodules.resdetection = ResolutionDetection()
self.comb += [
self.resdetection.valid_i.eq(self.syncpol.valid_o),
self.resdetection.de.eq(self.syncpol.de),
self.resdetection.vsync.eq(self.syncpol.vsync)
2013-03-23 19:45:29 -04:00
]
2013-05-04 14:40:21 -04:00
self.submodules.frame = FrameExtraction(24*lasmim.dw//32)
2013-05-04 14:40:21 -04:00
self.comb += [
self.frame.valid_i.eq(self.syncpol.valid_o),
self.frame.de.eq(self.syncpol.de),
self.frame.vsync.eq(self.syncpol.vsync),
self.frame.r.eq(self.syncpol.r),
self.frame.g.eq(self.syncpol.g),
self.frame.b.eq(self.syncpol.b)
2013-05-04 14:40:21 -04:00
]
self.submodules.dma = DMA(lasmim, n_dma_slots)
self.comb += self.frame.frame.connect(self.dma.frame)
2013-05-08 16:31:01 -04:00
self.ev = self.dma.ev
autocsr_exclude = {"ev"}