verification 验证环境配置传递

验证环境配置传递

tc配置env

继承关系:
tc_base->tc_base_bt->tc_xx
base_env->xx_env
base_env_cfg->xx_env_cfg

在tc_base_bt的new函数中设置env和env_cfg的override

override_by_name("base_env", "xx_env");
override_by_name("base_env_cfg", "xx_env_cfg");

tc_base中的build_phase例化env

base_env env = base_env::type_id::create("env", this);

在env的new函数中例化env_cfg

function base_env::new(string name="", uvm_component parent);
    super.new(name, parent);

    env_cfg = base_env_cfg::type_id::create("env_cfg");
endfunction

在tc_base_bt的build_phase将env.cfg的类型从base_env_cfg转为xx_env_cfg,并保存在env_cfg这个引用中。

function void build_phase(uvm_phase phase);
    xx_env_cfg env_cfg;
    super.build_phase(phase);
    $cast(env_cfg, env.cfg);
endfunction

在tc_xxx的build_phase中用env_cfg引用设置xx_env_cfg的值

function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    env_cfg.xxx = 0;
endfunction

tc配置agent

agent的默认配置在tc_base_bt中的build_phase通过uvm_config_db,配置下去

uvm_config_db::#(xx_agent_cfg)set(null, "xxx", "cfg", xx_agt_cfg);

如果某个用例还有特殊配置,则在用例的build_phase重新再uvm_config_db配置一下

agent_cfg中包含driver_cfg,slave_driver_cfg,monitor_cfg的对象,在agent_cfg new的时候new出来,配置的时候,通过层层引用的方式设置

axi_agent_cfg axi_cfg = axi_agent_cfg::type_id::create("axi_cfg");
axi_cfg.drv_cfg.default_rready      = 1; 
axi_cfg.slv_drv_cfg.default_arready = 1; 
axi_cfg.mon_cfg.pack_mode           = axi_dec::PART_DATA; 
uvm_config_db::#(axi_agent_cfg)set(null, "*AXI*", "axi_cfg", axi_cfg);
posted @ 2021-12-14 23:36  下夕阳  阅读(194)  评论(0编辑  收藏  举报