From 55acea8705bc9d65abb2a6b7951492596d65378b Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Wed, 8 Jul 2026 21:38:08 -0700 Subject: [PATCH] eth: Add support for SGMII symbol replication to BASE-X sink model Signed-off-by: Alex Forencich --- src/eth/tb/basex.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/eth/tb/basex.py b/src/eth/tb/basex.py index 343f3fd..09866b3 100644 --- a/src/eth/tb/basex.py +++ b/src/eth/tb/basex.py @@ -16,9 +16,6 @@ from cocotb.queue import Queue, QueueFull from cocotb.triggers import RisingEdge, Timer, First, Event from cocotb.utils import get_sim_time -# from cocotbext.eth.constants import (EthPre, XgmiiCtrl, BaseRCtrl, BaseRO, -# BaseRSync, BaseRBlockType, xgmii_ctrl_to_baser_mapping, -# baser_ctrl_to_xgmii_mapping, block_type_term_lane_mapping) from cocotbext.eth.constants import EthPre, XgmiiCtrl from cocotbext.eth import GmiiFrame @@ -536,6 +533,8 @@ class BaseXSerdesSink: self.queue_occupancy_bytes = 0 self.queue_occupancy_frames = 0 + self.gmii_rep_count = 0 + self.an_cfg = None self.an_ability_match_cnt = 0 self.an_ack_match_cnt = 0 @@ -605,6 +604,12 @@ class BaseXSerdesSink: continue self.gbx_bit_cnt += in_bits + def set_gmii_rep_count(self, rep=0): + self.gmii_rep_count = int(rep) + + def get_gmii_rep_count(self): + return self.gmii_rep_count + def get_an_cfg(self): an_cfg = self.an_cfg self.an_cfg = None @@ -680,6 +685,8 @@ class BaseXSerdesSink: an_cfg = None last_an_cfg = 0 + skip_cnt = 0 + while True: await clock_edge_event @@ -784,7 +791,7 @@ class BaseXSerdesSink: self.active_event.set() frame = None - else: + elif skip_cnt == 0: # normal frame data if frame.sim_time_sfd is None and not in_pre: frame.sim_time_sfd = sim_time + (clk_period // self.byte_lanes * k) + gbx_delay @@ -833,6 +840,7 @@ class BaseXSerdesSink: frame = GmiiFrame(bytearray([EthPre.PRE]), [False]) frame.sim_time_start = sim_time + (clk_period // self.byte_lanes * k) + gbx_delay in_pre = True + skip_cnt = 0 else: self.log.warning("Ignoring unaligned start") elif d_val == XgmiiCtrl.ERROR: @@ -859,6 +867,11 @@ class BaseXSerdesSink: self.an_ack_match_cnt = 0 self.an_idle_match_cnt += 1 + if skip_cnt > 0: + skip_cnt -= 1 + elif self.gmii_rep_count: + skip_cnt = self.gmii_rep_count + if an_cnt_reset: self.an_ability_match_cnt = 0 self.an_ack_match_cnt = 0