from migen.fhdl.std import * from migen.actorlib.fifo import AsyncFIFO from migen.actorlib.structuring import Converter from migen.flow.actor import Sink, Source from lib.sata.k7sataphy.std import * class K7SATAPHYRXConvert(Module): def __init__(self, dw=16): self.rxdata = Signal(dw) self.rxcharisk = Signal(dw//8) self.source = Source([("data", 32), ("charisk", 4)]) ### # byte alignment rxdata_r = Signal(2*dw) rxcharisk_r = Signal((2*dw)//8) rxalignment = Signal(dw//8) rxvalid = Signal() self.sync.sata_rx += [ rxdata_r.eq(Cat(self.rxdata, rxdata_r[0:dw])), rxcharisk_r.eq(Cat(self.rxcharisk, rxcharisk_r[0:dw//8])), If(self.rxcharisk != 0, rxalignment.eq(self.rxcharisk), rxvalid.eq(1) ).Else( rxvalid.eq(~rxvalid) ) ] rxdata = Signal(2*dw) rxcharisk = Signal((2*dw)//8) cases = {} cases[1<<0] = [ rxdata.eq(rxdata_r[0:]), rxcharisk.eq(rxcharisk_r[0:]) ] for i in range(1, dw//8): cases[1<