P11.44.1 Reassemble the Preempted Frame

HardImplementIcarus Verilog · serverReview the topic

Express frames cut into a long frame, and the pieces arrive one octet at a time. Put the frame together again, and notice every way it can go wrong.

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.

Write the receive side of the MAC Merge sublayer: Receive Processing and the Express Filter.

mm_octet is called once for each octet time. With dv = 1 it brings one octet of an mPacket.

Express frames go to the eMAC. The parts of a preemptable frame go to the pMAC, joined into one frame.

The standard gives the rules as two state diagrams. The table below has every rule.

It does not give you a structure. Which octets can you hand on at once, and which must wait?

The diagrams use a function that looks 32 bits into the future. Hardware cannot. That is the heart of this problem.

A model in three ways. The MACs get frames: no preamble, no SFD.

The pMAC's own FCS check is part of your answer: p_status reports it.

And rcv_v and rcv_r are counts here. The standard has flags.

Course choice: SMD-V and SMD-R while a frame waits are passed over, like SMD-E. Figure 99-6 has no exit for them there.

Our reading of 30.14.1.10: ass_ok counts a finished frame that had at least one continuation fragment taken.

One surprise: Figure 99-6 sets the next fragment count to 0 in IDLE_RX_PROC only.

So a frame that starts through DISCARD_KEEP_S keeps the old count. This problem follows the figure (99.4.7.1).

Take one CRC step for each octet. A CRC over the whole frame at every octet will run out of time.

You may port a CRC-32 from your answer to P11.5.1. The lesson's readable model is the transmit side only.

Signals in the Timeline

SignalWidthRole
test_number8input of each check
Full specification
The API (keep it)
// The receive side of the MAC Merge sublayer (99.4.5, 99.4.6), one call for each octet time.
bit p_valid; reg [7:0] p_data;        // this call hands one octet to the pMAC
bit p_end; reg [1:0] p_status;        // this call ends a pMAC frame. 0: FCS good. 1: FCS wrong. 2: discarded
bit e_valid; reg [7:0] e_data;        // this call hands one octet to the eMAC
bit e_end;                            // this call ends an express frame
int unsigned ass_err, smd_err, ass_ok, frag_rx;   // the four receive counters of 30.14.1.8 to 30.14.1.11
int unsigned rcv_v, rcv_r;            // verify and respond mPackets that had a correct mCRC
function automatic void mm_reset(input bit keep_s_after_d);
function automatic void mm_octet(input bit dv, input [7:0] d);
ItemRule
mm_reset(k)begin: no frame waits, every counter is 0, the four output flags are 0. k is keepSafterD until the next reset
mm_octet(dv, d)one octet time. dv = 1: d is the next octet of an mPacket. dv = 0: a gap, and d means nothing
Outputseach call sets p_valid, p_end, e_valid and e_end anew. At most one octet for each MAC in a call
Order, not timingthe octets and end marks of each MAC are graded as a sequence. They may come some calls late
Deadlineall that an mPacket causes must be out before the next mPacket starts. A gap is at least 12 calls
Octet and end in one callthe octet belongs to the frame that ends
An mPacketany number of 55h octets, even none; then the SMD; then, after an SMD-C only, the frag_count octet; then the rest
SMDTable 99-1. An octet that is neither 55h nor in the table is no SMD, however close it is to one
SMD-Eevery octet after it goes to the eMAC; e_end when the mPacket ends. Receive Processing passes it over, waiting or not
SMD-V, SMD-Rif the last four octets are the mCRC of the octets between: rcv_v or rcv_r + 1. Nothing else
SMD-S, no frame waitsa frame starts. Keep its frame count. Every octet after the SMD is data, up to the last four
The last four octetsequal to the mCRC of all data of this frame so far: the frame waits, and the four are not handed on
Else: the frame endsthe four go to the pMAC too. p_end, with p_status 0 if they are the FCS of all data before them, else 1
Fewer than four octetsan mPacket with fewer than four octets after its header ends the frame with p_status 1
mCRC (99.3.6)the CRC-32 of 3.2.9 without its last inversion, then 16 bits inverted. See the lesson for which 16
CRC registerstarts at all ones (FFFFFFFFh) for every frame, however short. A course choice: 3.2.9 does not define the CRC of fewer than four octets. The tests still send such parts, with an mCRC from this register
SMD-C, no frame waitssmd_err + 1 (BAD_FRAG). The mPacket is passed over
No SMDsmd_err + 1, and the mPacket is passed over. A frame that waits goes on waiting
SMD-C, frame waits, other frame countass_err + 1 (ASSEMBLY_ERROR). The frame is discarded: p_end with p_status 2. The mPacket is passed over
SMD-C, frame waits, same frame countfrag_rx + 1 (CHECK_FRAG_CNT). Then the frag_count octet is checked against Table 99-2
frag_count is the next onethe next count goes up by one, modulo 4. The octets after it are data of the frame
frag_count is anything elseASSEMBLY_ERROR, as above
SMD-S, frame waits, keepSafterD 1the waiting frame is discarded (p_status 2). No counter moves. The new frame starts with this mPacket
SMD-S, frame waits, keepSafterD 0ASSEMBLY_ERROR, as above. The new mPacket is passed over too
Next fragment count0 after mm_reset, after a frame ends and after ASSEMBLY_ERROR. DISCARD_KEEP_S does not change it. That is the figure as drawn and as graded. It is a likely gap in the standard: 99.4.7.3 does not define the variable
ass_ok+ 1 when a frame ends that had a continuation fragment taken. The FCS plays no part (30.14.1.10)
Counters32 bits. They never go back, and only mm_reset clears them
Sizesthe receiver checks none. The tests send short fragments too, and fragments with no data at all
Not in the testsan mPacket that ends before its SMD, or between an SMD-C and its frag_count

Random tests compare every octet, end mark and counter with a private model, mPacket by mPacket.

Examples

Example 1

One Frame, Cut Once
Input
SMD-S0 and 60 octets; an express frame; SMD-C0, frag_count 0 and the rest
Output
frames_fcs_good = 1, frames_fcs_wrong = 0, frames_discarded = 0, pmac_octets = 124, pmac_check_value = 0x74cc, express_frames = 1, emac_octets = 64, emac_check_value = 0x4, ass_err = 0, smd_err = 0, ass_ok = 1, frag_rx = 1, rcv_v = 0, rcv_r = 0

The pMAC gets all 124 octets as one frame with a good FCS. The eMAC gets 64. frag_rx and ass_ok are 1.

Example 2

A Fragment Is Lost
Input
parts with frag_count 0 and then 2
Output
frames_fcs_good = 0, frames_fcs_wrong = 0, frames_discarded = 1, pmac_octets = 120, pmac_check_value = 0x9a40, express_frames = 0, emac_octets = 0, emac_check_value = 0x0, ass_err = 1, smd_err = 0, ass_ok = 0, frag_rx = 2, rcv_v = 0, rcv_r = 0

The second continuation is not the next one. That is an assembly error: the frame is discarded after 120 octets.

Example 3

A New Frame While One Waits
Input
keepSafterD is 1
Output
frames_fcs_good = 1, frames_fcs_wrong = 0, frames_discarded = 1, pmac_octets = 134, pmac_check_value = 0x85bb, express_frames = 0, emac_octets = 0, emac_check_value = 0x0, ass_err = 0, smd_err = 0, ass_ok = 0, frag_rx = 0, rcv_v = 0, rcv_r = 0

The waiting frame is discarded and the new one is received. No counter moves.

Constraints and Contract

  • Keep the names of the API.
  • You may add variables and helper functions.
  • Declare your variables at the top of a function, not inside a loop, and do not return from inside a loop.
  • Do not call a variable cell, use, before or cross: they are reserved keywords of SystemVerilog (IEEE 1800 Annex B).
  • Off limits: the names ref_m, rng, tb, root, names that begin with fx_ and the modules of the bench.
  • The fixture's own names are off limits to keep an answer from reading the expected values.

Hints

Hint 1

When the fifth octet of data arrives, what do you know about the first one that you did not know before?

Hint 2

When dv falls, which octets have you not handed on yet? What are the three things they can be?

Hint 3

Over which octets must the CRC register have run at that moment? Which octets must it never see?

Hint 4

An express frame arrives while a frame waits. List every variable of yours that it must not touch.

Hint 5

Walk Figure 99-6 from WAIT FOR RESUME for each kind of SMD. Which arrows pass through IDLE_RX_PROC?

Hint 6

A verify mPacket has an mCRC too. Can it share a CRC register with the frame that waits?

Hint 7

Which counter moves in CHECK_FRAG_CNT, and is the frag_count known to be right at that point?

What the grader checks: A bench model of Figures 99-6 and 99-7 of IEEE Std 802.3-2022 in whole octets. The MACs get frames without preamble and SFD. The pMAC's FCS check is folded into p_status, and rcv_v and rcv_r are counts. These are course choices. So is passing over SMD-V and SMD-R while a frame waits. So is a CRC register that starts at all ones. Thirty-two scripted streams take their expected values from a JavaScript model. Thirteen more tests compare every octet, end mark and counter with a private model, on streams seeded by the judge. Transmit Processing, the Verify and Respond diagrams, minimum sizes and the eMAC's own FCS check are not graded. Nor is an mPacket that ends before its SMD.

45 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

One Frame, Cut Once

Input
SMD-S0 and 60 octets; an express frame; SMD-C0, frag_count 0 and the rest
Expected output
frames_fcs_good = 1, frames_fcs_wrong = 0, frames_discarded = 0, pmac_octets = 124, pmac_check_value = 0x74cc, express_frames = 1, emac_octets = 64, emac_check_value = 0x4, ass_err = 0, smd_err = 0, ass_ok = 1, frag_rx = 1, rcv_v = 0, rcv_r = 0

The pMAC gets all 124 octets as one frame with a good FCS. The eMAC gets 64. `frag_rx` and `ass_ok` are 1.

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

Icarus Verilog · server