P11.30.1 A 64B/66B to 257B Transcoder

MediumImplementIcarus Verilog · serverReview the topic

RS-FEC needs room for its parity. Pack four 66-bit blocks into one block of 257 bits, for every mix of data blocks, control blocks and broken sync headers.

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.

to257 gets four 66-bit blocks and returns one 257-bit block. Block 0 arrived first.

Four data blocks are the simple case. Bit 0 is 1, and the four payloads follow, 256 bits in all.

With a control block in the group, bit 0 is 0. Bits 1 to 4 hold one flag per block: its second sync bit.

That costs four more bits. So the first control block gives up the second nibble of its block type field.

If any sync header is invalid, 00 or 11, all four flags are 1. The nibble is then taken from block 0.

Last, when hdr_xor is 1, XOR the first five bits with bits 12 to 8. Clause 91 does that; Clause 119 does not.

Two things are course choices. The four blocks come as one 264-bit vector whose bit 0 is sent first.

And one function serves both clauses, with hdr_xor as the switch. The standard describes two transcoders.

The lesson shows this transcoder only as tables of results. The readable eth_xc_type is the receive side's lookup. The whole of to257 is graded.

Signals in the Timeline

SignalWidthRole
test_number8input of each check
Full specification
Signature (keep it)
function automatic [256:0] to257(input [263:0] blocks, input bit hdr_xor);
ItemRule
blocksa course choice of layout: block j is bits 66j to 66j + 65, and bit 0 is sent first. A block is two sync bits, then 64 payload bits
Data blocksync bits 0 then 1. Control block: 1 then 0. Invalid: 00 or 11
Four data blocksbit 0 = 1. Bits 1 to 256: the payloads of blocks 0 to 3, in order (91.5.2.5 a, b)
All valid, a control blockbit 0 = 0. Bit j + 1 = the second sync bit of block j. Then the 256 payload bits, less one nibble (a1 to e1)
The nibble left outpayload bits 4 to 7 of the first control block: the second nibble of its block type field
Any invalid sync headerbit 0 = 0, bits 1 to 4 = 1111. Payload bits 4 to 7 of block 0 are left out, whatever block 0 is (a2 to d2)
hdr_xor = 1after all that, bits 0 to 4 are XORed with bits 8 to 12, bit 0 with bit 8 (a3). The other bits stay
hdr_xor = 0no XOR: the Clause 119 transcoder, whose scrambler comes after it (119.2.4.2)

Some hidden tests are groups of Annex 91A of IEEE Std 802.3-2022, checked against the rows of its Table 91A-2.

Examples

Example 1

Four Data Blocks
Input
payloads 0123456789abcdefh, 1122334455667787h, a5a5a5a55a5a5a5ah, fedcba987654321eh; `hdr_xor` = 0
Output
first_five_bits_in_sending_order = 'b11111, bits_5_to_20_in_sending_order = 0x7b3d, last_16_bits_in_sending_order = 0x3b7f, xor_of_all_32_bit_slices = 0x77777664

Bit 0 is 1. The payloads follow from bit 1, so the first five bits are 1 and then four payload bits.

Example 2

Data, Control, Data, Data
Input
block 1 is a control block; `hdr_xor` = 0
Output
first_five_bits_in_sending_order = 'b01011, bits_5_to_20_in_sending_order = 0x1e96, last_16_bits_in_sending_order = 0xeac8, xor_of_all_32_bit_slices = 0xaaaaaa50

Bit 0 is 0. The flags are 1, 0, 1, 1: block 1 is the control block. Its payload bits 4 to 7 are left out.

Example 3

Four Idle Blocks from Annex 91A
Input
the first row of Table 91A-1; `hdr_xor` = 1
Output
first_five_bits_in_sending_order = 'b00101, bits_5_to_20_in_sending_order = 0xa5a3, last_16_bits_in_sending_order = 0x638, xor_of_all_32_bit_slices = 0x9967fd62

Before the XOR the first five bits are 00000. Bits 8 to 12 are 0, 0, 1, 0, 1. So 00101 is sent, as the annex shows.

Constraints and Contract

  • Keep the name and the arguments of to257.
  • It is a pure function: keep no state.
  • Do not look at the block type field. The transcoder moves bits and never checks them.
  • Off limits: the names lib, rng, tb, root, names that begin with fx_ and the modules of the bench.

Hints

Hint 1

Collect the 256 payload bits in one vector first. Every case copies from it.

Hint 2

With the first control block at c, the nibble left out is payload bits 64c + 4 to 64c + 7.

Hint 3

Check the invalid case before you look for the first control block.

Hint 4

Do the XOR last, on the finished block. It applies to a group of four data blocks too.

What the grader checks: The fixture checks 20 fixed groups and 900 random ones. Fixed groups are checked against an independent JavaScript model, random ones bit for bit against a private transcoder. Four fixed groups are rows of Annex 91A of IEEE Std 802.3-2022, with the annex's own rows as the expected result. Random groups carry all four sync values. The one-vector layout and the hdr_xor switch are course choices. The receive transcoder, the scrambled block type nibble and the Reed-Solomon code are not graded.

23 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

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

Four Data Blocks

Input
payloads 0123456789abcdefh, 1122334455667787h, a5a5a5a55a5a5a5ah, fedcba987654321eh; `hdr_xor` = 0
Expected output
first_five_bits_in_sending_order = 'b11111, bits_5_to_20_in_sending_order = 0x7b3d, last_16_bits_in_sending_order = 0x3b7f, xor_of_all_32_bit_slices = 0x77777664

Bit 0 is 1. The payloads follow from bit 1, so the first five bits are 1 and then four payload bits.

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

Icarus Verilog · server