P10.15.1 Write a PRBS Checker

MediumImplementIcarus · browser samples / server checksReview the topic

Write the PRBS15 checker of a bit error rate test. It locks from the data, counts each wrong bit once, and relocks after a slip.

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 PRBS15, the sequence of x^15 + x^14 + 1 that USB 3.2 uses as its CP12 pattern. You receive it one bit at a time, from an unknown point in the sequence.

Write pc_push(b). First lock: copy 15 received bits into your register. Then predict each bit from your own register, count a wrong bit as one error, and step the register.

If errors pile up, the data has slipped or your lock was wrong: drop lock and lock again. Also write pc_reset().

Signals in the Timeline

SignalWidthRole
test_number8input of each check
Full specification
Signatures (keep them)
function automatic void pc_reset();
function automatic [1:0] pc_push(input bit b);   // returns {locked, error}
ItemRule (bench values)
LockCopy 15 received bits, the oldest first. On the 15th, set locked. That bit returns {1, 0}.
PredictThe next expected bit is the XOR of the bits received 15 and 14 bits ago. After lock, step your own register: never shift a received bit in.
ErrorA locked bit that differs from the prediction returns error = 1.
WindowCount bits and errors in windows of 64 locked bits. The first window starts at lock.
RelockOn the 8th error in one window, clear locked, return {0, 0}, and lock again from the next 15 bits.

The tests compare your result on every bit with a reference checker that follows these rules.

Examples

Example 1

Clean Data
Input
4,000 bits of PRBS15
Output
mismatches = 0, errors_counted = 0

The checker locks after 15 bits and counts no error.

Example 2

Six Isolated Wire Errors
Input
six single flipped bits
Output
mismatches = 0, errors_counted = 6

A free-running checker counts each flipped bit once: six errors. A self-synchronising one would count eighteen.

Example 3

A Flipped Bit While Locking
Input
bit 7 flipped
Output
mismatches = 0, errors_counted = 7

The checker copies a wrong bit and predicts the wrong sequence. It counts 7 errors, relocks on the 8th, and then counts nothing more.

Constraints and Contract

  • Keep both function names, the argument and the 2-bit result.
  • Keep your state in module-level variables, and clear it in pc_reset().
  • Use the bench values as given.

Hints

Hint 1

After lock, the register holds the 15 most recent bits of the sequence the transmitter sent. Which two give the next one?

Hint 2

Shifting received bits in after lock makes a self-synchronising checker: one wire error then counts three times.

Hint 3

A flipped bit during the first 15 bits gives a wrong lock. The window rule is how the checker finds out.

What the grader checks: The fixture sends six PRBS15 streams through your functions and compares every result with a reference checker using the same rules. It does not test other polynomials or parallel checkers.

6 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

Clean Data

Input
4,000 bits of PRBS15
Expected output
mismatches = 0, errors_counted = 0

The checker locks after 15 bits and counts no error.

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

Icarus · browser samples / server checks