An 800G port deals its blocks to two flows and the far end weaves them back together. Block 33 arrives where block 41 was due. Find the first bad cycle 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 design below is the two ends of an 800GBASE-R PCS. The two FEC pipelines between the ends are left out.
The near end deals 66-bit blocks to flow 0 and flow 1 and says where each flow puts its marker group.
The far end reads a marker on each of 32 wires. It sends each wire to one of two decoders, 16 lanes each.
Then it collects: it weaves the blocks of the two decoders back into one stream.
The bench sends 150 numbered blocks. The far end starts listening in mid-stream. The log says: ERROR: the far end got block 33 where block 41 was due.
Step 1: find the first cycle where a signal differs from a correct design, and name the signal.
Cycles 1 to 32 read the markers: cycle N is wire N − 1. From cycle 33 on, cycle N sends block N − 33.
Step 2: choose the cause from five bugs. Each is real, and each one makes the far end report blocks out of order.
Step 3 is optional: fix the design and run the tests.
A 257-bit block is kept here as its four 66-bit blocks. The bench stands in for the decoders: a decoder works only when it gets the 16 lanes of one flow, in order.
A wire may be read again. If it then shows no lane, its old lane is gone and rx_ready falls.
The lesson's readable library holds the marker table. This design calls its lane_of.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
test_number | 8 | input of each check |
Full specification
function automatic void tx_reset(input int gap);
function automatic void tx_block(input [65:0] blk); // one 66-bit block from the encoder
function automatic void rx_reset();
function automatic void rx_marker(input int wire_no, input [119:0] m); // the marker found on one of the 32 wires
function automatic void rx_units(input bit v0, input bit am0, input [263:0] u0, input bit v1, input bit am1, input [263:0] u1);
| Item | Rule |
|---|---|
| Block distribution | the first 66-bit block after tx_reset goes to flow 0, the next to flow 1, and so on in turn (172.2.4.3). tx_flow is the flow of the block of this call |
| 257-bit block | four 66-bit blocks of one flow in a row. tx_v is 1 in the call that brings the fourth. tx_unit then holds the four, the first in bits 65:0 |
| Marker group | each flow sends a group of its own, eight 257-bit blocks long. tx_am = 1 with tx_v means: the group of tx_flow goes out just before this 257-bit block |
| Where the groups go | at the same point of the stream in both flows (172.2.4.6). Say the group of flow 0 is before the 257-bit block that holds 66-bit block k. Then the group of flow 1 is before the one that holds k + 1 |
| How often | a course choice of interface: before the first 257-bit block of each flow after tx_reset, and then after every gap blocks of that flow. The standard's number is 163,832: one group in every 163,840 blocks (119.2.4.4.2) |
rx_marker | rx_l is the PCS lane of the marker, from am.lane_of, or −1. Calls may come in any order, and a wire may be read again |
| A wire read again | the new reading replaces the old one. A wire that now shows no lane has dropped its old lane |
| Lanes to flows | PCS lanes 0 to 15 belong to flow 0 and lanes 16 to 31 to flow 1 (172.2.5.2). rx_f is the flow. rx_s is the place among the 16 lanes of that flow: the lane number, less 16 for flow 1. Both are −1 with no lane |
rx_ready | a course choice: 1 when, as the wires stand now, every one of the 32 PCS lanes is found on a wire |
rx_units | v0 = 1: decoder 0 hands over a 257-bit block, u0. am0 = 1: it is the first after a marker group. The same for decoder 1 |
| Block collection | the first 66-bit block after the group of flow 0 is followed by the first after the group of flow 1 (172.2.5.8). Then they alternate |
| Where it starts | a course choice: after rx_reset, a flow's blocks are dropped until one arrives with its am set. That one is kept. Later groups change nothing |
rx_v, rx_out | as soon as both flows have a block waiting, the oldest of each leave together. rx_out holds their eight 66-bit blocks in stream order, the first in bits 65:0 |
| Waiting | a course choice of the tests: they never leave more than four 257-bit blocks of one flow waiting for the other |
| Left out | transcoding, scrambling, the content of the marker group, FEC and the lanes' symbols. Deskew has lined the lanes up: both decoders start at the same point of the stream |
The fixture runs each end beside a private model on random streams, wire orders and pipeline delays. Scripted runs check both ends together.
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 3 is optional: fix the code in the editor, then run the tests.
Examples
Example 1
Eighty Blocks, a Group Every 5- Input
`tx_reset(5)`, then 66-bit blocks 0 to 79
- Output
marker_groups_of_flow_0 = 2, marker_groups_of_flow_1 = 2, last_group_of_flow_0_is_before_block = 40, last_group_of_flow_1_is_before_block = 41, blocks_of_257_bits_sent = 20, wrong_calls = 0
Each flow sends ten 257-bit blocks and two marker groups. The second group of flow 0 is before the block that starts with 66-bit block 40. That of flow 1 is before block 41.
Example 2
Thirty-Two Wires, Lanes in a Mixed Order- Input
wire w carries PCS lane (5w + 7) mod 32
- Output
flow_of_wire_0 = 0, place_of_wire_0 = 7, flow_of_wire_31 = 0, place_of_wire_31 = 2, wires_sent_to_flow_0 = 16, wires_sent_to_flow_1 = 16, ready_after_32_markers = 1, ready_after_16_markers = 0, sum_over_all_wires = 0xa740, ready_at_the_end = 1
Wire 0 carries lane 7: flow 0, place 7. Wire 31 carries lane 2. Sixteen wires go to each flow, and ready rises only with the last marker.
Example 3
Both Ends and a Link- Input
a group every 5, a start at 257-bit block 3, 200 blocks
- Output
ready = 1, decoder_0_decodes_flow = 0, decoder_1_decodes_flow = 1, blocks_out = 136, first_block_out = 40, blocks_out_of_order = 0
The first group at or after block 3 is before block 5. So the first 66-bit block out is 40, and 136 blocks leave in order.
Constraints and Contract
- Keep the five functions with their arguments.
- Keep the names
tx_flow,tx_v,tx_am,tx_unit,rx_l,rx_f,rx_s,rx_ready,rx_vandrx_out: the fixture reads them. tx_resetandrx_resetmust clear all state of their end.- After a reset only
rx_readyis checked before the next call. It must be 0 afterrx_reset. - You may call
am.lane_of,am.amand the other functions ofam. - Off limits: the names
ref_p,rng,tb,rootand the modules of the bench. - The fixture's own names are off limits too. They begin with
fx_.
Hints
Hint 1
The lanes come first. Check that each decoder gets the 16 lanes of its own flow.
Hint 2
Then look at the near end. In which calls does tx_am rise for flow 0, and in which for flow 1?
Hint 3
Both flows must put their group at the same point of the stream. Flow 1 finishes its 257-bit block one call after flow 0.
What the grader checks: The failing run is simulated live with the faulty design. The first bad cycle and each option's symptom come from runs of each version on the same bench. The fix is checked on 18 scripted runs, with expected values from a JavaScript model. It is also checked on 48 random runs, seeded for each submission. Those compare every output with a private model after every call. The private model is written in another way than the solution. Four things are course choices: one call per 66-bit block and the gap argument. So are the first group at the start and the single start of collection. The tests never leave more than four blocks waiting. Transcoding, scrambling, the marker group's content, FEC, symbol distribution, deskew and marker lock are not graded here.
23 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 2 steps and the final capstone