P11.40.1 Verify the Statistics Block

HardVerifyIcarus Verilog · server36 hidden designsReview the topic

A port's statistics block counts frames, PCS errors and FEC results, and a station reads it. Write the checker that knows what every read must return.

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 block under test is the management side of one model port. It holds three groups of numbers.

Group one is the MAC: 17 counters for frames sent and received, and for MAC Control and PAUSE frames.

Group two is a 10GBASE-R PCS (Clause 49): four status registers with latched bits and two small counters.

Group three is a four-lane Clause 91 RS-FEC: six counters of 32 bits, each read as two registers.

This is a teaching model. No real PHY has this pair: Clause 91 belongs to 100GBASE-R (P11.32).

The model shows both kinds of register in one place.

Your checker is told every event: a frame, a step of the PCS, a step of the decoder, a read.

For a read it also gets the value the block returned. It must know what that value should be.

The fixture runs your checker on a correct block and on 36 hidden broken ones. Each run has about 1,700 events.

The last run is the correct block again, on other events.

Stay silent on the correct block. Raise the alarm on every broken one.

The 38 runs are separate simulations that share one time budget.

So update your counters at each event. Do not recount a log at every read.

Some broken blocks are wrong after one kind of frame, others only after a certain order of reads.

The lesson has the rule for each frame. The table below names the clauses.

Choices of the model are marked "course choice" in the table.

Signals in the Timeline

SignalWidthRole
hidden_block8input of each check
Full specification
Signatures (keep them)
function automatic void chk_reset(input int width, input bit promiscuous);
function automatic void chk_tx(input int n, input int da, input [15:0] lt, input [15:0] opcode);
function automatic void chk_rx(input int n, input bit fcs_ok, input int da, input [15:0] lt, input [15:0] opcode);
function automatic void chk_pcs(input bit block_lock, input bit hi_ber, input int bad_sh, input int rx_e);
function automatic void chk_fec(input bit align, input int unsigned corrected, input int unsigned uncorrected, input [127:0] symbols);
function automatic void chk_read(input int id, input [31:0] value);
function automatic bit  chk_alarm();   // 1 = alarm
ItemMeaning
chk_reseta reset of the block. Every counter is zero. The PCS has block lock and no high BER, and no bit is latched. Course choice: this start state. A real PCS leaves reset without block lock (Figure 49-14), so its latched bits would show a loss at the first read
widthcourse choice: the MAC counters are width bits wide, so that a run can wrap them. The tests use 32 and 4 to 12. The standard's counters are 32 bits (5.2.4.4)
promiscuous1: the MAC takes frames for every address (30.3.1.1.16)
nthe octets of the frame, from the destination address to the FCS
fcs_ok1 if the FCS matched. There are no extra bits after the last octet
dathe destination address. 0: this station. 1: broadcast. 2: a group address on this station's list. 3: a group address not on the list. 4: another station. 5: 01-80-C2-00-00-01, which this station always takes
lt, opcodethe Length/Type field, and the opcode of a MAC Control frame. opcode means nothing for other frames
chk_txthe MAC has sent this frame without an error. The link is full duplex
chk_pcsone step of the PCS. block_lock and hi_ber are its two variables now. In this step BER_BAD_SH was entered bad_sh times and RX_E rx_e times (49.2.14.2)
chk_fecone step of the decoder. corrected and uncorrected count codewords. symbols holds the symbols corrected on FEC lanes 0 to 3, with lane 0 in symbols[31:0]
alignthe FEC lanes are aligned in this step (91.6.16)
chk_readthe station read id, and the block returned value
idIt isClause
0aFramesTransmittedOK30.3.1.1.2
1aOctetsTransmittedOK30.3.1.1.8
2aMulticastFramesXmittedOK30.3.1.1.18
3aBroadcastFramesXmittedOK30.3.1.1.19
4aFramesReceivedOK30.3.1.1.5
5aOctetsReceivedOK30.3.1.1.14
6aMulticastFramesReceivedOK30.3.1.1.21
7aBroadcastFramesReceivedOK30.3.1.1.22
8aFrameCheckSequenceErrors30.3.1.1.6
9aInRangeLengthErrors30.3.1.1.23
10aOutOfRangeLengthField30.3.1.1.24
11aFrameTooLongErrors30.3.1.1.25
12aMACControlFramesTransmitted30.3.3.3
13aMACControlFramesReceived30.3.3.4
14aUnsupportedOpcodesReceived30.3.3.5
15aPAUSEMACCtrlFramesTransmitted30.3.4.2
16aPAUSEMACCtrlFramesReceived30.3.4.3
3001register 3.1. Bit 2: PCS receive link status, latching low. Bit 7: fault45.2.3.2
3008register 3.8. Bit 10: receive fault, latching high45.2.3.7
3032register 3.32. Bit 0: block lock. Bit 1: high BER. Bit 12: receive link status. All three live45.2.3.15
3033register 3.33. Bit 15: latched block lock. Bit 14: latched high BER. Bits 13:8: BER counter. Bits 7:0: errored blocks counter45.2.3.16
1202, 1203corrected codewords: lower and upper 16 bits45.2.1.118
1204, 1205uncorrected codewords: lower and upper45.2.1.119
1210 to 1217symbol errors of FEC lanes 0 to 3: lower, upper, lower, upper and so on45.2.1.121, 45.2.1.122
ItemRule
MAC countersas 5.2.4.2 and 5.2.4.3 update them. They wrap (5.2.4.4), and a read changes nothing (30.3.1)
Size limitcourse choice: this MAC takes basic frames only, so more than 1,518 octets is too long. 4.2.9 recommends the envelope limit of 2,000
Length/Type 1,501 to 1,535course choice, as in P11.8: a length error, counted out of range
Group address not on the listcourse choice: in promiscuous mode it is received and counts as multicast. The two clauses differ. 5.2.4.3 tests only the address. 30.3.1.1.21 speaks of an active group address and could be read the other way. The tests take the reading of 5.2.4.3
MAC Controlthis device supports the PAUSE opcode, 0001h, and no other. The tests use 0001h, 0002h and 0101h, and send such frames to da 0 or 5 only
Receive link statusblock lock and no high BER (49.2.14.1). Bit 3.32.12 shows it live
Receive faultthe inverse of the receive link status. No transmit fault exists in this model
Latched bitsthe rule of 45.2. Bit 3.1.7 is not a latch of its own: it reads as bit 3.8.10 would (45.2.3.2.5)
PCS counters6 bits and 8 bits. They stop at all ones, as this model has no registers 3.44 and 3.45 (45.2.3.16). A read of register 3.33 clears them (49.2.14.2)
Legal stepswithout block lock, hi_ber and bad_sh are 0. While the receive link is down, rx_e is 0
FEC counters32 bits. They count only while align is 1, and stop at all ones
Reading an FEC countera read of the lower register returns the lower half, latches the upper half and clears the counter. A read of the upper register returns the latched half (45.2.1.118)
The latched upper halfcourse choice: it keeps its value until the lower register is read again. After a reset it is zero
Other bitscourse choice: every bit not named here reads 0. A real device also sets its device-present and ability bits in registers 3.1 and 3.8 (45.2.3.7.1)

The fixture calls chk_reset three times in a run. Each time the block is reset too, with a new width.

You may reuse your answer to P11.8.1 for the receive status.

The MDIO model of P11.16 shows one latched bit and one counter that clears. That idea is free too.

No file of the bench holds the counter model itself.

The clause numbers are those of IEEE Std 802.3-2022.

Examples

Example 1

The Correct Block
Input
About 1,700 events in three parts: scripted sequences with random events between them, counters that wrap, and a promiscuous part
Output
alarm = no

Every read returns what the rules give. A received PAUSE frame moves five counters, and a frame for another station moves none.

Example 2

A Broken Block
Input
The same kind of run through one hidden broken block
Output
alarm = yes

A frame of fewer than 64 octets with a good FCS is counted as received.

Example 3

A Different Broken Block
Input
The same kind of run through one hidden broken block
Output
alarm = yes

A frame with a bad FCS that is not for this station is counted as an FCS error.

Constraints and Contract

  • Keep the seven function names and their arguments.
  • Keep your state in module-level variables, and clear it in chk_reset().
  • Judge the block by the values it returns. The fixture's own instances are off limits.
  • Off limits: the names block_under_test, result, run_design, run_case, run_again, rng, tb, root, names that begin with fx_ and the modules of the bench.

Hints

Hint 1

Start with one question for each frame: does it get a status at all? Two kinds of frame get none.

Hint 2

A received PAUSE frame is a good frame first. Count how many counters it moves.

Hint 3

For a latched bit, ask what a second read returns while the cause is still there.

Hint 4

Reading one register must not disturb another. Check each read against every other value you hold.

Hint 5

One broken block is wrong at a single read of the whole run. Raise the alarm at the first mismatch.

What the grader checks: The fixture runs your checker on a private statistics model: a correct block and 36 fault switches. Each run has about 1,700 events in three parts. Each part starts with a reset and a new counter width, and reads every value once straight after it. Part one holds 28 scripted sequences, each of them twice, with random events between them. Part two walks narrow counters through their wrap. Part three is promiscuous. The correct block runs twice. On a full check the random events change with every submission, and the scripted sequences come in another order. The block is a model of one port: MAC counters of a chosen width, a 10GBASE-R PCS and a Clause 91 RS-FEC. No real PHY has that pair. It is driven by events, not by frames on a wire. Half-duplex counters, alignment errors, the transmit fault, EEE status bits and the BIP counters are not graded.

38 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

The Correct Block

Input
About 1,700 events in three parts: scripted sequences with random events between them, counters that wrap, and a promiscuous part
Expected output
alarm = no

Every read returns what the rules give. A received PAUSE frame moves five counters, and a frame for another station moves none.

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

Icarus Verilog · server