P11.25.1 A PRBS31 Checker

MediumImplementIcarus Verilog · serverReview the topic

A link test sends a pattern that both ends know. Build the receiving end: a checker that needs no start signal and counts every bit that does not fit.

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 bench calls prbs_check once for every received bit. Return the PRBS31 pattern error signal for that bit.

The checker is self-synchronising. It has no generator of its own that must be put in step. It tests each bit against the 31 bits that came before.

It also keeps the test-pattern error counter: one count for each bit time the error signal is high. The counter has 16 bits and stops at FFFFh.

The transmitter sends the pattern of Figure 49-9: the lesson's eth_prbs31. Read that generator first. The checker follows from it.

Two things are course choices. prbs_clear() is how the fixture starts a test, and reading the counter does not clear it. A real PCS clears the counter when it is read.

The fixture never looks at the first 31 results after a clear, because the standard gives the register no start value.

The generator is readable in the lesson's library. The checker is not: it is what this problem grades.

Signals in the Timeline

SignalWidthRole
test_number8input of each check
Full specification
Signatures (keep them)
function automatic void prbs_clear();
function automatic bit prbs_check(input bit b);
function automatic [15:0] prbs_errors();
ItemRule
CheckerFigure 49-11. It has 31 stages. Derive what it tests from the generator of Figure 49-9, the lesson's eth_prbs31
A clean patternthe error signal is 0 for every bit, once 31 bits are in
One wrong bit, alonethe error signal is 1 three times
Counterplus one for each bit whose error signal is 1. It stops at FFFFh and stays there
prbs_errors()reads the counter and does not clear it. A course choice: a real PCS clears it on read (45.2.3.20)
prbs_clear()the counter is 0. The register contents after it are yours to choose

The checker is Figure 49-11 of IEEE Std 802.3-2022, with the counter of 49.2.12 and 49.2.14.2.

The fixture sends 31 bits after every clear before it looks at a result.

Examples

Example 1

One Bit Flipped
Input
400 pattern bits, bit 101 flipped
Output
errors_counted = 3, first_flagged_bit = 101, second_flagged_bit = 129, third_flagged_bit = 132, last_flagged_bit = 132

The bit is flagged when it arrives. It is flagged twice more, each time it is used to test a later bit.

Example 2

Two Bits Flipped, 28 Apart
Input
400 pattern bits, bits 101 and 129 flipped
Output
errors_counted = 4, first_flagged_bit = 101, second_flagged_bit = 132, third_flagged_bit = 157, last_flagged_bit = 160

Bit 129 is wrong, and so is the older bit it is tested against. The two cancel, so bit 129 is not flagged. Four flags are left.

Example 3

The Pattern Without Its Inverter
Input
400 bits of the pattern, sent not inverted
Output
errors_counted = 400, first_flagged_bit = 1, second_flagged_bit = 2, third_flagged_bit = 3, last_flagged_bit = 400

Three inverted bits are XORed for each test, so the result is inverted too. Every bit is flagged.

Constraints and Contract

  • Keep the three function names and their arguments.
  • Keep your state in module-level variables.
  • Shift in the bit you received, not the bit you expected.
  • Off limits: the names lib, rng, tb, root, names that begin with fx_ and the modules of the bench.

Hints

Hint 1

The generator puts a new bit into stage 0 from two of its stages. Where are those two bits in the stream the checker has already seen?

Hint 2

A clean pattern gives 400 flags in 400 bits. What is missing at the input?

Hint 3

One flipped bit is flagged three times. Why would a checker that corrects the bit before it stores it flag it once only?

What the grader checks: The fixture checks 12 scripted streams against an independent JavaScript model, and one counter run. It checks 240 random streams against a private reference checker. The first 31 results after prbs_clear() are never looked at, so the register's start value is not graded. prbs_clear() is a fixture choice; the counter's clear-on-read, the pseudo-random checker and the MDIO registers are not graded.

15 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 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

One Bit Flipped

Input
400 pattern bits, bit 101 flipped
Expected output
errors_counted = 3, first_flagged_bit = 101, second_flagged_bit = 129, third_flagged_bit = 132, last_flagged_bit = 132

The bit is flagged when it arrives. It is flagged twice more, each time it is used to test a later bit.

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

Icarus Verilog · server