Give every received frame its one receive status, in the order 802.3 checks them, and say how many octets the client gets.
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.
A receive MAC must give each frame exactly one status, and its management counters depend on it. Several faults can hit one frame, so the order of the checks decides.
Write classify. It sees the whole octets that arrived in rx_oct, the extra bits after them, and the size limit this MAC uses.
It returns the status and a flag for a Length/Type value between 1500 and 1536. It also returns the number of octets handed to the client.
The FCS check is given: fcs_good(n) runs the CRC over all n octets and compares with the residue.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
test_number | 8 | input of each check |
Full specification
bit [7:0] rx_oct [0:2199]; // given: the octets that arrived
function automatic bit fcs_good(input int n); // given
function automatic [19:0] classify(input int n, input int excess, input int max_len);
// returns {client_octets[15:0], out_of_range, status[2:0]}
| Status | Code | Counter it moves |
|---|---|---|
| receiveOK | 0 | aFramesReceivedOK |
| discarded: fewer than 64 octets | 1 | none |
frameTooLong: more than max_len octets | 2 | aFrameTooLongErrors |
| frameCheckError: FCS bad, no extra bits | 3 | aFrameCheckSequenceErrors |
| alignmentError: FCS bad, extra bits | 4 | aAlignmentErrors |
| lengthError | 5 | aInRangeLengthErrors or aOutOfRangeLengthField |
| Item | Rule |
|---|---|
| Length/Type | octets 12 and 13, high octet first |
| Data field | n − 18 octets: data and pad |
| out_of_range | 1 only with status 5 when the Length/Type value is 1501 to 1535 |
| client_octets | only with status 0: the length for a length value (pad stripped), else the data field. 0 otherwise |
| Discarded frames | return 1 and nothing else |
Use the length and size rules of P11.8 and the order of 4.2.9.
Examples
Example 1
A Good Frame with a Type- Input
type 0800h, 50 data octets
- Output
status = receiveOK (0), out_of_range = no, client_octets = 50
receiveOK. A type says nothing about size, so the client gets all 50 octets.
Example 2
A Short Length- Input
length 30, 16 pad octets
- Output
status = receiveOK (0), out_of_range = no, client_octets = 30
receiveOK. The data field is 46, which is right for a padded frame, and the client gets 30 octets.
Example 3
A Flipped Bit- Input
one bit of octet 40 flipped
- Output
status = frameCheckError (3), out_of_range = no, client_octets = 0
The FCS fails and the frame is a whole number of octets: frameCheckError.
Constraints and Contract
- Keep the function name, its arguments and the 20-bit result.
- Do not rewrite
fcs_goodorrx_oct. excessis 0 to 7;max_lenis 1518, 1522 or 2000.- Off limits: the names
rng,tb,root, names that begin withfx_and the modules of the bench.
Hints
Hint 1
Draw the decision tree first. Which test is made before the FCS is even looked at?
Hint 2
Extra bits alone do not make an error. When do they matter?
Hint 3
A length below 46 comes with a pad. What data field size is then correct?
What the grader checks: The fixture checks 24 literal frames against an independent JavaScript model with zlib.crc32. Thirteen of them sit at the 64, 1518, 1522 and 2000 limits or one octet either side. 370 random frames are made in JavaScript and judged by the same model. It does not test address filtering, carrier extension or the half-duplex collision fragments.
29 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