phy/pcs_1000basex: Move PCS Gearbox.

This commit is contained in:
Florent Kermarrec 2024-10-15 11:40:13 +02:00
parent 313e7a985c
commit 19e1d19444
1 changed files with 30 additions and 30 deletions

View File

@ -19,7 +19,7 @@ from litex.soc.cores.code_8b10b import K, D, Encoder, Decoder
from liteeth.common import * from liteeth.common import *
# Constants / Helpers ------------------------------------------------------------------------------ # PCS Constants / Helpers --------------------------------------------------------------------------
SGMII_1000MBPS_SPEED = 0b10 SGMII_1000MBPS_SPEED = 0b10
SGMII_100MBPS_SPEED = 0b01 SGMII_100MBPS_SPEED = 0b01
@ -31,6 +31,35 @@ CTYPE_C2 = 0b1
ITYPE_I1 = 0b0 ITYPE_I1 = 0b0
ITYPË_I2 = 0b1 ITYPË_I2 = 0b1
# PCS Gearbox --------------------------------------------------------------------------------------
class PCSGearbox(LiteXModule):
def __init__(self):
self.tx_data = Signal(10)
self.tx_data_half = Signal(20)
self.rx_data_half = Signal(20)
self.rx_data = Signal(10)
# # #
# TX
buf = Signal(20)
self.sync.eth_tx += buf.eq(Cat(buf[10:], self.tx_data))
self.sync.eth_tx_half += self.tx_data_half.eq(buf)
# RX
phase_half = Signal()
phase_half_rereg = Signal()
self.sync.eth_rx_half += phase_half_rereg.eq(phase_half)
self.sync.eth_rx += [
If(phase_half == phase_half_rereg,
self.rx_data.eq(self.rx_data_half[10:])
).Else(
self.rx_data.eq(self.rx_data_half[:10])
),
phase_half.eq(~phase_half),
]
# PCS TX ------------------------------------------------------------------------------------------- # PCS TX -------------------------------------------------------------------------------------------
class PCSTX(LiteXModule): class PCSTX(LiteXModule):
@ -248,35 +277,6 @@ class PCSRX(LiteXModule):
) )
) )
# PCS Gearbox --------------------------------------------------------------------------------------
class PCSGearbox(LiteXModule):
def __init__(self):
self.tx_data = Signal(10)
self.tx_data_half = Signal(20)
self.rx_data_half = Signal(20)
self.rx_data = Signal(10)
# # #
# TX
buf = Signal(20)
self.sync.eth_tx += buf.eq(Cat(buf[10:], self.tx_data))
self.sync.eth_tx_half += self.tx_data_half.eq(buf)
# RX
phase_half = Signal()
phase_half_rereg = Signal()
self.sync.eth_rx_half += phase_half_rereg.eq(phase_half)
self.sync.eth_rx += [
If(phase_half == phase_half_rereg,
self.rx_data.eq(self.rx_data_half[10:])
).Else(
self.rx_data.eq(self.rx_data_half[:10])
),
phase_half.eq(~phase_half),
]
# PCS ---------------------------------------------------------------------------------------------- # PCS ----------------------------------------------------------------------------------------------
class PCS(LiteXModule): class PCS(LiteXModule):