From 6c6717daef01464da6db9267a2a93d08ac8227fb Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 8 Oct 2019 18:58:50 +0200 Subject: [PATCH] kc705: add Scrambler and enable it when in polling.idle (experiment) --- kc705.py | 11 +++++++++++ usb3_pipe/ltssm.py | 13 ++++++++++--- usb3_pipe/training.py | 3 +-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/kc705.py b/kc705.py index e621326..4bb311e 100755 --- a/kc705.py +++ b/kc705.py @@ -23,6 +23,7 @@ from litescope import LiteScopeAnalyzer from usb3_pipe.serdes import K7USB3SerDes from usb3_pipe.phy import USB3PHY +from usb3_pipe.scrambling import Scrambler # USB3 IOs ----------------------------------------------------------------------------------------- @@ -133,6 +134,16 @@ class USB3SoC(SoCMini): ) ] + # Scrambler -------------------------------------------------------------------------------- + self.submodules.scrambler = scrambler = Scrambler() + self.comb += [ + If(usb3_phy.ready, + scrambler.sink.valid.eq(1), + scrambler.sink.data.eq(0), + scrambler.source.connect(usb3_serdes.sink) + ) + ] + # Leds ------------------------------------------------------------------------------------- self.comb += platform.request("user_led", 0).eq(usb3_serdes.ready) self.comb += platform.request("user_led", 1).eq(usb3_phy.ready) diff --git a/usb3_pipe/ltssm.py b/usb3_pipe/ltssm.py index 00d3dac..8004e6c 100644 --- a/usb3_pipe/ltssm.py +++ b/usb3_pipe/ltssm.py @@ -176,11 +176,14 @@ class PollingFSM(FSM): # # # + rx_ts2 = Signal() + # FSM -------------------------------------------------------------------------------------- FSM.__init__(self, reset_state="LFPS") # LFPS State ------------------------------------------------------------------------------- self.act("LFPS", + NextValue(rx_ts2, 0), serdes.rx_align.eq(1), lfps_unit.tx_polling.eq(1), If(lfps_unit.rx_polling, @@ -208,7 +211,7 @@ class PollingFSM(FSM): self.act("ACTIVE", ts_unit.rx_enable.eq(1), If(ts_unit.rx_ts1 | ts_unit.rx_ts2, - NextState("CONFIGURATION"), # 8 consecutiive TS1 or TS2 received. + NextState("CONFIGURATION_0"), # 8 consecutiive TS1 or TS2 received. ), #self.exit_to_ss_disabled.eq(1), # Timeout (Dev) or directed (DS). #self.exit_to_rx_detect.eq(1), # Timeout (DS). @@ -216,11 +219,15 @@ class PollingFSM(FSM): ) # Configuration State ---------------------------------------------------------------------- - self.act("CONFIGURATION", + + self.act("CONFIGURATION_0", ts_unit.rx_enable.eq(1), ts_unit.tx_enable.eq(1), ts_unit.tx_ts2.eq(1), - If(ts_unit.rx_ts2, + NextValue(rx_ts2, rx_ts2 | ts_unit.rx_ts2), + If(rx_ts2 & ts_unit.ts2_generator.done, + ts_unit.tx_enable.eq(0), + ts_unit.tx_ts2.eq(0), NextState("IDLE"), # TS2 handshake. ), #self.exit_to_ss_disabled.eq(1), # Timeout (Dev) or directed (DS). diff --git a/usb3_pipe/training.py b/usb3_pipe/training.py index f1edd31..164cf6d 100644 --- a/usb3_pipe/training.py +++ b/usb3_pipe/training.py @@ -205,8 +205,7 @@ class TSUnit(Module): ] # Ordered Set Generators ------------------------------------------------------------------- - ts2_generator = TSGenerator(ordered_set=TS2, n_ordered_sets=8) - self.submodules += ts2_generator + self.submodules.ts2_generator = ts2_generator = TSGenerator(ordered_set=TS2, n_ordered_sets=8) self.comb += [ If(self.tx_enable, ts2_generator.send.eq(self.tx_ts2),