7.3 uvm_config_db in UVM

uvm_config_db类派生自uvm_resource_db类。它是uvm_resource_db顶部的另一层便利层,简化了用于uvm_component实例的基本接口(资源库的访问方法)。

下面uvm_config_db类的代码段取自uvm源代码。

class uvm_config_db#(type T=int) extends uvm_resource_db#(T);static uvm_pool#(string,uvm_resource#(T)) m_rsc[uvm_component];static local uvm_queue#(m_uvm_waiter) m_waiters[string];static function bit get(uvm_component cntxt,string inst_name,string field_name,inout T value);...endfunctionstatic function void set(uvm_component cntxt,string inst_name,string field_name,T value);...endfunction...
...
endclass

1. uvm_config_db methods

下表中除了wait_modified是静态任务外,其余都是的静态函数。

其中,

uvm_component cntxt:该context是可访问数据库条目的起点(hierarchical starting point)。

string inst_name:实例名称是限制数据库条目可访问性的路径。

string field_name:field_name是用于查找数据库条目的标记或标签。
T value: 是从数据库中set或者get的值。default是整数类型。

简单地说,完整path取决于 cntxt  和 inst_name拼接 {cntxt, “.” ,inst_name} .

例子:uvm_test_top.env.agent_o的层次路径可以从测试用例中提到为:

cntxt = null
inst_name = env.agent_oORcntxt = this
inst_name = "env.agent_o"

 Syntax for set method:

void uvm_config_db#(type T = int)::set(uvm_component cntxt,string inst_name,string field_name,T value);

Syntax for get method:

bit uvm_config_db#(type T=int)::get(uvm_component cntxt,string inst_name,string field_name,ref T value);

2. uvm_config_db example

在下面的示例中,control位存储在数据库中,作为在component_B中为my_component创建对象的使能条件(enable condition)。

名为“control”、类型为bit的新资源将从测试用例添加到资源池中。

uvm_config_db #(bit)::set(null, "*", "control", 1);//where,
//uvm_component cntxt= null;
//string inst_name = "*"
//String field_name = "control";
//T value = 1;// In component_B, 
if(!uvm_config_db #(bit)::get(this, "*", "control", ctrl))`uvm_fatal(get_type_name(), "get failed for resource in this scope");

使用get()static函数检索资源,该函数在数据库中以field_name作为“control”进行查找。如果get()在数据库中找不到“control”字符串field_name,将报告致命错误。尽管致命检查不是强制性的,但建议将其用于调试目的。一旦表中的查找成功,存储在资源数据库中的值就会在局部变量ctrl中更新。此控制位用于控制my_component对象的创建。 

 

`include "uvm_macros.svh"
import uvm_pkg::*;class component_A #(parameter ID_WIDTH = 8) extends uvm_component;bit [ID_WIDTH-1:0] id;`uvm_component_param_utils(component_A #(ID_WIDTH))function new(string name = "component_A", uvm_component parent = null);super.new(name, parent);id = 1;endfunctionfunction display();`uvm_info(get_type_name(), $sformatf("inside component_A: id = %0d", id), UVM_LOW);endfunction
endclassclass mycomponent #(parameter ID_WIDTH = 8) extends uvm_component;bit [ID_WIDTH-1:0] id;`uvm_component_param_utils(mycomponent #(ID_WIDTH))function new(string name = "mycomponent", uvm_component parent = null);super.new(name, parent);id = 2;endfunctionfunction display();`uvm_info(get_type_name(), $sformatf("inside mycomponent: id = %0d", id), UVM_LOW);endfunction
endclassclass component_B #(int ID_WIDTH = 8) extends component_A #(ID_WIDTH);bit ctrl;bit [ID_WIDTH-1:0] id;mycomponent #(8) my_comp;`uvm_component_param_utils(component_B #(ID_WIDTH))function new(string name = "component_B", uvm_component parent = null);super.new(name, parent);id = 3;endfunctionfunction void build_phase(uvm_phase phase);super.build_phase(phase);if(!uvm_config_db #(bit)::get(this, "*", "control", ctrl))`uvm_fatal(get_type_name(), "get failed for resource in this scope");if(ctrl)  my_comp = mycomponent #(8)::type_id::create("my_comp", this);endfunctionfunction display();`uvm_info(get_type_name(), $sformatf("inside component_B: id = %0d, ctrl = %0d", id, ctrl), UVM_LOW);if(ctrl) void'(my_comp.display());endfunction
endclassclass my_test extends uvm_test;bit control;`uvm_component_utils(my_test)component_A #(32) comp_A;component_B #(16) comp_B;function new(string name = "my_test", uvm_component parent = null);super.new(name, parent);endfunctionfunction void build_phase(uvm_phase phase);super.build_phase(phase);comp_A = component_A #(32)::type_id::create("comp_A", this);comp_B = component_B #(16)::type_id::create("comp_B", this);uvm_config_db #(bit)::set(null, "*", "control", 1);//or//uvm_config_db #(bit)::set(this, "*", "control", 1);endfunctionfunction void end_of_elaboration_phase(uvm_phase phase);super.end_of_elaboration_phase(phase);uvm_top.print_topology();endfunctiontask run_phase(uvm_phase phase);super.run_phase(phase);void'(comp_A.display());void'(comp_B.display());endtask
endclassmodule tb_top;initial beginrun_test("my_test");end
endmodule

Output:

UVM_INFO /xcelium20.09/tools//methodology/UVM/CDNS-1.2/sv/src/base/uvm_root.svh(605) @ 0: reporter [UVMTOP] UVM testbench topology:
----------------------------------------
Name          Type           Size  Value
----------------------------------------
uvm_test_top  my_test        -     @1812comp_A      uvm_component  -     @1879comp_B      uvm_component  -     @1910my_comp   uvm_component  -     @1958
----------------------------------------UVM_INFO testbench.sv(14) @ 0: uvm_test_top.comp_A [uvm_component] inside component_A: id = 1
UVM_INFO testbench.sv(52) @ 0: uvm_test_top.comp_B [uvm_component] inside component_B: id = 3, ctrl = 1
UVM_INFO testbench.sv(28) @ 0: uvm_test_top.comp_B.my_comp [uvm_component] inside mycomponent: id = 2

3. precedence rule

有两个优先规则适用于uvm_config_db。在build_phase中,

1.在组件层次结构较高的上下文中的set()调用优先于层次结构路径较低的set()调用。

例子:

`include "uvm_macros.svh"
import uvm_pkg::*;class component_A extends uvm_component;int id;`uvm_component_utils(component_A)function new(string name = "component_A", uvm_component parent = null);super.new(name, parent);id = 1;endfunctionfunction display();`uvm_info(get_type_name(), $sformatf("inside component_A: id = %0d", id), UVM_LOW);endfunction
endclassclass component_B extends component_A;int receive_value;int id;`uvm_component_utils(component_B)function new(string name = "component_B", uvm_component parent = null);super.new(name, parent);id = 2;endfunctionfunction void build_phase(uvm_phase phase);super.build_phase(phase);if(!uvm_config_db #(int)::get(this, "*", "value", receive_value))`uvm_fatal(get_type_name(), "get failed for resource in this scope");    endfunctionfunction display();`uvm_info(get_type_name(), $sformatf("inside component_B: id = %0d, receive_value = %0d", id, receive_value), UVM_LOW);endfunction
endclassclass env extends uvm_env;`uvm_component_utils(env)component_A comp_A;component_B comp_B;function new(string name = "env", uvm_component parent = null);super.new(name, parent);endfunctionfunction void build_phase(uvm_phase phase);super.build_phase(phase);comp_A = component_A ::type_id::create("comp_A", this);comp_B = component_B ::type_id::create("comp_B", this);uvm_config_db #(int)::set(this, "*", "value", 200);endfunctiontask run_phase(uvm_phase phase);super.run_phase(phase);void'(comp_A.display());void'(comp_B.display());endtask
endclassclass my_test extends uvm_test;bit control;`uvm_component_utils(my_test)env env_o;function new(string name = "my_test", uvm_component parent = null);super.new(name, parent);endfunctionfunction void build_phase(uvm_phase phase);super.build_phase(phase);env_o = env::type_id::create("env_o", this);uvm_config_db #(int)::set(null, "*", "value", 100);endfunctionfunction void end_of_elaboration_phase(uvm_phase phase);super.end_of_elaboration_phase(phase);uvm_top.print_topology();endfunction
endclassmodule tb_top;initial beginrun_test("my_test");end
endmodule

Output:

UVM_INFO /xcelium20.09/tools//methodology/UVM/CDNS-1.2/sv/src/base/uvm_root.svh(605) @ 0: reporter [UVMTOP] UVM testbench topology:
--------------------------------------
Name          Type         Size  Value
--------------------------------------
uvm_test_top  my_test      -     @1810env_o       env          -     @1877comp_A    component_A  -     @1922comp_B    component_B  -     @1953
--------------------------------------UVM_INFO testbench.sv(14) @ 0: uvm_test_top.env_o.comp_A [component_A] inside component_A: id = 1
UVM_INFO testbench.sv(36) @ 0: uvm_test_top.env_o.comp_B [component_B] inside component_B: id = 2, receive_value = 100

2.在具有相同的上下文字段时,最后一个set()调用优先于前面的set()。

 Example:

`include "uvm_macros.svh"
import uvm_pkg::*;class component_A extends uvm_component;int id;`uvm_component_utils(component_A)function new(string name = "component_A", uvm_component parent = null);super.new(name, parent);id = 1;endfunctionfunction display();`uvm_info(get_type_name(), $sformatf("inside component_A: id = %0d", id), UVM_LOW);endfunction
endclassclass component_B extends component_A;int receive_value;int id;`uvm_component_utils(component_B)function new(string name = "component_B", uvm_component parent = null);super.new(name, parent);id = 2;endfunctionfunction void build_phase(uvm_phase phase);super.build_phase(phase);if(!uvm_config_db #(int)::get(this, "*", "value", receive_value))`uvm_fatal(get_type_name(), "get failed for resource in this scope");    endfunctionfunction display();`uvm_info(get_type_name(), $sformatf("inside component_B: id = %0d, receive_value = %0d", id, receive_value), UVM_LOW);endfunction
endclassclass env extends uvm_env;`uvm_component_utils(env)component_A comp_A;component_B comp_B;function new(string name = "env", uvm_component parent = null);super.new(name, parent);endfunctionfunction void build_phase(uvm_phase phase);super.build_phase(phase);comp_A = component_A ::type_id::create("comp_A", this);comp_B = component_B ::type_id::create("comp_B", this);endfunctiontask run_phase(uvm_phase phase);super.run_phase(phase);void'(comp_A.display());void'(comp_B.display());endtask
endclassclass my_test extends uvm_test;bit control;`uvm_component_utils(my_test)env env_o;function new(string name = "my_test", uvm_component parent = null);super.new(name, parent);endfunctionfunction void build_phase(uvm_phase phase);super.build_phase(phase);env_o = env::type_id::create("env_o", this);uvm_config_db #(int)::set(null, "*", "value", 100);uvm_config_db #(int)::set(null, "*", "value", 200);endfunctionfunction void end_of_elaboration_phase(uvm_phase phase);super.end_of_elaboration_phase(phase);uvm_top.print_topology();endfunction
endclassmodule tb_top;initial beginrun_test("my_test");end
endmodule

Output:

 

UVM_INFO /xcelium20.09/tools//methodology/UVM/CDNS-1.2/sv/src/base/uvm_root.svh(605) @ 0: reporter [UVMTOP] UVM testbench topology:
--------------------------------------
Name          Type         Size  Value
--------------------------------------
uvm_test_top  my_test      -     @1810env_o       env          -     @1877comp_A    component_A  -     @1924comp_B    component_B  -     @1955
--------------------------------------UVM_INFO testbench.sv(14) @ 0: uvm_test_top.env_o.comp_A [component_A] inside component_A: id = 1
UVM_INFO testbench.sv(36) @ 0: uvm_test_top.env_o.comp_B [component_B] inside component_B: id = 2, receive_value = 200

4. uvm_config_db usage

  1. 将配置变量/类向下传递到testbench的层次结构中(如上面的示例所示)。
  2. 将虚拟接口从顶部层次结构传递到测试台层次结构中的组件。

5. Difference between uvm_config_db and uvm_resource_db 

  1. 虽然这两个类都在uvm资源facility上提供了一个方便层(便利),但uvm_config_db是从uvm_resource_db派生而来的。这将在uvm_resource_db方法之上添加其他方法。
  2. 关于组件层次结构,与具有两个字符串scope和name的uvm_resource相比,uvm_config_db具有一个参数作为上下文,其类型为uvm_component,实例名称为字符串,提供了更大的灵活性。由于上下文中提到了组件层次结构,因此它提供了对层次路径的更多控制。这个context = this参数提供组件的相对路径。这个context = null提供了一个绝对路径,这意味着上面没有层次路径。

With respect to component hierarchy, the uvm_config_db  has an argument as a context that has the type of uvm_component and instance name as a string that provides more flexibility as compared to uvm_resource that has two strings scope and name. Since component hierarchy is mentioned in the context, it provides more control over the hierarchical path.
The context = this argument provides a relative path from the component. The context = null provides an absolute path which means there is no hierarchical path above.

因此,建议总是使用uvm_config_db。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/580107.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

html之为什么使用表单,常用表单元素使用?

文章目录 一、为什么使用表单呢?二、常用表单元素使用三、总结 一、为什么使用表单呢? 为什么使用表单呢,使用表单是为了更好的收集用户数据,并且安全 二、常用表单元素使用 1、password密码框 密码框:会隐藏数据&a…

网络摄像头爆破实战

*** 重要说明:仅用于交流网络安全测试技术,并唤起大家对网络安全的重视,如用本文的技术干违法的事情,博主概不负责。*** 文章目录 前言1. 发现摄像头2. 发现端口3. 确定品牌信息4. 确定RTSP地址5. 获取视频流6. 获取密码7. 再次获…

flutter学习-day20-使用SafeArea组件处理各机型的安全距离

📚 目录 介绍分析示例和效果图特殊情况 1. 介绍 安全区域,指的是移动端设备的可视窗口范围。处于安全区域的内容不受圆角、刘海屏、iPhone 小黑条、状态栏等的影响,也就是说,我们要做好适配,必须保证页面可视、可操作…

亚马逊鲲鹏系统全自动化操作注册下单更快捷

亚马逊鲲鹏系统的强大崛起,让买家号的注册、养号、下单留评等繁琐任务迎来了一场全新的自动化革命。这一创新性软件系统的横空出世,为广大亚马逊卖家提供了一种高效、智能的解决方案,成功摆脱了繁重的手动操作。 在这一系统中,买家…

安卓恢复指南:五种安卓数据恢复软件推荐

我们的手机随身携带。我们抓住他们快速拍照、发送消息并保持娱乐。有时我们对它们过于冒险,将它们扔在混凝土或水中,安装我们不应该安装的软件,然后将它们留在电影中或公园的长椅上。 如果您要在任何地方丢失重要数据,很可能是在…

C# WPF上位机开发(扩展上位机之外的技能)

【 声明:版权所有,欢迎转载,请勿用于商业用途。 联系信箱:feixiaoxing 163.com】 如果把c# wpf只是看成是一个做界面的框架,那确实有点狭隘了。单独的上位机软件,如果不需要上下游的支持,没有与…

linux中top参数详解

top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器 top参数详解 第一行,任务队列信息,同 uptime 命令的执行结果 系统时间:07:27:05 运行时间:up …

Oracle查询重复数据取第二行,好用来删除重复数据

Oracle查询重复数据取第二行,好用来删除重复数据 SELECT * FROM ( SELECT e.* , ROW_NUMBER() over(PARTITION BY product_category_id,model_size_id ORDER BY product_category_id,model_size_id) rn FROM equ_check_rules e ) s WHERE rn 2;

Plantuml之序列图语法介绍(十七)

简介: CSDN博客专家,专注Android/Linux系统,分享多mic语音方案、音视频、编解码等技术,与大家一起成长! 优质专栏:Audio工程师进阶系列【原创干货持续更新中……】🚀 优质专栏:多媒…

springboot对接WebSocket实现消息推送

1.修改pom文件 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-websocket</artifactId></dependency> 2.增加配置WebSocketConfig.java import org.springframework.context.annotation.Bean…

实训4---硬件部分---点灯实验--按键控制灯实验--uart串口实验

目录 三、硬件部分 【1】点灯实验 【2】按键控制灯实验 【3】uart串口实验 核心代码&#xff1a; 实验视频 实现流水灯 uart串口实验 三、硬件部分 GPIO 【1】点灯实验 1.首先找到要点的灯&#xff0c;在板子上看到对应的白色丝印&#xff0c;比如绿灯D10.然后打开底板…

服务器数据恢复-raid6离线磁盘强制上线后分区打不开的数据恢复案例

服务器数据恢复环境&#xff1a; 服务器上有一组由12块硬盘组建的raid6磁盘阵列&#xff0c;raid6阵列上层有一个lun&#xff0c;映射到WINDOWS系统上使用&#xff0c;WINDOWS系统划分了一个GPT分区。 服务器故障&分析&#xff1a; 服务器在运行过程中突然无法访问。对服务…

什么是EMC工程师?

摘要: 今天来介绍一下什么是EMC工程师。一 EMC工程师起源要了解什么是EMC工程师&#xff0c;我们首先要了解什么是EMC。 今天来介绍一下什么是EMC工程师。 一 EMC工程师起源 要了解什么是EMC工程师&#xff0c;我们首先要了解什么是EMC。 工程师这个职业相信大家都耳熟能详…

1.决策树

目录 1. 什么是决策树? 2. 决策树的原理 2.1 如何构建决策树&#xff1f; 2.2 构建决策树的数据算法 2.2.1 信息熵 2.2.2 ID3算法 2.2.2.1 信息的定义 2.2.2.2 信息增益 2.2.2.3 ID3算法举例 2.2.2.4 ID3算法优缺点 2.2.3 C4.5算法 2.2.3.1 C4.5算法举例 2.2.4 CART算法 2.2.4…

基于VUE3+Layui从头搭建通用后台管理系统(前端篇)十六:统计报表模块相关功能实现

一、本章内容 本章使用Echarts及DataV实现常用图表、特殊图表、地图及综合图表等图表展示功能。 1. 详细课程地址: https://edu.csdn.net/course/detail/38183 2. 源码下载地址: 点击下载 二、界面预览 三、开发视频 3.1 B站视频地址: 基于VUE3+Layui从

Python——yolov8识别车牌2.0

目录 一、前言 二、关于项目UI 2.1、修改界面内容的文本 2.2、修改界面的图标和图片 三、项目修改地方 四、其他配置问题 一、前言 因为后续有许多兄弟说摄像头卡顿&#xff0c;我在之前那个MATS上面改一下就可以了&#xff0c;MAST项目&#xff1a;基于YOLOv8的多端车流检…

【leetcode100-019】【矩阵】螺旋矩阵

【题干】 给你一个 m 行 n 列的矩阵 matrix &#xff0c;请按照 顺时针螺旋顺序 &#xff0c;返回矩阵中的所有元素。 【思路】 不难注意到&#xff0c;每进行一次转向&#xff0c;都有一行/列被输出&#xff08;并失效&#xff09;&#xff1b;既然已经失效&#xff0c;那我…

倒计时1天!WAVE SUMMIT+ 2023将开启,五大亮点抢鲜看!

10句话2分钟&#xff0c;挑战成功说服宿管阿姨开门&#xff0c;这个人群中的“显眼包”是一个接入文心大模型4.0游戏里的NPC&#xff0c;妥妥 “工具人”实锤&#xff5e; 尝试用AI一键自动识别好坏咖啡豆&#xff0c;看一眼便知好坏&#xff0c;真正“颜值即正义”&#xff0…

信息筑牢安全防线|隐私安全保护仍任重道远!

在日常生活中&#xff0c;就连小小一张快递面单可以显示很多关键信息&#xff0c;让不法分子盗取个人信息有机可乘。 今年2月1日&#xff0c;《快递电子运单》国家标准开始实施。根据国家邮政局数据&#xff0c;中国快递日均包裹量3.4亿余件&#xff0c;隐私面单日均使用量已超…

13.鸿蒙HarmonyOS App(JAVA)文本框组件按钮点击提示

13.鸿蒙HarmonyOS App(JAVA)文本框按钮点击提示 点击按钮触发组件状态&#xff0c;点击改变颜色 文本框组件&#xff0c;文本居中&#xff0c;斜体&#xff0c;左右对齐&#xff0c;点击显示提示信息 Button button(Button) findComponentById(ResourceTable.Id_btn_1); but…