From: Sebastien Bourdeauducq Date: Sun, 5 May 2013 09:53:38 +0000 (+0200) Subject: dvisampler: add sync polarity detection module (thanks Lars for suggestions) X-Git-Tag: 24jan2021_ls180~2959 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e3e1dcd5477b5dc305fec82645e2850591d0cd2e;p=litex.git dvisampler: add sync polarity detection module (thanks Lars for suggestions) --- diff --git a/milkymist/dvisampler/syncpol.py b/milkymist/dvisampler/syncpol.py new file mode 100644 index 00000000..2ef752a8 --- /dev/null +++ b/milkymist/dvisampler/syncpol.py @@ -0,0 +1,49 @@ +from migen.fhdl.structure import * +from migen.fhdl.module import Module +from migen.genlib.record import Record + +from milkymist.dvisampler.common import channel_layout + +class SyncPolarity(Module): + def __init__(self): + self.valid_i = Signal() + self.data_in0 = Record(channel_layout) + self.data_in1 = Record(channel_layout) + self.data_in2 = Record(channel_layout) + + self.valid_o = Signal() + self.de = Signal() + self.hsync = Signal() + self.vsync = Signal() + self.r = Signal(8) + self.g = Signal(8) + self.b = Signal(8) + + ### + + de = self.data_in0.de + de_r = Signal() + c = self.data_in0.c + c_polarity = Signal(2) + c_out = Signal(2) + + self.comb += [ + self.de.eq(de_r), + self.hsync.eq(c_out[0]), + self.vsync.eq(c_out[1]) + ] + + self.sync.pix += [ + self.valid_o.eq(self.valid_i), + self.r.eq(self.data_in2.d), + self.g.eq(self.data_in1.d), + self.b.eq(self.data_in0.d), + + de_r.eq(de), + If(de_r & ~de, + c_polarity.eq(c), + c_out.eq(0) + ).Else( + c_out.eq(c ^ c_polarity) + ) + ]