P10.12.1 Deskew Four Lanes

MediumImplementIcarus · browser samples / server checksReview the topic

Four lanes arrive with different delays. Buffer each one from its marker, and read the four in step once all have arrived.

Hardware context: The digital blocks of a serializer/deserializer: line encoder and decoder, scrambler, CRC and error-correcting code. Keep the line balanced and busy, and detect or correct the errors a fast serial link makes.

A link sends one stream over four lanes. Each lane reaches you with its own delay, up to 15 symbol times. Every 64 symbols, each lane carries a marker, K28.5, sent on all four lanes at the same moment.

Write the deskew. In each step the fixture calls dsk_put(lane, sym) for every lane that has a symbol, then dsk_step() once. When every lane has seen its first marker, read one symbol from each lane per step, all from the same moment.

Write dsk_reset() too. The tests call it before each stream. Your result is compared, step by step, with a reference deskew that follows the rules below.

Signals in the Timeline

SignalWidthRole
test_number8input of each check
Full specification
Signatures (keep them)
function automatic void dsk_reset();
function automatic void dsk_put(input int lane, input [8:0] sym);   // sym = {k, d}
function automatic bit dsk_step();                                   // 1 = a column was read
function automatic [8:0] dsk_col(input int lane);                    // the column of the last read
ItemRule
LockA lane locks on its first marker, 9'h1bc. Other K codes, such as K28.1 (9'h13c), are not markers.
WriteA locked lane writes every symbol it receives into its own FIFO, starting with the marker.
ReadIn a step where every lane locked in an earlier step, read one symbol from each FIFO, oldest first, and return 1.
Order inside a stepRead first, then write this step's symbols. So the first read comes one step after the last lane locks.
Depth16 symbols per lane, a bench value. A delay of 15 needs 16 entries in the earliest lane.
Other stepsReturn 0. dsk_col is then not read.

The added latency is then the largest delay minus the smallest. The tests check every column of every step for 999 steps.

Examples

Example 1

Small Skews
Input
delays 0, 3, 1, 5
Output
mismatches = 0, columns_read = 930

The lanes lock at steps 64, 67, 65 and 69. The first column is read at step 70, and lane 0 then holds 6 symbols.

Example 2

No Skew
Input
delays 0, 0, 0, 0
Output
mismatches = 0, columns_read = 935

All four lanes lock at step 64. Reading starts at step 65, and the FIFOs never hold more than one symbol.

Example 3

The Largest Delay This Deskew Can Absorb
Input
delays 0, 15, 2, 7
Output
mismatches = 0, columns_read = 920

Lane 0 must hold 16 symbols while it waits for lane 1. A FIFO of 16 is exactly enough.

Constraints and Contract

  • Keep the four function names and their arguments.
  • Keep your state in module-level variables, and clear it in dsk_reset().
  • Lanes are numbered 0 to 3.

Hints

Hint 1

Each lane needs a write counter and a locked flag. One read counter serves all four lanes, because they are read together.

Hint 2

Lane 2 may lock several steps after lane 0. What must lane 0 do with its symbols meanwhile?

Hint 3

Read before you write inside a step. Otherwise the first column comes one step too early.

What the grader checks: The fixture sends 8 sets of four lane streams through your functions for 999 steps. It compares every step with a reference deskew that uses the same rules. It does not test realignment after a lost marker or skew larger than 15.

8 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. 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

Small Skews

Input
delays 0, 3, 1, 5
Expected output
mismatches = 0, columns_read = 930

The lanes lock at steps 64, 67, 65 and 69. The first column is read at step 70, and lane 0 then holds 6 symbols.

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

Icarus · browser samples / server checks