当前位置:网站首页>Config in UVM_ How to use the DB mechanism
Config in UVM_ How to use the DB mechanism
2022-06-27 01:25:00 【Alfred. HOO】
set Function and get The parameters of the function
config_db The mechanism is used in UVM Verify the parameters passed between platforms . They usually appear in pairs .set Send letter when function ,get The function is to receive .
For example, in a test case build_phase You can use the following methods to send letters :uvm_config_db#(int)::set(this, "env.i_agt.drv" "pre_num", 100);
The first parameter and the second parameter are combined to form the target path , Only the target that matches this path can receive . The first parameter must be a uvm_component Pointer to instance , The second parameter is the path relative to this instance . General , If the first parameter is set to this, Then the second parameter can be an empty string . The third parameter is set The third argument in the function , These two parameters must strictly match , The fourth parameter is the variable to be set .
stay top_tb Pass through config_db The mechanism set Function settings virtual interface when ,set The first function of the function is null. under these circumstances ,UVM Will automatically replace the first singular with uvm_root::get(), namely uvm_top. let me put it another way , The following two expressions are completely equivalent :
uvm_config_db#(virtual my_if)::set(null, "uvm_test_top.env.i_agt.drv", "vif", input_vif);
uvm_config_db#(virtual my_if)::set(uvm_root::get(), "uvm_test_top.env.i_agt.drv", "vif", input_vif);
set And get The third argument in the function can be associated with get The fourth parameter in the function is different .
umv_config_db#(int)::set(this, "env.i_agt.drv", "p_num", 100);
umv_config_db#(int)::set(this, "", "p_num", pre_num);
Omit get sentence
src/ch3/section3.5/3.5.3/my_driver.sv
7 int pre_num;
8 `uvm_component_utils_begin(my_driver)
9 `uvm_field_int(pre_num, UVM_ALL_ON)
10 `uvm_component_utils_end
11
12 function new(string name = "my_driver", uvm_component parent = null);
13 super.new(name, parent);
14 pre_num = 3;
15 endfunction
16
17 virtual function void build_phase(uvm_phase phase);
18 `uvm_info("my_driver", $sformatf("before super.build_phase, the pre_num is %0d", pre_num), UVM_LOW)
19 super.build_phase(phase);
20 `uvm_info("my_driver", $sformatf("after super.build_phase, the pre_num is %0d", pre_num), UVM_LOW)
21 if(!uvm_config_db#(virtual my_if)::get(this, "", "vif", vif))
22 `uvm_fatal("my_driver", "virtual interface must be set for vif!!!")
23 endfunction
uvm_config_db#(int)::get(this, "", "pre_num", pre_num);
The key here is build_phase Medium super.build_phase sentence , When executed driver Of super.build_phase when , Automatically get sentence . Before this practice
Yes, it is : First of all ,my_driver You have to use uvm_component_utils Macro registration ; second ,pre_num You have to use uvm_field_int Macro registration ; Third , Calling set function
When ,set The third argument to the function must be the same as the argument to get The names of the variables in the function are consistent , It has to be pre_num.
Multiple settings across levels
In the figure 3-4 in , If uvm_test_top and env All right driver Of pre_num Set the value of , stay uvm_test_top The setting statements in are as follows :
file :src/ch3/section3.5/3.5.4/normal/my_case0.sv
32 function void my_case0::build_phase(uvm_phase phase);
33 super.build_phase(phase);
…
39 uvm_config_db#(int)::set(this,
40 "env.i_agt.drv",
41 "pre_num",
42 999);
43 `uvm_info("my_case0", "in my_case0, env.i_agt.drv.pre_num is set to 999",UVM_LOW)
stay env The setting statement of is as follows :
file :src/ch3/section3.5/3.5.4/normal/my_env.sv
19 virtual function void build_phase(uvm_phase phase);
20 super.build_phase(phase);
…
31 uvm_config_db#(int)::set(this,
32 "i_agt.drv",
33 "pre_num",
34 100);
35 `uvm_info("my_env", "in my_env, env.i_agt.drv.pre_num is set to 100",UVM_LOW)
36 endfunction
that driver The value obtained in is 100 still 999 Well ? The answer is 999.UVM The higher the level of regulation , Then the higher its priority . The hierarchy here refers to UVM
The position in the tree , The closer to the root node uvm_top, The higher the level .uvm_test_top The level of is higher than env Of , therefore uvm_test_top Medium set Priority of function
High class .
The above conclusion is in set The first argument to the function is this The time was established , But if set The first argument to the function is not this How will? ? hypothesis uvm_test_top Of set The sentence is :
file :src/ch3/section3.5/3.5.4/abnormal/my_case0.sv
32 function void my_case0::build_phase(uvm_phase phase);
33 super.build_phase(phase);
…
39 uvm_config_db#(int)::set(uvm_root::get(),
40 “uvm_test_top.env.i_agt.drv”,
41 “pre_num”,
42 999);
43 `uvm_info(“my_case0”, “in my_case0, env.i_agt.drv.pre_num is set to 999”, UVM_LOW)
and env Of set The sentence is :
file :src/ch3/section3.5/3.5.4/normal/my_env.sv
19 virtual function void build_phase(uvm_phase phase);
20 super.build_phase(phase);
…
31 uvm_config_db#(int)::set(uvm_root::get(),
32 “uvm_test_top.env.i_agt.drv”,
33 “pre_num”,
34 100);
35 `uvm_info(“my_env”, “in my_env, env.i_agt.drv.pre_num is set to 100”,UVM_LOW)
36 endfunction
In this case ,driver Got pre_num The value of is 100. because set The first argument to the function is uvm_root::get(), So the sender became uvm_top. under these circumstances , We can only compare the time of sending letters .UVM Of build_phase It's top-down ,my_case0 Of build_phase Precede my_env Of build_phase perform . therefore my_env Yes pre_num The setting of is after , Its setting becomes the final setting .
If uvm_test_top in set The first argument to the function is this, and env in set The first argument to the function is uvm_root::get(), that driver Got
pre_num The value of is also 100. This is because env in set The sender of the function becomes uvm_top, stay UVM The highest priority in the tree .
therefore , in any case , Calling set The first parameter of a function should try to use this. When you can't get this In case of pointer ( If in top_tb in ), Use null
perhaps uvm_root::get().
Multiple settings at the same level
When looking at problems across levels , It's high-level set Set priority ; When at the same level , As mentioned in the previous section , Time first .
uvm_config_db#(int)::set(this, "env.i_agt.drv", "pre_num", 100);
uvm_config_db#(int)::set(this, "env.i_agt.drv", "pre_num", 109);
When the above two statements appear in the test case at the same time build_phase In the middle of the day ,driver The final value obtained will be 109. Usage like the one above seems to be completely
That's monkey business , It doesn't make any sense .
A principle of writing code in validation is that the same statement only appears in one place , Try to avoid appearing in multiple places . The solution to this problem is to base_test Of
build_phase Use in config_db::set Set it up , such , When base_test Derived from case1~case99 In execution super.build_phase(phase) when , Will be set :
classs base_test extends uvm_test;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
uvm_config_db#(int)::set(this, "env.i_agt.drv", pre_num_max, 7);
endfunction
endclass
class case1 extends base_test;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
endfunction
endclass
…
class case99 extends base_test;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
endfunction
endclass
But for the first 100 Test cases , It still needs to be written like this :
class case100 extends base_test;
function void build_phase(uvm_phase phase);
super.build_phase(phase);
uvm_config_db#(int)::set(this, "env.i_agt.drv", pre_num_max, 100);
endfunction
endclass
case100 Of build_phase It is equivalent to two consecutive settings as shown below :
uvm_config_db#(int)::set(this, "env.i_agt.drv", "pre_num", 7);
uvm_config_db#(int)::set(this, "env.i_agt.drv", "pre_num", 100);
According to the principle of time first , Back config_db::set The value of will eventually be driver obtain .
边栏推荐
- Kept to implement redis autofailover (redisha) 13
- Reporting Classes中uvm_report_server的get_severity_count和get_server用法
- About Random Numbers
- Memcached foundation 2
- SystemVerilog仿真速率提升
- Statistical Hypothesis Testing
- NLP:Transformer在NLP自然语言领域的简介(预训练技术)、NLP模型发展(ELmo/GPT/BERT/MT-DNN/XLNet/RoBERTa/ALBERT)、经典案例之详细攻略
- Find the minimum value in the rotation sort array ii[classical Abstract dichotomy + how to break the game left, middle and right are equal]
- Memcached foundation 1
- Gaussian and Summary Stats
猜你喜欢
Ml: a detailed introduction to the division of the top ten roles, backgrounds, responsibilities and outputs of the machine learning engineering team
Tsinghua & Zhiyuan | cogview2: faster and better text image generation model
通过Rust语言计算加速技术突破图片识别性能瓶颈
buuctf-pwn write-ups (6)
Topolvm: kubernetes local persistence scheme based on LVM, capacity aware, dynamically create PV, and easily use local disk
美团:踩雷好几年,才总结出的数据治理避坑攻略
IIS 部署静态网站和 FTP 服务
buuctf-pwn write-ups (6)
uvm中的config机制方法总结(二)
getReader() has already been called for this request
随机推荐
大白话高并发(一)
IIS deploy static web site and FTP service
Law of Large Numbers
Clip: learning transferable visual models from natural language monitoring
Memcached Foundation
Structure the fifth operation of the actual camp module
Solve the problem that only one line of text is displayed or not displayed in u8glib
Statistical Hypothesis Testing
福元医药上市在即:募资净额将达到16亿元,胡柏藩为实际控制人
About Random Numbers
JVM 的指针压缩
Gaussian and Summary Stats
Weibo comments on high performance and high availability architecture
[graduation season] role conversion
Object access mechanism and others
Esp32-solo development tutorial to solve config_ FREERTOS_ UNICORE problem
C#程序结构预览最基础入门
CLIP:从自然语言监督中学习可迁移的视觉模型
memcached基础5
Flink practical problems (VII): no watermark (watermarks are only available eventtime is used)