I have the following code for passive agent who has only monitor and agent config file:
class tx_upconv_in_agent extends uvm_agent;
//configuration object
tx_upconv_in_agent_config m_cfg;
//factory registration
`uvm_component_utils(tx_upconv_in_agent)
//external interfaces
uvm_analysis_port#(tx_upconv_in_transaction) agent_ap;
//internal interfaces
//virtual tx_upconv_in_interface tx_upconv_in_if_i;
tx_upconv_in_monitor tx_upconv_in_monitor_i;
//constructor
function new(string name = "tx_upconv_in_agent", uvm_component parent);
super.new(name, parent);
endfunction: new
//build phase
virtual function void build_phase(uvm_phase phase);
if(!uvm_config_db #(tx_upconv_in_agent_config)::get(this, "", "db_tx_upconv_in_agent_config", m_cfg)) begin
`uvm_error("build_phase", "agent_config not found")
end//if
agent_ap = new(.name("tx_upconv_in_agent_ap"), .parent(this));
//Monitor is always built
tx_upconv_in_monitor_i = tx_upconv_in_monitor::type_id::create("tx_upconv_in_monitor_i", this);
endfunction: build_phase
//connect phase
virtual function void connect_phase(uvm_phase phase);
//Monitor is always connected
tx_upconv_in_monitor_i.ap.connect(agent_ap);
tx_upconv_in_monitor_i.vif = m_cfg.tx_upconv_in_vif;
endfunction: connect_phase
endclass: tx_upconv_in_agent
I have and will have more passive agents similar to this (has only monitor and agent config file), Is there any way to make this code more generic/reusable?