UVM Agent

The container component that encapsulates the verification logic for a specific interface.

Active vs Passive

An Agent can be configured as:

  • UVM_ACTIVE: Builds Driver, Sequencer, and Monitor. Used for driving stimulus.
  • UVM_PASSIVE: Builds ONLY the Monitor. Used for checking/coverage (e.g., in a Slave agent or System monitor).

Standard Implementation

class my_agent extends uvm_agent;
    `uvm_component_utils(my_agent)
    
    my_driver    drv;
    my_sequencer sqr;
    my_monitor   mon;
    
    function void build_phase(uvm_phase phase);
        super.build_phase(phase);
        mon = my_monitor::type_id::create("mon", this);
        
        if(get_is_active() == UVM_ACTIVE) begin
            drv = my_driver::type_id::create("drv", this);
            sqr = my_sequencer::type_id::create("sqr", this);
        end
    endfunction

    function void connect_phase(uvm_phase phase);
        if(get_is_active() == UVM_ACTIVE) begin
            drv.seq_item_port.connect(sqr.seq_item_export);
        end
    endfunction
endclass