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
| Signal | Width | Role |
|---|---|---|
test_number | 8 | input of each check |
Full specification
function automatic void pc_reset();
function automatic [1:0] pc_push(input bit b); // returns {locked, error}
| Item | Rule (bench values) |
|---|---|
| Lock | Copy 15 received bits, the oldest first. On the 15th, set locked. That bit returns {1, 0}. |
| Predict | The 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. |
| Error | A locked bit that differs from the prediction returns error = 1. |
| Window | Count bits and errors in windows of 64 locked bits. The first window starts at lock. |
| Relock | On 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