The USB 3.2 Gen 1 scrambler steps once per bit. Write the version that takes 32 data bits and the register in one call, as wide RTL does.
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.
At 5 Gb/s the scrambler cannot step once per bit clock. Real RTL steps it 32 times in one cycle.
Write scr32(s, d). It takes the 16-bit register s and 32 data bits d, and returns the register after 32 steps and the 32 scrambled bits. Data bit 0 is scrambled first.
The tests compare your function with the library's serial scrambler on random inputs. They also check the first key bytes USB 3.2 prints.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
test_number | 8 | input of each check |
Full specification
function automatic [47:0] scr32(input [15:0] s, input [31:0] d); // returns {s_next, d_out}
| Item | Rule |
|---|---|
| Key bit | s[15], before each step. |
| One step | Shift left by one; if s[15] was 1, XOR 0039h in (x^16 + x^5 + x^4 + x^3 + 1). |
| Bit order | Bit i of d is XORed with the key bit after i steps. Byte 0 is d[7:0], sent first. |
| Result | {the register after 32 steps, d_out[31:0]}. |
From the seed FFFFh with zero data, the key stream starts FF 17 C0 14 B2 E7 02 82 (USB 3.2 §6.8.4.1). With byte 0 in d[7:0] the first word is 14C017FFh.
Examples
Example 1
The First Two Key Words- Input
seed FFFFh, zero data
- Output
word_0 = 0x14c017ff, word_1 = 0x8202e7b2
Zero data XOR the key is the key. USB 3.2 prints FF 17 C0 14 B2 E7 02 82; byte 0 is the low byte of each word.
Example 2
Random States and Data- Input
2,000 calls
- Output
wrong_calls = 0
Each call must match 32 serial steps of the library scrambler, data and register both.
Example 3
Another Seed- Input
2,000 calls
- Output
wrong_calls = 0
A second set of random states and data. Both the scrambled bits and the returned register must match on every call.
Constraints and Contract
- Keep the function name, the arguments and the 48-bit result.
- A loop of 32 steps or derived XOR equations are both fine: synthesis unrolls the loop into the same network.
Hints
Hint 1
Step the register once per data bit, in order from bit 0.
Hint 2
Byte 0 is the low byte, and within it bit 0 goes first.
Hint 3
The returned register is the one after all 32 steps, ready for the next word.
What the grader checks: The fixture checks the first two key words against the bytes USB 3.2 prints. It checks 4,020 more calls against the library's serial scrambler. It does not check reset, SKP or COM handling.
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