当前位置:网站首页>UVM中uvm_config_db非直线的设置与获取
UVM中uvm_config_db非直线的设置与获取
2022-06-27 00:46:00 【Alfred.HOO】
在图3-4所示的UVM树中,driver的路径为uvm_test_top.env.i_agt.drv。在uvm_test_top,env或者i_agt中,对driver中的某些变量
通过config_db机制进行设置,称为直线的设置。但是若在其他component,如scoreboard中,对driver的某些变量使用config_db机制
进行设置,则称为非直线的设置。
在my_driver中使用config_db::get获得其他任意component设置给my_driver的参数,称为直线的获取。假如要在其他的component,如在reference model中获取其他component设置给my_driver的参数的值,称为非直线的获取。
要进行非直线的设置,需要仔细设置set函数的第一个和第二个参数。以在scoreboard中设置driver中的pre_num为例:
文件:src/ch3/section3.5/3.5.6/set/my_scoreboard.sv
18 function void my_scoreboard::build_phase(uvm_phase phase);
…
22 uvm_config_db#(int)::set(this.m_parent, "i_agt.drv", "pre_num", 200);
26 `uvm_info("my_scoreboard", "in my_scoreboard, uvm_test_top.env.i_agt.drv.pre_num is set to 200", UVM_LOW)
27 endfunction
或者:
function void my_scoreboard::build_phase(uvm_phase phase);
super.build_phase(phase);
uvm_config_db#(int)::set(uvm_root::get(), "uvm_test_top.env.i_agt.drv", "pre_num", 200);
endfunction
无论哪种方式,都带来了一个新的问题。在UVM树中,build_phase是自上而下执行的,但是对于图3-4所示的UVM树来说,scb与i_agt处于同一级别中,UVM并没有明文指出同一级别的build_phase的执行顺序。所以当my_driver在获取参数值时,my_scoreboard的build_phase可能已经执行了,也可能没有执行。所以,这种非直线的设置,会有一定的风险,应该避免这种情况的出现。
非直线的获取也只需要设置其第一和第二个参数。假如要在reference model中获取driver的pre_num的值:
文件:src/ch3/section3.5/3.5.6/get/my_model.sv
21 function void my_model::build_phase(uvm_phase phase);
22 super.build_phase(phase);
23 port = new("port", this);
24 ap = new("ap", this);
25 `uvm_info("my_model", $sformatf("before get, the pre_num is %0d", drv_pre_num), UVM_LOW)
26 void'(uvm_config_db#(int)::get(this.m_parent, "i_agt.drv", "pre_num", drv_pre_num));
27 `uvm_info("my_model", $sformatf("after get, the pre_num is %0d", drv_pre_num), UVM_LOW)
28 endfunction
或者:
void'(uvm_config_db#(int)::get(uvm_root::get(), "uvm_test_top.env.i_agt.drv",
"pre_num", drv_pre_num));
这两种方式都可以正确地得到设置的pre_num的值。
非直线的获取可以在某些情况下避免config_db::set的冗余。上面的例子在reference model中获取driver的pre_num的值,如果
不这样做,而采用直线获取的方式,那么需要在测试用例中通过cofig_db::set分别给reference model和driver设置pre_num的值。
同样的参数值设置出现在不同的两条语句中,这大大增加了出错的可能性。因此,非直线的获取可以在验证平台中多个组件
(UVM树结点)需要使用同一个参数时,减少config_db::set的冗余。
边栏推荐
猜你喜欢
随机推荐
持续交付-Blue Ocean 应用
Is it safe to open a securities account online? Is it reliable to speculate in stocks by mobile phone
Kept to implement redis autofailover (redisha) 16
乔治·华盛顿大学 : Hanhan Zhou | PAC:多智能体强化学习中具有反事实预测的辅助价值因子分解
3 - wire SPI Screen Drive
Other service registration and discovery
buuctf-pwn write-ups (6)
Live review | Ziya &ccf TF: Discussion on software supply chain risk management technology under cloud native scenario
Object access mechanism and others
Beyond lithium battery -- the concept of battery in the future
接口测试框架实战(一) | Requests 与接口请求构造
What is the difference between the working principle of gas-liquid slip ring and other slip rings
统计无向图中无法互相到达点对数[经典建邻接表+DFS统计 -> 并查集优化][并查集手册/写的详细]
使用NetworkX对社交网络进行系统的分析:Facebook网络分析案例
Memcached foundation 4
memcached基础5
一键加速索尼相机SD卡文件的复制操作,文件操作批处理教程
Kept to implement redis autofailover (redisha) 15
接口测试框架实战(一) | Requests 与接口请求构造
Summary of working at home during the epidemic | community essay solicitation









