From: Florent Kermarrec Date: Mon, 29 Sep 2014 11:02:11 +0000 (+0200) Subject: fix alignment (still some transmissions errors --> need to check clocks and resets) X-Git-Tag: 24jan2021_ls180~2572^2~186 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b47153fbfabc80b1590b5de38622089463eb5473;p=litex.git fix alignment (still some transmissions errors --> need to check clocks and resets) --- diff --git a/lib/sata/k7sataphy/__init__.py b/lib/sata/k7sataphy/__init__.py index f3a3676f..90094e0c 100644 --- a/lib/sata/k7sataphy/__init__.py +++ b/lib/sata/k7sataphy/__init__.py @@ -5,7 +5,6 @@ from lib.sata.k7sataphy.std import * from lib.sata.k7sataphy.gtx import K7SATAPHYGTX from lib.sata.k7sataphy.crg import K7SATAPHYCRG from lib.sata.k7sataphy.ctrl import K7SATAPHYHostCtrl, K7SATAPHYDeviceCtrl -from lib.sata.k7sataphy.datapath import K7SATAPHYRXAlign from lib.sata.k7sataphy.datapath import K7SATAPHYRXConvert, K7SATAPHYTXConvert class K7SATAPHY(Module): @@ -20,22 +19,18 @@ class K7SATAPHY(Module): # CRG / CTRL crg = K7SATAPHYCRG(pads, gtx, clk_freq, default_speed) if host: - ctrl = K7SATAPHYHostCtrl(gtx, clk_freq) + ctrl = K7SATAPHYHostCtrl(gtx, crg, clk_freq) else: - ctrl = K7SATAPHYDeviceCtrl(gtx, clk_freq) + ctrl = K7SATAPHYDeviceCtrl(gtx, crg, clk_freq) self.submodules += crg, ctrl - self.comb += ctrl.start.eq(crg.ready) # DATAPATH - rxalign = K7SATAPHYRXAlign() rxconvert = K7SATAPHYRXConvert() txconvert = K7SATAPHYTXConvert() - self.submodules += rxalign, rxconvert, txconvert + self.submodules += rxconvert, txconvert self.comb += [ - rxalign.rxdata_i.eq(gtx.rxdata), - rxalign.rxcharisk_i.eq(gtx.rxcharisk), - rxconvert.rxdata.eq(rxalign.rxdata_o), - rxconvert.rxcharisk.eq(rxalign.rxcharisk_o), + rxconvert.rxdata.eq(gtx.rxdata), + rxconvert.rxcharisk.eq(gtx.rxcharisk), gtx.txdata.eq(txconvert.txdata), gtx.txcharisk.eq(txconvert.txcharisk) @@ -53,7 +48,7 @@ class K7SATAPHY(Module): txconvert.sink.charisk.eq(ctrl.txcharisk) ), self.source.stb.eq(rxconvert.source.stb), - self.source.payload.eq(rxconvert.source.payload), - rxconvert.source.ack.eq(self.source.ack), + self.source.payload.eq(rxconvert.source.data), + rxconvert.source.ack.eq(1), ctrl.rxdata.eq(rxconvert.source.data) ] diff --git a/lib/sata/k7sataphy/ctrl.py b/lib/sata/k7sataphy/ctrl.py index 7f9648ab..07b541bd 100644 --- a/lib/sata/k7sataphy/ctrl.py +++ b/lib/sata/k7sataphy/ctrl.py @@ -11,8 +11,7 @@ def us(t, clk_freq): return ceil(t/clk_period_us) class K7SATAPHYHostCtrl(Module): - def __init__(self, gtx, clk_freq): - self.start = Signal() + def __init__(self, gtx, crg, clk_freq): self.ready = Signal() self.txdata = Signal(32) @@ -33,7 +32,7 @@ class K7SATAPHYHostCtrl(Module): fsm.act("RESET", gtx.txelecidle.eq(1), - If(self.start, + If(crg.ready, NextState("COMINIT") ) ) @@ -89,8 +88,7 @@ class K7SATAPHYHostCtrl(Module): ) fsm.act("AWAIT_ALIGN", gtx.txelecidle.eq(0), - self.txdata.eq(0x4A4A4A4A), #D10.2 - self.txcharisk.eq(0b0000), + gtx.rxalign.eq(1), If(align_detect & ~align_timeout, NextState("SEND_ALIGN") ).Elif(~align_detect & align_timeout, @@ -143,7 +141,7 @@ class K7SATAPHYHostCtrl(Module): self.sync += \ If(fsm.ongoing("SEND_ALIGN"), - If(self.rxdata[0:8] == K28_5, + If(self.rxdata[0:8] == 0xBC, non_align_cnt.eq(non_align_cnt + 1) ).Else( non_align_cnt.eq(0) @@ -151,8 +149,7 @@ class K7SATAPHYHostCtrl(Module): ) class K7SATAPHYDeviceCtrl(Module): - def __init__(self, gtx, clk_freq): - self.start = Signal() + def __init__(self, gtx, crg, clk_freq): self.ready = Signal() self.txdata = Signal(32) @@ -172,7 +169,7 @@ class K7SATAPHYDeviceCtrl(Module): fsm.act("RESET", gtx.txelecidle.eq(1), - If(self.start, + If(crg.ready, NextState("AWAIT_COMINIT") ) ) @@ -218,6 +215,7 @@ class K7SATAPHYDeviceCtrl(Module): ) fsm.act("SEND_ALIGN", gtx.txelecidle.eq(0), + gtx.rxalign.eq(1), self.txdata.eq(ALIGN_VAL), self.txcharisk.eq(0b0001), If(align_detect, diff --git a/lib/sata/k7sataphy/datapath.py b/lib/sata/k7sataphy/datapath.py index 95f115ba..d7e4c737 100644 --- a/lib/sata/k7sataphy/datapath.py +++ b/lib/sata/k7sataphy/datapath.py @@ -5,69 +5,57 @@ from migen.flow.actor import Sink, Source from lib.sata.k7sataphy.std import * -class K7SATAPHYRXAlign(Module): +class K7SATAPHYRXConvert(Module): def __init__(self, dw=16): - self.rxdata_i = Signal(dw) - self.rxcharisk_i = Signal(dw//8) + self.rxdata = Signal(dw) + self.rxcharisk = Signal(dw//8) - self.rxdata_o = Signal(dw) - self.rxcharisk_o = Signal(dw//8) + self.source = Source([("data", 32), ("charisk", 4)]) ### - rxdata_r = Signal(dw) - rxcharisk_r = Signal(dw//8) + # 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(self.rxdata_i), - rxcharisk_r.eq(self.rxcharisk_i) + 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] = [ - self.rxdata_o.eq(rxdata_r[0:dw]), - self.rxcharisk_o.eq(rxcharisk_r[0:dw//8]) + rxdata.eq(rxdata_r[0:]), + rxcharisk.eq(rxcharisk_r[0:]) ] for i in range(1, dw//8): cases[1<