U18.4.1 Drop It or Corrupt It, Never Both

HardImplementUVM · serverReview the topic

Write the veto gate and two injectors for a VIP whose one hook may edit or drop a beat. The ledger must match the pins.

Hardware context: Lane VIP with a hook that may edit or drop a beat. Build a veto gate and stackable injectors with a ledger that matches the pins.

A lane VIP offers one hook, received, in the style of the UVM 1.1 guide. A callback may edit the beat, and returns 0 to drop it. The driver asks a gate object before each beat, and drops the beat when the gate says 0.

Write the gate, a drop injector and a parity injector, and install them on a lane. The scoreboard trusts the ledger. Every drop, corruption and sent beat recorded there must be exactly what reached the pins. A beat planned for both is dropped, never corrupted.

Full specification
What you write
// Asks every callback in order. The first one that returns 0 drops the beat, and the
// callbacks after it are not asked. Record each beat that will be sent in ledger.
class lane_gate extends lane_gate_base;
  function new(string name = "lane_gate"); super.new(name); endfunction
  function bit ask(lane_driver drv, lane_item it, lane_beat beat);
    return 1;
  endfunction
endclass

// Drops the items listed in on. Record each drop in ledger.
class drop_cb extends lane_cb;
  int on[$];
  inject_ledger ledger;
  function new(string name = "drop_cb"); super.new(name); endfunction
endclass

// Sends the items listed in on with bad parity. Record each corruption in ledger.
class corrupt_cb extends lane_cb;
  int on[$];
  inject_ledger ledger;
  function new(string name = "corrupt_cb"); super.new(name); endfunction
endclass

// Called once per lane with that lane's driver and injectors.
function void install(lane_driver drv, drop_cb d, corrupt_cb c);
endfunction
GivenMeaning
lane_cb::received(drv, it, beat)The hook. Return 1 to let the beat go on, 0 to drop it. The base returns 1.
ledger.note(kind, n)Record "drop", "corrupt" or "sent" for item n.
lane_driverCalls gate.ask(this, req, beat) after it builds the beat. On 0 it calls item_done and drives nothing.
onThe item numbers an injector acts on, set by the test.

The gate asks the callbacks in queue order and stops at the first that returns 0. Later callbacks are not asked. It records "sent" exactly for the beats it lets through.

Examples

Example 1

Drop Item 2, Corrupt Item 4
Input
5 items; drop [2], corrupt [4]
Output
items_on_pins = {1, 3, 4, 5}, bad_parity_on_pins = {4}, ledger_dropped = {2}, ledger_corrupted = {4}, ledger_sent = {1, 3, 4, 5}

Item 2 never reaches the pins; item 4 arrives with bad parity. The ledger lists the drop, the corruption and the four sent items.

Example 2

Item 3 Is Planned for Both
Input
4 items; drop [3], corrupt [1, 3]
Output
items_on_pins = {1, 2, 4}, bad_parity_on_pins = {1}, ledger_dropped = {3}, ledger_corrupted = {1}, ledger_sent = {1, 2, 4}

The drop injector answers first and returns 0, so the parity injector is never asked about item 3. Only item 1 is corrupted.

Example 3

Nothing Planned
Input
3 items; drop [], corrupt []
Output
items_on_pins = {1, 2, 3}, bad_parity_on_pins = {}, ledger_dropped = {}, ledger_corrupted = {}, ledger_sent = {1, 2, 3}

Every callback returns 1, the gate returns 1, and all three items are sent with good parity.

Constraints and Contract

  • Keep every class and function name and signature; the bench creates and calls them.
  • Flip beat.par to corrupt; do not touch the item.
  • install is called once per lane, in connect_phase.

Hints

Hint 1

UVM has a callback macro that stops at the first callback returning a chosen value. Read what it expands to before you put code after it.

Hint 2

If the parity injector is asked before the drop injector, what does the ledger say about an item planned for both?

Hint 3

The macro returns from the function it sits in. Where can the "sent" record go so it runs only for beats that will be sent?

What the grader checks: Your gate and injectors run on six real lanes with hidden plans. The checks compare the items the sink took and their parity with your ledger's drops, corruptions and sent beats.

6 checks on UVM · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 1 problem on this path

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

Drop Item 2, Corrupt Item 4

Input
5 items; drop [2], corrupt [4]
Expected output
items_on_pins = {1, 3, 4, 5}, bad_parity_on_pins = {4}, ledger_dropped = {2}, ledger_corrupted = {4}, ledger_sent = {1, 3, 4, 5}

Item 2 never reaches the pins; item 4 arrives with bad parity. The ledger lists the drop, the corruption and the four sent items.

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

UVM · server