P11.17.1 Debug the MAC That Puts Start in the Wrong Lane

MediumDebugIcarus Verilog · serverReview the topic

A 10 Gb/s MAC sends back-to-back frames of mixed sizes. Now and then the PHY drops one, and the monitor sees Start on lane 2. Find the first bad column and the cause.

Hardware context: An Ethernet MAC and physical coding sublayer: frame builder and checker, reconciliation sublayer and block encoder. Build, check and pace Ethernet frames, and code them for the physical layer as IEEE 802.3 specifies.

The RS below lays packets onto the XGMII. It keeps Start on lane 0 with the deficit idle count: it deletes or inserts idle in the gap.

The MAC sends seven frames back to back: 64, 65, 66, 67, 65, 65 and 64 octets. The log says: ERROR: Start on lane 2.

Step 1: find the first column where a signal differs from a correct RS, and name it. Step 2: choose the cause from five bugs. Each is real and fails at a different column.

Step 3 is optional: fix the RS and run the tests.

Signals in the Timeline

SignalWidthRole
test_number8input of each check
Full specification
The RS API
bit [7:0] fr [0:2047];                     // the next frame
function automatic void rs_reset();
function automatic void rs_send(input int n);   // queue one packet with an n-octet frame
function automatic [35:0] xg_col();          // {c[3:0], d[31:0]}, lane 0 in c[0] and d[7:0]
RuleCorrect RS
PacketStart (FBh, control), six 55h, D5h, the frame, Terminate (FDh, control)
Gapthe Terminate and 11 idles (07h, control): 12 characters, as the MAC asks
Starton lane 0 only. If it would land on lane m, delete m idles from the gap, or insert 4 - m
Deficit idle countdeleting adds to it, inserting subtracts; delete only if the count stays at 3 or below
Columnscycle N is column N; the signals are taken as the column goes out

The count starts at 0. Both choices keep the long-run gap at 12 characters on average.

The 25GMII has the same logical function as the XGMII, with a faster clock (106.1). So one test sends a 25 Gb/s stream through the same RS, with the same rules.

Diagnose the Failing Run

The test below runs the buggy design. Read its log, then find where it first goes wrong in the waveform.

Log

Waveform

Click a signal at a cycle to select it. Or focus the waveform and use the arrow keys: Left and Right move one cycle, Up and Down one signal.

Step 1 · The first bad cycle and signal
Step 2 · The cause

Step 3 is optional: fix the code in the editor, then run the tests.

Examples

Example 1

Four 64-octet Frames
Input
64 + 8 + 12 = 84 characters each
Output
columns_differing_from_a_correct_rs = 0, frames_seen = 4, idle_characters = 1468, starts_off_lane_0 = 0

Every Start already lands on lane 0. Nothing is deleted or inserted.

Example 2

Eight 65-octet Frames
Input
each Start would land one lane late
Output
columns_differing_from_a_correct_rs = 0, frames_seen = 8, idle_characters = 2768, starts_off_lane_0 = 0

The RS deletes one idle three times, then must insert three.

Example 3

Eight 67-octet Frames
Input
each Start would land three lanes late
Output
columns_differing_from_a_correct_rs = 0, frames_seen = 8, idle_characters = 2752, starts_off_lane_0 = 0

Deleting 3 is allowed when the count is 0. Three single inserts bring it back to 0, and the pattern repeats.

Constraints and Contract

  • Keep the four functions, fr and the queue.
  • Queue packets only through rs_send; the bench calls it when fewer than 16 characters wait.
  • xg_col pads an empty queue with idle.
  • Off limits: the names mon, rng, tb, root, names that begin with ref_ and the modules of the bench.

Hints

Hint 1

Work the deficit idle count by hand for the first five frames. Which one has to insert idle?

Hint 2

If Start would land on lane 3, how many idles put it on lane 0 of the next column?

Hint 3

Watch dic at the column where the fifth packet (the 65-octet frame after the 67) is queued.

What the grader checks: The failing run is simulated live with the faulty RS. The first bad column and each option's symptom come from runs of each version on the same bench. The fix is checked on six fixed lists against an independent JavaScript model. One is a 25GMII stream, whose rules are the XGMII's (106.1). It is also checked on 400 random frames against a private reference RS, column by column.

8 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 1 steps and the final capstone

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

Four 64-octet Frames

Input
64 + 8 + 12 = 84 characters each
Expected output
columns_differing_from_a_correct_rs = 0, frames_seen = 4, idle_characters = 1468, starts_off_lane_0 = 0

Every Start already lands on lane 0. Nothing is deleted or inserted.

Run samples executes all 3 public checks. Check all tests runs 8 checks on the server.

Icarus Verilog · server