The transcoder hands over 32 words of 65 bits. Add the 32 parity bits and the PN-2112 pattern, so that the block is ready for the line.
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.
fec_block gets the 2,080 bits of 32 transcoded words, in sending order. It returns the FEC block of 2,112 bits.
First the parity. Take the 2,080 bits as a polynomial m(x), with the first bit sent as the highest power of x.
The parity is the remainder of x^32 · m(x) divided by g(x). Its 32 bits follow the words, highest power first.
Then PN-2112. XOR every bit of the block, parity included, with the next bit of the pattern. The pattern starts again for every block.
The words themselves go out unchanged under the pattern: the code is systematic.
One thing is a course choice: a block is one vector whose bit 0 is sent first.
The lesson shows this encoder only as tables of results. The one readable model, eth_fec74_lock, holds no parity and no pattern. The whole of fec_block is graded.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
test_number | 8 | input of each check |
Full specification
function automatic [2111:0] fec_block(input [2079:0] words);
| Item | Rule |
|---|---|
words | bit 0 is sent first. Word k is bits 65k to 65k + 64; its transcode bit is the lowest of them |
| Result | bits 0 to 2,079: the words. Bits 2,080 to 2,111: the parity. Then all of it XORed with PN-2112 |
| g(x) | x^32 + x^23 + x^21 + x^11 + x^2 + 1 (Equation 74-1) |
| Parity | p(x) = x^32 · m(x) mod g(x) (Equation 74-2). No seed of ones and no inversion: this is not the frame check sequence |
| Order | the first bit sent is the highest power of x, for the words and for the parity. Annex 74A's worked example fixes this |
| PN-2112 register | 58 stages, S0 to S57. Start state: S57 = 1, S56 = 0, S55 = 1, and so on down to S0 = 0 |
| PN-2112 step | the output bit is S38 XOR S57. It is also shifted into S0, and every stage moves up by one (Figure 74-8) |
| Restart | the register is set to its start state before every block (74.7.4.4.1) |
One hidden test is the worked example of Annex 74A of IEEE Std 802.3-2022. Its parity is D96E7685 in sending order.
Examples
Example 1
All-Zero Words- Input
all 2,080 bits are 0
- Output
parity_in_sending_order = 0x0, payload_bits_wrong_after_undoing_pn = 0, first_16_bits_as_sent = 0xffff
The remainder of zero is zero, so the parity is 00000000. The block that goes out is PN-2112 itself: it starts with ones.
Example 2
Only the Last Bit Set- Input
bit 2,079 is 1
- Output
parity_in_sending_order = 0xa00805, payload_bits_wrong_after_undoing_pn = 0, first_16_bits_as_sent = 0xffff
m(x) is 1, so the parity is x^32 mod g(x): the lower terms of g(x), 00A00805.
Example 3
Only the First Bit Set- Input
bit 0 is 1
- Output
parity_in_sending_order = 0xa7c00d3e, payload_bits_wrong_after_undoing_pn = 0, first_16_bits_as_sent = 0x7fff
m(x) is x^2079. The same single bit, 2,079 places earlier, gives a parity with no visible pattern.
Constraints and Contract
- Keep the name and the argument of
fec_block. - Do the division and the pattern yourself: the bench library's CRC model is not allowed here.
- A call must not depend on the calls before it.
- Off limits: the names
lib,rng,tb,root, names that begin withfx_and the modules of the bench.
Hints
Hint 1
Parity first, on the plain words. Check it with the sample that has one bit set: the last bit of the last word.
Hint 2
A division by g(x) is a 32-bit shift register. One bit in, one shift, and an XOR with g(x) when the top bit and the input differ.
Hint 3
For the pattern, write down the first three output bits by hand from the start state.
What the grader checks: The fixture checks eight fixed blocks against an independent JavaScript model, and 40 random ones bit for bit against a private encoder. One fixed block is the worked example of Annex 74A, whose parity is the standard's: D96E7685. Two tests send two blocks in a row and check the second. The fixture takes PN-2112 off with its own generator before it shows the parity. The vector layout is a course choice. The transcoder, the decoder, burst correction and the FEC lock are not graded here.
10 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 5 steps and the final capstone