U17.2.1 Two Environments, One Name

MediumFixUVM · serverReview the topic

Six copies of one block environment wait on an event named "done". Make each start its second stage on its own block's event, and veto the glitches that carry no data.

Hardware context: Six copies of a two-stage block, each announcing the end of stage 1 on an event named "done". Give each environment its own event pool and veto data-less triggers with an event callback.

A block environment has a producer and a consumer. The producer triggers an event named "done" when stage 1 of its block finishes, with a note naming the block. The consumer starts stage 2 when "done" is on.

The chip has six copies of the block, so the bench builds six copies of the environment. In the bench you are given, every consumer starts when the first block anywhere finishes.

A fault in the status logic also makes some producers trigger "done" with no data before the block has finished. Those triggers must not start stage 2, and each environment must count the ones it rejected.

Fix share_done and null_veto so that each consumer starts at its own block's real "done", and no glitch releases anyone.

Full specification
What you fix
// Rejects a "done" with no data, and counts each one it rejects.
class null_veto extends uvm_event_callback #(uvm_object);
  int unsigned vetoed;
  function new(string name = "null_veto"); super.new(name); endfunction
  virtual function void post_trigger(uvm_event #(uvm_object) e, uvm_object data);
    if (data == null) vetoed++;
  endfunction
endclass

// Called by every blk_env at the end of its build_phase: give the producer and the
// consumer their pool, and guard the block's "done" event with the env's veto.
function automatic void share_done(blk_env env);
  uvm_event_pool pool = uvm_event_pool::get_global_pool();   // one pool for the whole bench
  env.p.pool = pool;
  env.c.pool = pool;
  pool.get("done").add_callback(env.veto);
endfunction
GivenWhat it does
blk_producerGets "done" from its pool, triggers it with null at each glitch time, then with its note at done_at.
blk_consumerGets "done" from its pool, calls wait_on(), and records when it started and which block's note it saw.
blk_envCreates the producer, the consumer and veto, then calls share_done(this) at the end of build_phase.

All six environments run in one test. The test reads the consumers and the vetoes at 200 ns.

Examples

Example 1

Block 1 Finishes at 30 Ns
Input
environment blk0: done at 30 ns; no glitch; all six environments run together
Output
stage2_started = yes, started_at_ns = 30, started_by_block = 1, glitches_vetoed = 0

Block 3 finishes at 15 ns, but its "done" belongs to another environment. Block 1's consumer starts at 30 ns, on its own note.

Example 2

A Glitch at 20 Ns
Input
environment blk1: done at 50 ns; glitches (no data) at 20 ns; all six environments run together
Output
stage2_started = yes, started_at_ns = 50, started_by_block = 2, glitches_vetoed = 1

The glitch carries no data, so the veto skips it: the event stays off and the consumer keeps waiting until 50 ns. One glitch vetoed.

Example 3

The First Block to Finish
Input
environment blk2: done at 15 ns; no glitch; all six environments run together
Output
stage2_started = yes, started_at_ns = 15, started_by_block = 3, glitches_vetoed = 0

Block 3 finishes at 15 ns and only its own consumer starts then.

Constraints and Contract

  • Keep the class name, the function's signature and the vetoed count.
  • Do not change the producer, the consumer or the environment.
  • A glitch is a trigger whose data is null.

Hints

Hint 1

How many "done" events does the bench have? How many should it have?

Hint 2

Which of the two hooks runs before the waiting processes are released, and how does it stop the trigger?

Hint 3

A pool creates an event the first time a name is asked for. What happens to a callback added to the wrong name?

What the grader checks: Six real environments run together in one test, each with its own producer schedule. The checks read when each consumer started, whose note it saw, and how many glitches its own veto rejected. A trusted callback, added after yours to each producer's event, counts every glitch that really fired.

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

Block 1 Finishes at 30 Ns

Input
environment blk0: done at 30 ns; no glitch; all six environments run together
Expected output
stage2_started = yes, started_at_ns = 30, started_by_block = 1, glitches_vetoed = 0

Block 3 finishes at 15 ns, but its "done" belongs to another environment. Block 1's consumer starts at 30 ns, on its own note.

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

UVM · server