UVM Environment

The UVM environment acts as the container for the UVM components including one or more agents, monitors, scoreboards and checkers. The communication between Monitor and other components like scoreboard or subscriber happens here.

A user-defined environment class is extended from uvm_env. uvm_env is inherited by uvm_component.

class <env_name> extends uvm_env;

Example: Implementing a UVM Env

Let’s implement a simple UVM environment.

class p_env extends uvm_env;
  p_agent p_agnt;
  p_scoreboard scb;
  
  `uvm_component_utils(p_env)
  
  virtual p_interface vif;
  
  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction
  
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    p_agnt = p_agent::type_id::create("p_agnt",this);
    scb = p_scoreboard::type_id::create("scb",this);
    
  endfunction
  
  function void connect_phase(uvm_phase phase);
    super.connect_phase(phase);
    p_agnt.monitor.p_collect_port.connect(scb.p_collect_export);
  endfunction
  
endclass