V3.6.1 Take the Block Environment up to the Chip

HardFix35 minUVM · serverReview the topic

A UART0 environment written for the block bench breaks when the chip reuses it. Make its agent passive when the chip says so. Feed its scoreboard from what the bus did, not from what its own driver claims.

Hardware context: The UVM environment of soc_tb and a UART0 block environment reused in it. Making a block agent passive and feeding its scoreboard from a monitor.

On the block bench, UART0's environment drives the registers itself. Its agent has a driver, and its scoreboard learns which bytes to expect from that driver. In the chip bench the fabric writes UART0, and two drivers on one bus would fight. So the chip sets the agent's is_active to UVM_PASSIVE and expects the environment to listen only.

Repair uart_agent and uart_env. At block level they must still work as before. At chip level the agent builds no driver and no sequencer. The scoreboard must still compare every byte written to TXDATA with the bytes on the pad.

The check builds a small UVM fixture around your classes, not the whole chip. Each check is one UVM build and run. It took about 40 s on the laptop (measured). Expect an estimated two to three minutes on the live server, and wait for the result before you run again.

What the fixture leaves out is what makes a chip environment big. There, the reused monitor watches the fabric's port to UART0 through an interface the chip bench hands it. The block's register model becomes one block of the chip's, at UART0's base address. A virtual sequencer starts the chip's traffic. None of that changes the two repairs this problem grades.

Full specification
Given (read only): the items, the driver, the monitor and the scoreboard
// Given: the items, the block's driver and monitor, and the scoreboard. They are the same at block and chip level.
class bus_item extends uvm_sequence_item;
  `uvm_object_utils(bus_item)
  bit        write;
  bit [31:0] addr, data;
  function new(string name = "bus_item"); super.new(name); endfunction
endclass
class ser_item extends uvm_sequence_item;        // one byte on the UART TX pad
  `uvm_object_utils(ser_item)
  bit [7:0] data;
  function new(string name = "ser_item"); super.new(name); endfunction
endclass

// The block bench's register driver. It puts each item on the bus wires (wire_ap) and, as a convenience of the block
// bench, also announces every item it drove (sent_ap).
class bus_driver extends uvm_driver #(bus_item);
  `uvm_component_utils(bus_driver)
  uvm_analysis_port #(bus_item) wire_ap;
  uvm_analysis_port #(bus_item) sent_ap;
  function new(string name, uvm_component parent); super.new(name, parent); wire_ap = new("wire_ap", this); sent_ap = new("sent_ap", this); endfunction
  task run_phase(uvm_phase phase);
    forever begin
      seq_item_port.get_next_item(req);
      #10ns;
      wire_ap.write(req);
      sent_ap.write(req);
      seq_item_port.item_done();
    end
  endtask
endclass

// The monitor of the register bus: every transfer it sees on the wires, whoever made it.
class bus_monitor extends uvm_subscriber #(bus_item);
  `uvm_component_utils(bus_monitor)
  uvm_analysis_port #(bus_item) ap;
  function new(string name, uvm_component parent); super.new(name, parent); ap = new("ap", this); endfunction
  function void write(bus_item t); ap.write(t); endfunction
endclass

// The scoreboard: bytes written to TXDATA (0x1000_0000) must come out of the pad, in order.
`uvm_analysis_imp_decl(_expected)
`uvm_analysis_imp_decl(_actual)
class uart_scoreboard extends uvm_component;
  `uvm_component_utils(uart_scoreboard)
  uvm_analysis_imp_expected #(bus_item, uart_scoreboard) expected_export;
  uvm_analysis_imp_actual #(ser_item, uart_scoreboard) actual_export;
  bit [7:0] queue [$];
  int matched, mismatched, unmatched, expected_writes, pad_bytes;
  function new(string name, uvm_component parent);
    super.new(name, parent);
    expected_export = new("expected_export", this);
    actual_export = new("actual_export", this);
  endfunction
  function void write_expected(bus_item t);
    expected_writes++;
    if (t.write && t.addr == 32'h1000_0000) queue.push_back(t.data[7:0]);
  endfunction
  function void write_actual(ser_item t);
    pad_bytes++;
    if (queue.size() != 0 && queue[0] == t.data) begin void'(queue.pop_front()); matched++; end
    else begin
      mismatched++;
      if (queue.size() != 0) void'(queue.pop_front());
    end
  endfunction
  function void check_phase(uvm_phase phase); unmatched = queue.size(); endfunction
endclass
Block levelChip level
is_active of env.agentUVM_ACTIVEUVM_PASSIVE
Who writes UART0the agent's driver, through its sequencerthe fabric: the fixture puts its writes on the wires
What the monitor seesevery writeevery write
Bytes on the padthe fixture plays themthe fixture plays them

The fixture sets is_active with uvm_config_db before your environment is built. It connects the bus wires to agent.monitor and the pad to scoreboard.actual_export. At the end it reads the scoreboard's counts.

Examples

Example 1

Block Level
Input
is_active = UVM_ACTIVE; writes TXDATA=0x41, TXDATA=0x42, TXDATA=0x43; pad 41 42 43
Output
drivers = 1, sequencers = 1, monitors = 1, matched = 3, mismatched = 0, unmatched = 0, expected_writes = 3, pad_bytes = 3

The agent is active: one driver, one sequencer. The three bytes written to TXDATA come out of the pad in order: 3 matched.

Example 2

Chip Level
Input
is_active = UVM_PASSIVE; writes DIV=0x8, TXDATA=0x6f, TXDATA=0x6b, TXDATA=0xa; pad 6f 6b a
Output
drivers = 0, sequencers = 0, monitors = 1, matched = 3, mismatched = 0, unmatched = 0, expected_writes = 4, pad_bytes = 3

The agent is passive: no driver, no sequencer. The monitor still sees the four writes, so the scoreboard expects the three TXDATA bytes and matches them.

Example 3

A Byte Nobody Wrote
Input
is_active = UVM_PASSIVE; writes TXDATA=0x31, TXDATA=0x32; pad 31 39 32
Output
drivers = 0, sequencers = 0, monitors = 1, matched = 1, mismatched = 2, unmatched = 0, expected_writes = 2, pad_bytes = 3

At chip level a 0x39 appears on the pad. The scoreboard counts it as a mismatch, which it can only do if it learned the expected bytes from the bus.

Constraints and Contract

  • Keep the class names uart_agent and uart_env and their members sequencer, driver, monitor, agent and scoreboard. A member the agent does not build stays null.
  • Do not change the given classes. Your classes must raise no UVM error.

Hints

Hint 1

uvm_agent reads is_active from the configuration database in its own build_phase. Does your build_phase let it?

Hint 2

At chip level the driver is never started. What does the scoreboard then hear from sent_ap?

Hint 3

Which component sees the bus in both levels?

What the grader checks: Six environments, each built by a small fixture with its own is_active, bus writes and pad bytes. The result is what your agent built and the scoreboard's counts. The fixture is not the chip. The full chip environment (soc_uvm) took 49 to 134 s to build on the laptop, an estimated 3 to 8 minutes live. So the check uses this slice. A scoreboard fed by the driver at block level and by the monitor at chip level would also pass. Only the monitor works in both.

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 2 problems 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 Level

Input
is_active = UVM_ACTIVE; writes TXDATA=0x41, TXDATA=0x42, TXDATA=0x43; pad 41 42 43
Expected output
drivers = 1, sequencers = 1, monitors = 1, matched = 3, mismatched = 0, unmatched = 0, expected_writes = 3, pad_bytes = 3

The agent is active: one driver, one sequencer. The three bytes written to TXDATA come out of the pad in order: 3 matched.

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

UVM · server