Hi,
Does anyone know what would be the best way to accomplish this.
I want to parameterize agents and their drivers/monitors.
Here is my puzzle:
from the test_top I want to define how many agents and what the names/types of the driver classes are.
EX:
function void build_phase(uvm_phase phase);
string interface_names[] = {
"adc_parallel", "adc_serial"};
// Get test name from UVM_TESTNAME command line argument
if(!$value$plusargs("UVM_TESTNAME=%s", test_name))
`uvm_error("TEST", {"Unknown Test name", test_name})
// Save transcript
// void'(mti_Cmd($sformatf("transcript file %s.$Sv_Seed.transcript.txt", test_name)));
// Construct the top level configuration, agent configuration
env_config = adc_env_configuration::type_id::create("env_config");
env_config.number_of_agents = 1;
env_config.create_agent_configs(env_config.number_of_agents);
env_config.agent[0].agent_name = "adc";
env_config.agent[0].config_type = agent_config;
env_config.agent[0].driver_type = adc_driver;
env_config.agent[0].monitor_type = adc_monitor;
env_config.agent[0].transaction_type= adc_transaction;
env_config.agent[0].coverage_type = adc_coverage;
env_config.agent_config[0].active_passive = ACTIVE;
env_config.agent_config[0].has_coverage = 1;
env_config.agent_config[0].enable_transaction_viewing = 1;
//retrieve interface from config db and put in adc_agent_config
if( !uvm_config_db #( virtual adc_vif )::get( this , "" , "adc_vi" , agent_config.vi ) )
`uvm_fatal("Config Error" , "uvm_config_db #( virtual adc_vi )::get cannot find resource adc_vif from test top" )
//set env_cfg.adc_agent_config to adc_agent_config
env_config.agent_config[0] = agent_config;
//set the agent configuration
uvm_config_db #(adc_env_configuration)::set(this,"*","env_config",env_config);
//create environment
env = generic_environment::type_id::create("env",this);
`uvm_info("TOP_LEVEL_CONFIGURATION",env_config.convert2string(),UVM_HIGH);
super.build_phase(phase);
endfunction
Now from the Environment:
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
//get the environment configuration
// type of value prefix path field name values
if( !uvm_config_db #( env_configuration )::get( this , "" , "env_config" , env_config ) )
`uvm_fatal("Config Error" , "uvm_config_db #( adc_env_configuration )::get resource env_config not found" )
//construct/create the agents
for (int i = 0; i < env_config.number_of_agents;i++)
begin
//set the agent configuration
uvm_config_db #(agent_configuration)::set(this,"*",$sformatf("agent_config_%2d", i),env_config.agent_config[i]);
agents[i] = generic_agent#(env_config.agent_config[i].config_type,
env_config.agent_config[i].monitor_type,
env_config.agent_config[i].driver_type,
env_config.agent_config[i].coverage_type,
env_config.agent_config[i].trans_type,
i
)::type_id::create($sformatf("agent_%2d", i),this);
end
endfunction
In the agent
class generic_agent #(
type CONFIG_T,
type MONITOR_T,
type DRIVER_T,
type COVERAGE_T,
type TRANS_T,
int AGENT_NUM
) extends uvm_agent;
// Register this component with the factory
`uvm_component_param_utils(generic_agent #(CONFIG_T,
MONITOR_T,
DRIVER_T,
COVERAGE_T,
TRANS_T,
AGENT_NUM))
CONFIG_T config_h;
COVERAGE_T coverage_h;
MONITOR_T monitor_h;
TRANS_T trans_req_h;
TRANS_T trans_rsp_h;
DRIVER_T #(config_h,AGENT_NUM, trans_req_h,trans_rsp_h) driver_h;
uvm_sequencer #(TRANS_T) sequencer_h;
uvm_analysis_port #(TRANS_T) mon_ap;
// FUNCTION: new
function new( string name = "", uvm_component parent = null );
super.new( name, parent );
endfunction: new
// FUNCTION: build_phase
virtual function void build_phase(uvm_phase phase);
if(!uvm_config_db #(CONFIG_T)::get(this, "",$sformatf("agent_config_%2d", AGENT_NUM),config_h))
`uvm_fatal("AGENT", "Failed to get config object");
//send the agent config to all levels below this and the driver and monitor can retriev the interface
uvm_config_db #(CONFIG_T)::set(this, "*","config_h",config_h);
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Construct a sequencer and driver only if agent is in active mode
if (config_h.active_passive == ACTIVE) begin
sequencer_h = new("sequencer_h",this);
//create specific base instance of driver so we can override with parameterized type
driver_h = DRIVER_T#(AGENT_NUM, trans_req_h,trans_rsp_h)::type_id::create("driver_h",this);
end
There is more here but I cut it off.
The error I get is
generic_agent.svh(61): (vlog-13175) Passing parameter to type ‘DRIVER_T’ is not allowed.
Any thoughts,
Thanks,
Scott