2013-03-13 14:56:26 -04:00
|
|
|
from migen.fhdl.structure import *
|
|
|
|
from migen.fhdl.module import Module
|
2013-05-06 03:58:12 -04:00
|
|
|
from migen.bank.description import AutoCSR
|
2013-03-13 14:56:26 -04:00
|
|
|
|
|
|
|
from milkymist.dvisampler.edid import EDID
|
2013-03-17 09:43:10 -04:00
|
|
|
from milkymist.dvisampler.clocking import Clocking
|
|
|
|
from milkymist.dvisampler.datacapture import DataCapture
|
2013-03-21 17:56:13 -04:00
|
|
|
from milkymist.dvisampler.charsync import CharSync
|
2013-05-16 16:38:55 -04:00
|
|
|
from milkymist.dvisampler.wer import WER
|
2013-03-22 18:49:25 -04:00
|
|
|
from milkymist.dvisampler.decoding import Decoding
|
2013-03-22 13:37:10 -04:00
|
|
|
from milkymist.dvisampler.chansync import ChanSync
|
2013-05-06 03:58:12 -04:00
|
|
|
from milkymist.dvisampler.analysis import SyncPolarity, ResolutionDetection, FrameExtraction
|
|
|
|
from milkymist.dvisampler.dma import DMA
|
2013-03-13 14:56:26 -04:00
|
|
|
|
2013-03-30 12:28:15 -04:00
|
|
|
class DVISampler(Module, AutoCSR):
|
2013-05-08 16:31:01 -04:00
|
|
|
def __init__(self, pads, asmiport, n_dma_slots=2):
|
2013-03-26 12:57:17 -04:00
|
|
|
self.submodules.edid = EDID(pads)
|
|
|
|
self.submodules.clocking = Clocking(pads)
|
2013-03-17 09:43:10 -04:00
|
|
|
|
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-26 12:57:17 -04:00
|
|
|
invert = False
|
|
|
|
try:
|
|
|
|
s = getattr(pads, name)
|
|
|
|
except AttributeError:
|
|
|
|
s = getattr(pads, name + "_n")
|
|
|
|
invert = True
|
2013-03-21 17:56:13 -04:00
|
|
|
|
2013-03-21 14:06:15 -04:00
|
|
|
cap = DataCapture(8, invert)
|
2013-03-17 09:43:10 -04:00
|
|
|
setattr(self.submodules, name + "_cap", cap)
|
|
|
|
self.comb += [
|
|
|
|
cap.pad.eq(s),
|
2013-03-18 14:03:17 -04:00
|
|
|
cap.serdesstrobe.eq(self.clocking.serdesstrobe)
|
2013-03-17 09:43:10 -04:00
|
|
|
]
|
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
|
|
|
|
2013-05-06 03:58:12 -04:00
|
|
|
###
|
|
|
|
|
2013-05-05 06:58:53 -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 += [
|
2013-05-06 03:58:12 -04:00
|
|
|
self.resdetection.valid_i.eq(self.syncpol.valid_o),
|
2013-05-05 06:58:53 -04:00
|
|
|
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
|
|
|
|
2013-05-06 03:58:12 -04:00
|
|
|
self.submodules.frame = FrameExtraction()
|
2013-05-04 14:40:21 -04:00
|
|
|
self.comb += [
|
2013-05-06 03:58:12 -04:00
|
|
|
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
|
|
|
]
|
|
|
|
|
2013-05-08 16:31:01 -04:00
|
|
|
self.submodules.dma = DMA(asmiport, n_dma_slots)
|
2013-05-06 03:58:12 -04:00
|
|
|
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"}
|