A MAC works 32 bits at a time; a 40 Gb/s PCS wants 64-bit columns with Start on lane 0. Build the RS between them, one word at a time.
Hardware context: An Ethernet MAC and physical coding sublayer: frame builder and checker, reconciliation sublayer and block encoder. Build, check and pace Ethernet frames, and code them for the physical layer as IEEE 802.3 specifies.
The MAC hands over four characters per call: Start, preamble, SFD, frame, Terminate, then at least 11 idles. It does not align anything.
Write rs_in and rs_flush. Collect characters into an 8-lane column. Hand the column out on the call that completes it. Every Start must leave on lane 0.
Keep the average gap at 12 with the deficit idle count, bounded 0 to 7. At the end of the stream, pad the last column with idle.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
test_number | 8 | input of each check |
Full specification
bit [8:0] hold [0:7]; int nh; // the column being built
int dic;
function automatic void rs_reset();
function automatic [72:0] rs_in(input [35:0] x); // {c[3:0], d[31:0]} in; {ready, c[7:0], d[63:0]} out
function automatic [72:0] rs_flush();
| Rule (this problem) | Value |
|---|---|
| Characters | Start = 1FBh, Terminate = 1FDh, Idle = 107h; data has the control bit 0 |
| Start that would land on lane m (not 0) | delete the m idles if the count stays within 0 to 7. Otherwise insert idle up to the next lane 0 |
| Count | each idle deleted adds 1; each idle inserted takes 1 away |
| Output | one column on the call that completes it, else 0; rs_flush hands out the last part column, padded with idle |
| rs_reset | an empty column and dic = 0 |
Every Start has at least 11 idles in front of it, except the first, which may have 0 to 7. 81.3.1.4 also allows a MAC that always inserts. This problem uses the deficit idle count.
Examples
Example 1
Eight Sizes- Input
64, 65, 66, 67, 68, 69, 70, 64 octets
- Output
calls_differing_from_a_correct_rs = 0, output_columns = 87, final_count = 1, idle_characters = 91, starts_off_lane_0 = 0
The Starts would land on lanes 0, 4, 5, 6, 7, 0, 1 and 2; lane 3 never comes up here. Some need deletions, some insertions.
Example 2
Already Aligned- Input
six 68-octet frames
- Output
calls_differing_from_a_correct_rs = 0, output_columns = 66, final_count = 0, idle_characters = 66, starts_off_lane_0 = 0
A 68-octet frame with its gap is 88 characters: eleven whole columns. Nothing moves.
Example 3
Seven Lanes Late, Again and Again- Input
six 67-octet frames
- Output
calls_differing_from_a_correct_rs = 0, output_columns = 66, final_count = 3, idle_characters = 72, starts_off_lane_0 = 0
87 mod 8 = 7, so each Start would land on lane 7. The RS deletes 7 idles once; after that it inserts one idle each time, and the count falls by 1.
Constraints and Contract
- Keep the names and widths; you may add variables.
- Only idles may be deleted or inserted; every other character keeps its order.
- Return 0 on a call that completes no column.
- Off limits: the names
rng,tb,root, names that begin withfx_and the modules of the bench.
Hints
Hint 1
Where would the next Start land? Look at nh, not at the lane of the MAC word.
Hint 2
Which choice is legal when dic + m is exactly 7? And at 8?
Hint 3
Can one call ever complete two columns? Compare the count of characters out with the count in.
What the grader checks: The fixture checks seven literal streams against an independent JavaScript model. It compares every call with a second JavaScript model of the RS, through a digest of each result and count. It also checks 50 random streams of 30 frames, every call in one digest per stream. Sequence ordered sets and Error characters are not in the streams.
9 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 1 steps and the final capstone