UVM Env

UVM Environment

The user-defined environment is derived from uvm_env, uvm_env is inherited from uvm_component.

The environment is the container class, It contains one or more agents, as well as other components such as the scoreboard, top-level monitor, and checker.

Writing Environment

1. The environment is written by extending UVM_ENV,

class mem_model_env extends uvm_env;
  
  `uvm_component_utils(mem_model_env)
    
  // new - constructor
  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction : new

endclass : mem_model_env

2. Declare the agent,

  mem_agent mem_agnt;

3. Create an agent,

  mem_agnt = mem_agent::type_id::create("mem_agnt", this);

Complete environment code,

class mem_model_env extends uvm_env;

  mem_agent mem_agnt;
  
  `uvm_component_utils(mem_model_env)
    
  // new - constructor
  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction : new

  // build_phase
  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    mem_agnt = mem_agent::type_id::create("mem_agnt", this);
  endfunction : build_phase

endclass : mem_model_env

❮ Previous Next ❯