A receive MAC sits in a UVM bench with a line driver and a monitor. Write the scoreboard: the reference model that knows what a correct MAC does with every frame.
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 of lesson P11.47 sends frames to a receive MAC over an MII. Its monitor publishes one mac_rx_item for each frame.
The item holds what was on the line and what the MAC did with it. The MAC either stays silent or gives one indication.
Write mac_rx_scoreboard. In write(), predict what a correct MAC does with the frame, compare, and report a difference with uvm_error.
The server runs twelve benches in one simulation. Two hold a correct MAC and ten hold a faulty one.
Every bench has its own addresses and 164 frames of its own. They are drawn anew for each submission.
Stay silent on a correct MAC. On a faulty MAC, your first report must name the right check, on the first frame that MAC got wrong.
So a scoreboard that reports too early, too late or under the wrong ID does not catch that MAC.
The rules come from lessons P11.4, P11.8, P11.9, P11.10 and P11.13. The tables give them in order.
Choices of this bench MAC are marked "course choice".
Full specification
typedef enum bit [2:0] { RECEIVE_OK = 0, FRAME_TOO_LONG = 2, FRAME_CHECK_ERROR = 3, ALIGNMENT_ERROR = 4, LENGTH_ERROR = 5 } mac_status_e;
localparam bit [47:0] MAC_PAUSE_DA = 48'h0180c2000001;
// The FCS of oct[0 .. len-1] (P11.5). The first FCS octet on the wire is bits 7:0.
function automatic bit [31:0] eth_fcs(input bit [7:0] oct [$], input int len);
class mac_cfg extends uvm_object;
bit [47:0] station; // the MAC's own address
bit [47:0] group [2]; // the two group addresses on its list
endclass
class mac_rx_item extends uvm_sequence_item;
int unsigned index; // 1 for the first frame of the run
bit [7:0] oct [$]; // whole octets from the destination address to the FCS
bit extra_nibble; // a nibble was left over after the last whole octet
bit rx_er; // RX_ER was high at some point while RX_DV was high
bit indicated; // the MAC reported this frame to its client
mac_status_e status; // valid when indicated
bit [7:0] data [$]; // the octets it handed over (none unless receiveOK)
function string convert2string();
endclass
| Step | Rule | Source |
|---|---|---|
| 1. Extra nibble | It is dropped. The frame is its whole octets, oct. | 4.2.9 |
| 2. Fragment | Fewer than 64 octets: no indication. The address is not even looked at. | 4.2.9 |
| 3. Address | The MAC takes cfg.station, the broadcast address, cfg.group[0], cfg.group[1] and 01-80-C2-00-00-01. For any other destination: no indication, whatever else is wrong. | 4.2.9. Course choice: the PAUSE address is always on the list (31B.1 reserves it) |
| 4. Size | More than 1,518 octets: frameTooLong. If octets 12 and 13 are 81-00, the limit is 1,522. | 3.2.7, 4.2.7.1. Course choice: this MAC takes basic and Q-tagged frames, not envelope frames |
| 5. FCS | RX_ER counts as a failed FCS. A failed FCS is alignmentError with an extra nibble and frameCheckError without one. | 4.2.9, 22.2.1.5. Course choice: RX_ER with an extra nibble is alignmentError too |
| 6. Length | A Length/Type value up to 1,500 is a length. The data field must then hold exactly that many octets, or 46 for a value below 46. If not: lengthError. A value from 1,501 to 1,535 is always lengthError. | 4.2.9. Course choice for 1,501 to 1,535, as in P11.8 |
| 7. MAC Control | A frame that passed steps 1 to 6 with Length/Type 88-08 is consumed: no indication, whatever its opcode. | Clause 31. Course choice: every opcode is consumed in silence |
| 8. receiveOK | The MAC hands over the two addresses, the Length/Type field and the data. For a length value the data is that many octets, so the pad is gone. For any other value it is the whole data field. | 4.2.9 (RemovePad). Course choice: a tag is handed over as it came |
The data field is everything between octet 14 and the FCS: oct.size() - 18 octets. For a tagged frame that includes the tag's last two octets and the field behind them.
A tagged frame has 81-00 where the Length/Type sits, so step 6 sees a type and checks nothing.
ID of the uvm_error | When |
|---|---|
RX_UNEXPECTED | The MAC gave an indication for a frame it must keep to itself. |
RX_MISSING | The MAC gave no indication for a frame it must report. |
RX_STATUS | The MAC gave an indication with another status than you predict. |
RX_DATA | The status is receiveOK as predicted, but data differs in its length or in any octet. |
Raise at most one report for a frame: the first row that applies. Raise it inside write(), for the item it was called with.
The message text is yours. In a sample run the log prints it under the frame.
You may reuse your answers to P11.4.1 and P11.8.1. eth_fcs is given.
The twelve benches share one run of at most 15 seconds on the server. One pass over the octets of a frame is fast enough.
The clause numbers are those of IEEE Std 802.3-2022.
Examples
Example 1
A Correct MAC- Input
A correct MAC, with its own addresses and frames
- Output
alarm = no
A sample run sends 22 frames. Some are good. Others are fragments, or go to wrong addresses, or have bad lengths. The rest have a bad FCS, extra nibbles or RX_ER, test both size limits, or are MAC Control frames. The scoreboard must stay silent on all of them.
Example 2
A MAC That Ignores RX_ER- Input
A frame with RX_ER and a good FCS is reported as receiveOK. Its own addresses and frames.
- Output
alarm = yes
Frame 14 has RX_ER high during one octet, and its FCS is good. This MAC reports receiveOK. Step 5 predicts frameCheckError, so the scoreboard raises RX_STATUS on frame 14.
Example 3
A MAC That Keeps the Pad- Input
A frame with a short length value is handed over with its pad octets. Its own addresses and frames.
- Output
alarm = yes
Frame 7 has the length value 20 and a data field of 46 octets. A correct MAC hands over 34 octets: 14 of header and 20 of data. This MAC hands over 60, so the scoreboard raises RX_DATA on frame 7.
Constraints and Contract
- Keep the class name, its base class, the
cfgfield and the factory registration: the environment createsmac_rx_scoreboardand setscfg. - Report with
uvm_errorfrom the scoreboard itself, with one of the four IDs. Any other UVM error or fatal fails the submission. write()runs in zero time. Do not change the item.- Use only the supplied item,
cfg, local helpers and the giveneth_fcsfunction to decide each report. - Do not inspect run arguments, simulation time, other components, the design hierarchy, or private fixture names.
- Do not change configuration databases, factory overrides, report handling or simulation control. Do not print result lines.
- Allowed macros:
uvm_component_utils,uvm_object_utils,uvm_error,uvm_warninganduvm_info. User macros and compiler directives are unavailable.
Hints
Hint 1
Two kinds of frame get no indication before any status is thought of. A third kind gets none after it passed every check.
Hint 2
Size is checked before the FCS, and the FCS before the length. A frame can be wrong in two ways at once.
Hint 3
The address filter compares all 48 bits. The tests send a neighbour of your station address for every single bit.
Hint 4
A length of 20 with 46 data octets is a good frame. What does the client get from it?
Hint 5
Compare every octet the MAC handed over, the addresses too. One hidden MAC is wrong in a single octet of a long frame.
What the grader checks: Your scoreboard runs in twelve UVM benches inside one simulation: two correct MACs and ten faulty ones. The server draws the bench of each MAC, the addresses and all frames from a number that is new for every submission. Each bench gets 164 frames. They include a neighbour of the station address for each of its 48 bits. They test both size limits, with and without a tag. They hold damaged frames of every kind, and lengths on both sides of 46 and of 1,500. MAC Control frames come with several opcodes and destinations. A faulty MAC counts as caught only by the right first report: the right ID, on the first frame it got wrong. The last row is a correct MAC again.
12 checks on UVM · 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