A deserializer cuts every ten bits from wherever it started. Write the aligner that moves the cut to the comma.
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 8b/10b line bits one at a time, with no mark where a code starts. Before the first code the line carries idle bits.
Write align_push(b). Watch the bits for a comma: 0011111 or 1100000. A comma is the first seven bits of a K28.5 code. Once you have seen one, deliver every following group of ten bits as one code, starting with the K28.5 itself.
Align once. After that, ignore any comma pattern you see. Some symbol pairs, such as K28.7 then D12.0, form a comma across a code boundary.
Also write aligner_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 aligner_reset();
function automatic [10:0] align_push(input bit b); // returns {valid, code[9:0]}
| Item | Rule |
|---|---|
| Bit order | Bit a of a code arrives first and ends up in code[9]. |
| Comma | The last seven bits received are 0011111 or 1100000, the first bit received on the left. |
| First code | The comma plus the next three bits: return it with valid = 1 on its tenth bit. |
| Later codes | Every tenth bit after that completes one code. |
| Other calls | Return valid = 0. The code bits are then ignored. |
| After alignment | Comma patterns change nothing. Only aligner_reset() starts a new search. |
The tests compare the codes you deliver with the codes sent, in order, from the first K28.5. Some streams send data before that first K28.5: deliver nothing for it. K28.5 then repeats every 50 symbols.
Examples
Example 1
Starts on a Code Boundary- Input
no idle bits, 100 symbols from K28.5
- Output
wrong_codes = 0, codes_delivered = 100
The comma ends on bit 7. Three more bits complete K28.5, the first code. All 100 codes come out as sent.
Example 2
Seven Idle Bits First- Input
7 idle bits, then 100 symbols
- Output
wrong_codes = 0, codes_delivered = 100
The idle bits hold no comma. The search skips them, and the first code is still the K28.5.
Example 3
K28.7 Then D12.0 in the Data- Input
200 symbols with a K28.7 D12.0 pair every ten symbols
- Output
wrong_codes = 0, codes_delivered = 200
K28.7 followed by D12.0 holds a comma pattern that crosses the boundary. An aligner that moves on it loses the codes after it.
Constraints and Contract
- Keep both function names, the argument and the 11-bit result.
- Keep your state in module-level variables, and clear it in
aligner_reset(). - Return one code per ten bits once aligned, never more.
Hints
Hint 1
Keep the last ten bits in a shift register, with the newest bit at the bottom.
Hint 2
When the comma is complete, how many bits of the K28.5 are still to come? Count them down.
Hint 3
A K28.5 sent at RD+ starts with the inverse comma. Your test must accept both forms.
What the grader checks: The fixture sends 19 bit streams through your two functions and compares the delivered codes with the codes sent. It models no clock recovery, bit errors or realignment after errors.
19 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