litex/milkymist/dvisampler/decoding.py

26 lines
763 B
Python
Raw Normal View History

2013-03-22 16:28:17 -04:00
from migen.fhdl.structure import *
from migen.fhdl.module import Module
2013-03-22 18:49:25 -04:00
from migen.genlib.record import Record
2013-03-22 16:28:17 -04:00
2013-03-22 18:49:25 -04:00
from milkymist.dvisampler.common import control_tokens, channel_layout
2013-03-22 16:28:17 -04:00
class Decoding(Module):
def __init__(self):
self.valid_i = Signal()
2013-03-22 18:49:25 -04:00
self.input = Signal(10)
2013-03-22 16:28:17 -04:00
self.valid_o = Signal()
2013-03-22 18:49:25 -04:00
self.output = Record(channel_layout)
2013-03-22 16:28:17 -04:00
###
2013-05-05 05:51:48 -04:00
self.sync.pix += self.output.de.eq(1)
2013-03-22 18:49:25 -04:00
for i, t in enumerate(control_tokens):
self.sync.pix += If(self.input == t,
self.output.de.eq(0),
self.output.c.eq(i)
)
self.sync.pix += self.output.d[0].eq(self.input[0] ^ self.input[9])
for i in range(1, 8):
self.sync.pix += self.output.d[i].eq(self.input[i] ^ self.input[i-1] ^ ~self.input[8])
2013-03-22 16:28:17 -04:00
self.sync.pix += self.valid_o.eq(self.valid_i)