SBASAO8 June 2025 DAC39RF20
ADVANCE INFORMATION
initial begin
int tries;
int arrival [];
// Start the link according to Startup Procedure. Any value of RBD is okay.
// Note that LINK_UP may not be set since RBD can be invalid.
startup_link();
// Wait for LANE_ARR_RDY to go high
// Give up after 1000 tries.
tries = 0;
while(read_reg(LANE_ARR_RDY)==0 && tries<1000)
tries++;
// Read LANE_ARR for all lanes
arrival = new [L];
foreach(arrival[i]) arrival[i] = read_reg(LANE_ARR[i]);
RBD = determine_RBD(arrival, K*F/8);
// Use this RBD value to restart the link
end
// This function computes RBD from an array of arrival times
function determine_RBD(
int arrival [], // A dynamic array of arrival times from LANE_ARR
int oneMF // Number of octa-bytes per multiframe/EMB
);
int spacing, max_spacing;
int latest, earliest;
int L, early_overwrite;
int AM, EB_size;
// Buffer size is up to 16 octa-bytes, but never more than oneMF
EB_size = oneMF > 16 ? 16 : oneMF;
// Modulo-value for LANE_ARR
AM = JENC ? 32*E : 32;
// Number of lanes is the size of the arrival array
L = arrival.size;
// Sort arrival list in ascending numeric order
arrival.sort;
// Find the largest spacing between arrival times (on a circle)
max_spacing = 0;
for(int i = 0; i<L; i++) begin
spacing = arrival[(i+1)%L] – arrival[i] + (i==L-1)*AM;
if(spacing>max_spacing) begin
max_spacing = spacing;
latest = arrival[i];
earliest = arrival[(i+1)%L];
end
end
// Check that lane skew is not too large for the elastic buffer
if ( (latest-earliest+AM)%AM >= EB_size ) begin
$display(“ERROR: Lane skew too large for elastic buffer”);
$display(“ Earliest=%0d Latest=%0d”);
return 0;
end
// Choose RBD to be halfway between the latest arriving lane (+1) and the moment
// the earliest lane begins to over-write the elastic buffer.
early_overwrite = (earliest+EB_size)%AM;
if(early_overwrite < latest+1) early_overwrite += AM;
return (latest+1+early_overwrite)/2 % oneMF;
endfunction