当前位置: 首页 > news >正文

27 UVM queue

uvm_queue类构建一个动态队列,该队列将按需分配并通过引用传递。

uvm_queue类声明:

class uvm_queue #( type T = int ) extends uvm_object

1 uvm_queue class hierarchy

2 uvm_queue class Methods

3 UVM Queue Example

在下面的示例中,组件A用于向队列中添加元素,组件B用于从同一队列中删除元素。

组件A和组件B代码:

class componentA extends uvm_component;`uvm_component_utils(componentA)uvm_queue#(string) qA;function new(string name = "componentA", uvm_component parent = null);super.new(name, parent);endfunctiontask run_phase(uvm_phase phase);super.run_phase(phase);qA = uvm_queue#(string)::get_global_queue();qA.push_front("Rock");qA.push_back("Scissor");qA.insert(1, "Paper");endtask
endclassclass componentB extends uvm_component;`uvm_component_utils(componentB)uvm_queue#(string) qB;string s_name;function new(string name = "componentB", uvm_component parent = null);super.new(name, parent);endfunctiontask run_phase(uvm_phase phase);super.run_phase(phase);s_name = uvm_queue#(string)::get_global(1);`uvm_info(get_name(), $sformatf("get_global: item = %s", s_name), UVM_LOW);qB = uvm_queue#(string)::get_global_queue();s_name = qB.pop_front();`uvm_info(get_name(), $sformatf("pop_front = %s", s_name), UVM_LOW);`uvm_info(get_name(), $sformatf("Before delete: qB size = %0d", qB.size()), UVM_LOW);qB.delete(1);`uvm_info(get_name(), $sformatf("After delete: qB size = %0d", qB.size()), UVM_LOW);s_name = qB.pop_back();`uvm_info(get_name(), $sformatf("pop_back = %s", s_name), UVM_LOW);endtask
endclass
class base_test extends uvm_test;`uvm_component_utils(base_test)componentA comp_a;componentB comp_b;function new(string name = "base_test",uvm_component parent=null);super.new(name,parent);endfunction : newfunction void build_phase(uvm_phase phase);super.build_phase(phase);comp_a = componentA::type_id::create("comp_a", this);comp_b = componentB::type_id::create("comp_b", this);endfunction : build_phasefunction void end_of_elaboration();uvm_top.print_topology();endfunction
endclassmodule uvm_queue_example;initial beginrun_test("base_test");end
endmodule

Output:

UVM testbench topology:
-------------------------------------
Name          Type        Size  Value
-------------------------------------
uvm_test_top  base_test   -     @336 comp_a      componentA  -     @349 comp_b      componentB  -     @358 
-------------------------------------UVM_INFO components.sv(31) @ 0: uvm_test_top.comp_b [comp_b] get_global: item = Paper
UVM_INFO components.sv(36) @ 0: uvm_test_top.comp_b [comp_b] pop_front = Rock
UVM_INFO components.sv(38) @ 0: uvm_test_top.comp_b [comp_b] Before delete: qB size = 2
UVM_INFO components.sv(40) @ 0: uvm_test_top.comp_b [comp_b] After delete: qB size = 1
UVM_INFO components.sv(43) @ 0: uvm_test_top.comp_b [comp_b] pop_back = Paper

http://www.lryc.cn/news/271167.html

相关文章:

  • 聊聊自动化测试的分层实践
  • LVS那点事
  • 2022-2023年度广东省职业院校学生专业技能大赛“软件测试”赛项接口测试训练题目
  • [Python][LeetCode]28. 找出字符串中第一个匹配项的下标
  • Prometheus监控mysql
  • 骑砍战团MOD开发(30)-游戏大地图map.txt
  • 关于 bringup sensor 时,曝光时间异常的问题排查
  • linux用户态与内核态通过字符设备交互
  • 如何高效查询文件:Linux 下的多种方法详解
  • 记矩阵基础概念
  • 用html,js和layui写一个简单的点击打怪小游戏
  • [线代]不挂科猴博士
  • 扩散式过滤器 水泵角通除污器 0阻力过滤器直角过滤器工作原理
  • MetalLB:本地Kubernetes集群的LoadBalancer负载均衡利器
  • C++判定终端ip和目标ip是否在同一局域网内
  • 深入解析 可空值类型
  • esp32idf使用thingscloud例程
  • 记一次应急响应练习(Linux)
  • Pandas教程(四)—— 分层索引及数据联合
  • 小梅哥Xilinx FPGA学习笔记16——FSM(状态机)的学习
  • vol----学习随记!!!
  • HarmonyOS4.0系统性深入开发10卡片事件能力说明
  • openGauss学习笔记-181 openGauss 数据库运维-升级-升级流程
  • 提前应对威胁
  • C语言与人生:数组交换和二分查找
  • Python实现【亚马逊商品】数据采集
  • Git使用教程 gittutorial
  • 有了向量数据库,我们还需 SQL 数据库吗?
  • 信息网络协议基础-IPv6协议
  • VC++ ado 实现单表CURD