core/USB3PIPE: integrate scrambler/descrambler

This commit is contained in:
Florent Kermarrec 2019-10-10 10:35:01 +02:00
parent d27639c927
commit c39ed5f38c
3 changed files with 24 additions and 2 deletions

4
sim.py
View File

@ -50,12 +50,16 @@ class USB3PIPESim(SoCMini):
host_usb3_serdes = USB3SerDesModel()
host_usb3_pipe = USB3PIPE(serdes=host_usb3_serdes, sys_clk_freq=sys_clk_freq)
self.submodules += host_usb3_serdes, host_usb3_pipe
self.comb += host_usb3_pipe.sink.valid.eq(1)
self.comb += host_usb3_pipe.source.ready.eq(1)
host_usb3_pipe.finalize()
# USB3 Device
dev_usb3_serdes = USB3SerDesModel()
dev_usb3_pipe = USB3PIPE(serdes=dev_usb3_serdes, sys_clk_freq=sys_clk_freq)
self.submodules += dev_usb3_serdes, dev_usb3_pipe
self.comb += dev_usb3_pipe.sink.valid.eq(1)
self.comb += dev_usb3_pipe.source.ready.eq(1)
dev_usb3_pipe.finalize()
# Connect Host <--> Device

View File

@ -8,6 +8,7 @@ from litex.soc.interconnect import stream
from usb3_pipe.lfps import LFPSUnit
from usb3_pipe.training import TSUnit
from usb3_pipe.ltssm import LTSSM
from usb3_pipe.scrambling import Scrambler, Descrambler
# USB3 PIPE ----------------------------------------------------------------------------------------
@ -40,3 +41,22 @@ class USB3PIPE(Module):
self.comb += ltssm.reset.eq(~self.enable)
self.submodules.ltssm = ltssm
self.comb += self.ready.eq(ltssm.polling_fsm.idle)
# Scrambling -------------------------------------------------------------------------------
scrambler = Scrambler()
scrambler = ResetInserter()(scrambler)
self.comb += scrambler.reset.eq(~self.enable)
self.submodules.scrambler = scrambler
self.comb += [
self.sink.connect(scrambler.sink),
If(self.ready, scrambler.source.connect(serdes.sink))
]
descrambler = Descrambler()
descrambler = ResetInserter()(descrambler)
self.comb += descrambler.reset.eq(~self.enable)
self.submodules.descrambler = descrambler
self.comb += [
If(self.ready, serdes.source.connect(descrambler.sink)),
descrambler.source.connect(self.source),
]

View File

@ -80,7 +80,6 @@ class ScramblerUnit(Module):
# Scrambler ----------------------------------------------------------------------------------------
@ResetInserter()
class Scrambler(Module):
def __init__(self):
self.sink = sink = stream.Endpoint([("data", 32), ("ctrl", 4)])
@ -98,7 +97,6 @@ class Scrambler(Module):
# Descrambler --------------------------------------------------------------------------------------
@ResetInserter()
class Descrambler(Module):
def __init__(self):
self.sink = sink = stream.Endpoint([("data", 32), ("ctrl", 4)])