A 64b/66b receiver gets bits with no marks. Write the machine that finds the block boundary, keeps it through one bad header and drops it when the stream slips.
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 receiver gets 64b/66b line bits one at a time. Each block is a two-bit sync header and a 64-bit payload. A valid header is 01 or 10. The receiver does not know where a block starts.
Write bl_push(b). Treat every 66 bits as a candidate block and check its first two bits. Slip the boundary on an invalid header until you have seen many valid headers in a row. Then declare lock.
Once locked, deliver every block with a valid header. One bad header is a bit error: keep the lock. Several bad headers in a short time mean the boundary moved: drop the lock and hunt again.
Also write bl_reset(), which forgets everything. The tests call it before each stream.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
test_number | 8 | input of each check |
Full specification
function automatic void bl_reset();
function automatic [1:0] bl_push(input bit b); // returns {locked, deliver}
| Item | Rule |
|---|---|
| Candidate block | Every 66 bits from the start, or from the last slip. Its header is its first two bits, in the order received. |
| Check | On the 66th bit of a candidate. Every other call returns {locked, 0}. |
| Before lock, valid header | Count it. On the 16th valid header in a row, set locked. That block is not delivered. |
| Before lock, invalid header | Clear the count and slip: the next candidate starts one bit later, so it is checked 67 bits after this one. |
| Once locked | Count each block in a window of 16 blocks, and count its header if it is invalid. A window starts at lock and restarts after its 16th block. |
| Losing lock | On the 4th invalid header in one window, clear locked and the count, and slip. That block is not delivered. |
| Deliver | A locked block with a valid header returns deliver = 1. A locked block with an invalid header returns 0. |
locked in the result | The state after this bit. |
The counts 16, 4 and 16 are this problem's bench values. P10.4 used 64 and 16 in 64. No document in our library gives IEEE 802.3's counts, so neither is quoted as the standard's.
The tests send random payload after a random number of lead-in bits. They compare your result on every bit with a reference machine that follows the rules above.
Examples
Example 1
Starts on a Block Boundary- Input
no lead-in bits; clean blocks
- Output
mismatches = 0, reference_locked = yes
Every check sees a valid header. The 16th one sets locked on bit 16 × 66 = 1,056. Every later block is delivered.
Example 2
Starts 29 Bits Late- Input
29 lead-in bits, then clean blocks
- Output
mismatches = 0, reference_locked = yes
Random payload bits pass the check about half the time. Each invalid header slips one bit, so the machine needs 29 slips before it sits on the real boundary.
Example 3
One Header Hit by a Bit Error- Input
lock, one flipped header bit, 60 clean blocks
- Output
mismatches = 0, reference_locked = yes
One invalid header in a window is far below 4. The machine stays locked and skips only that one block.
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
bl_reset(). - Use the three bench values as given.
Hints
Hint 1
You need a bit counter for the current candidate. A slip is just one extra bit before the next check.
Hint 2
Two counts matter before lock and two after it. Which of them must go back to zero on an invalid header, and which must not?
Hint 3
The window restarts every 16 locked blocks, whatever the headers were. Without that restart, rare single errors add up and drop the lock.
What the grader checks: The fixture sends 18 bit streams through your two functions. On every bit it compares your result with a reference block-lock machine that uses the same rules. It models no descrambling, no 128b/130b layout and no IEEE 802.3 state names.
18 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