P10.5.1 Break the Self-Synchronising Scrambler

EasyBreak ItIcarus · browser samples / server checksReview the topic

A scrambler is meant to keep the line busy. Choose the data so that the line stops toggling for more than 60 bits.

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.

This is a Break It problem. The scrambler is correct. Your job is to write the stimulus that defeats it.

A link scrambles with x^58 + x^39 + 1. Each line bit is the data bit XOR the line bits sent 39 and 58 steps earlier. The clock recovery on the far side loses lock after 60 equal bits.

Write next_data(line_history). The fixture calls it once per bit, 400 times, and passes the last 58 line bits. Bit 0 is the newest. You pass when the line shows a run of more than 60 equal bits.

Random data will not do it. The last 58 line bits are on the wire for anyone to see, and they are the whole state of the scrambler.

Signals in the Timeline

SignalWidthRole
test_number8input of each check
Full specification
Signature (keep it), and what the scrambler does with your bit
function automatic bit next_data(input [57:0] line_history);

// each step, inside the fixture:
//   line_bit     = next_data(line_history) ^ line_history[38] ^ line_history[57];
//   line_history = {line_history[56:0], line_bit};

The fixture runs four starts: an all-zero history, an all-one history and two mixed ones. Each start runs 400 bits.

A run is a group of equal line bits in a row. The result is 1 when the longest run is over 60.

Your function sees only the line history. It has no state of its own between calls.

Examples

Example 1

Mixed History
Input
the history starts as alternating bits
Output
run_over_60 = yes

The reference stimulus cancels both taps, so every line bit is 0. The run reaches 400.

Example 2

All-One History
Input
the history starts as 58 ones
Output
run_over_60 = yes

The two tapped bits are equal, so the data bit is 0 and the line bit is 0. The line then stays at 0.

Example 3

Another Mixed History
Input
the history starts as a fixed mixed pattern
Output
run_over_60 = yes

The same rule works from any start, because the fixture hands you the full state.

Constraints and Contract

  • Keep the function name and its argument.
  • Return one data bit per call.
  • The function must be pure: it may read only line_history.

Hints

Hint 1

What data bit makes the next line bit a 0, whatever the history holds?

Hint 2

XOR is its own inverse. If the scrambler adds two history bits to your data bit, you can add them first.

Hint 3

After 58 line bits of the same value the history is constant. What does your function return from then on?

What the grader checks: The fixture runs your stimulus against one scrambler model from four start states and measures the longest run in 400 bits. It does not model a clock recovery loop.

4 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 3 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

Mixed History

Input
the history starts as alternating bits
Expected output
run_over_60 = yes

The reference stimulus cancels both taps, so every line bit is 0. The run reaches 400.

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

Icarus · browser samples / server checks