示例:

具体概念详见[UVM 事务级建模TLM 单向/多向通信 端口 FIFO通信](https://blog.csdn.net/qq_40456702/article/details/126682331?spm=1001.2014.3001.5501)

component A 每隔 50ns 往 tlm_fifo 写入一个 transaction,component B 每隔 100ns 从 tlm_fifo 读出一个 transaction

1. 定义 transaction

// Packet (transaction)继承自uvm_object,其在组件之间传输class Packet extends uvm_object;randbit[7:0] addr;randbit[7:0] data;`uvm_object_utils_begin(Packet)`uvm_field_int(addr, UVM_ALL_ON)`uvm_field_int(data, UVM_ALL_ON)`uvm_object_utils_endfunction new(string name = "Packet");super.new(name);endfunction
endclass

2. 定义 component A

// 创建component A,定义 put_port,实现 transaction 的生成、约束和发送class componentA extendsuvm_component;`uvm_component_utils (componentA)uvm_blocking_put_port #(Packet) m_put_port;int m_num_tx = 2;function new (string name = "componentA", uvm_component parent= null);super.new (name, parent);endfunctionvirtual function void build_phase(uvm_phase phase);super.build_phase(phase);m_put_port = new ("m_put_port", this);endfunctionvirtual task run_phase(uvm_phase phase);phase.raise_objection(this);repeat (m_num_tx) begin  //  component A每隔 50个时钟周期, 往 tlm_fifo 写入一个 transaction,写两次。Packet pkt = Packet::type_id::create ("pkt");assert(pkt.randomize ());#50;   //Print the packet to be displayed in log`uvm_info ("COMPA", "Packetsent to CompB", UVM_LOW)pkt.print (uvm_default_line_printer);//Call the TLM put() method of put_port class and pass packet as argumentm_put_port.put(pkt);endphase.drop_objection(this);endtask
endclass

3. 定义 component B

// 创建component B,定义get_port,实现transaction的接收
// 可以看出,uvm_tlm_fifo的两端都是export,都是put()和get()的实现端,而不是发起端class componentB extendsuvm_component;`uvm_component_utils (componentB)//Create a get_port to request for data from componentAuvm_blocking_get_port #(Packet) m_get_port;int m_num_tx = 2;function new (string name, uvm_component parent);super.new (name, parent);endfunctionvirtual function void build_phase(uvm_phase phase);super.build_phase(phase);m_get_port = new ("m_get_port", this);endfunctionvirtual task run_phase(uvm_phase phase);Packet pkt;phase.raise_objection(this);repeat (m_num_tx) begin  // component B 每隔 100个时钟周期 从 tlm_fifo 读出一个 transaction,写两次#100;m_get_port.get(pkt);`uvm_info ("COMPB", "ComponentAjust gave me the packet", UVM_LOW)pkt.print (uvm_default_line_printer);endphase.drop_objection(this);endtask
endclass

4. 在上层 env 定义 uvm_tlm_fifo

// 在更高的测试平台层次中定义uvm_tlm_fifo
// 连接 comp A 的 put_port 和 tlm_fifo 的 put_export,以及 comp B 的 get_port 和 tlm_fifo 的 get_exportclass my_test extendsuvm_env;`uvm_component_utils (my_test)componentA compA;componentB compB;int m_num_tx;//Create the UVM TLM Fifo that can accept simple_packetuvm_tlm_fifo #(Packet)   m_tlm_fifo;function new (string name = "my_test", uvm_component parent = null);super.new (name, parent);endfunctionvirtual function void build_phase(uvm_phase phase);super.build_phase(phase);//Create an object of both componentscompA = componentA::type_id::create ("compA", this);compB = componentB::type_id::create ("compB", this);std::randomize(m_num_tx) with {m_num_tx inside {[4:10]}; };compA.m_num_tx = m_num_tx;compB.m_num_tx = m_num_tx;// 创建tlm fifo 深度为2m_tlm_fifo = new ("uvm_tlm_fifo", this, 2);endfunction//Connect the ports to the export of FIFO.virtual function void connect_phase(uvm_phase phase);compA.m_put_port.connect(m_tlm_fifo.put_export);compB.m_get_port.connect(m_tlm_fifo.get_export);endfunction// 查询fifo是否为满virtual task run_phase(uvm_phase phase);forever begin#10;if(m_tlm_fifo.is_full ())`uvm_info ("UVM_TLM_FIFO", "Fifo isnow FULL !", UVM_MEDIUM)         endendtask
endclass

仿真结果

# UVM_INFO tb_classes/componentA.sv(33) @50: uvm_test_top.compA [COMPA] Packet sent to CompB
# pkt: (Packet@543) { addr: 'h10  data: 'hcc }
# UVM_INFO tb_classes/componentB.sv(26) @100: uvm_test_top.compB [COMPB] ComponentA just gave me the packet
# pkt: (Packet@543) { addr: 'h10  data: 'hcc }
# UVM_INFO tb_classes/componentA.sv(33) @100: uvm_test_top.compA [COMPA] Packet sent to CompB
# pkt: (Packet@544) { addr: 'h3e  data: 'h92 }
# UVM_INFO tb_classes/componentA.sv(33) @150: uvm_test_top.compA [COMPA] Packet sent to CompB
# pkt: (Packet@545) { addr: 'hde  data: 'h65 }
# UVM_INFO tb_classes/my_test.sv(40) @ 150:uvm_test_top [UVM_TLM_FIFO] Fifo is now FULL !
# UVM_INFO tb_classes/my_test.sv(40) @ 160:uvm_test_top [UVM_TLM_FIFO] Fifo is now FULL !
# UVM_INFO tb_classes/my_test.sv(40) @ 170:uvm_test_top [UVM_TLM_FIFO] Fifo is now FULL !
# UVM_INFO tb_classes/my_test.sv(40) @ 180:uvm_test_top [UVM_TLM_FIFO] Fifo is now FULL !
# UVM_INFO tb_classes/my_test.sv(40) @ 190:uvm_test_top [UVM_TLM_FIFO] Fifo is now FULL !
# UVM_INFO tb_classes/componentB.sv(26) @200: uvm_test_top.compB [COMPB] ComponentA just gave me the packet
# pkt: (Packet@544) { addr: 'h3e  data: 'h92 }

UVM TLM FIFO通信 示例相关推荐

  1. UVM——TLM通信

    UVM--TLM通信 1. 概述 2. 基本概念 3. 分类 4. 端口的使用 1. 概述 在芯片开发流程中,系统原型和芯片验证对项目的助推起到了关键作用 系统原型,一般是通过硬件功能描述文档来模拟硬 ...

  2. UVM TLM通信简介

    1.UVM put/get通信 在UVM中一对一的TLM有很多种类型,以sequencer和driver为例. driver是请求端,在driver列化了两种端口(在uvm_driver中列化,可直接 ...

  3. 【从零开始学习 UVM】10.5、UVM TLM —— UVM TLM Blocking Get Port

    文章目录 UVM TLM Get Port Example 1. 创建一个发送方类,其端口类型为 uvm_blocking_get_imp 3. 创建接收器类,等待 get 方法. 4. 在更高层次上 ...

  4. 启明云端分享|ESP32-C3 IO口控制灯的应用及串口通信示例

    启明云端作为乐鑫代理,一直都尽最大可能做完善的教程能帮助更多的开发小伙伴快速上手各种应用:今天小明为大家带来ESP32-C3IO口控制灯的应用及串口通信示例,每一个步骤我们都分享出来供小伙伴们参考! ...

  5. TCP/IP 通信示例

    TCP/IP 通信示例 Global String ReadData_P_All$, ReadData_P$(10), data$ ' Global Preserve Double x Global ...

  6. 安卓应用安全指南 5.4.1 通过 HTTPS 的通信 示例代码

    5.4.1 通过 HTTPS 的通信 示例代码 原书:Android Application Secure Design/Secure Coding Guidebook 译者:飞龙 协议:CC BY- ...

  7. UI线程与子线程通信示例 日记

    UI线程与子线程通信示例 日记 个人日记 package com.example.appthread_test;import androidx.annotation.NonNull; import a ...

  8. 有人串口转wifi模块 httpd client通信示例-用户使用网页通过服务器收发串口数据源码 小黄人软件

    有人串口转wifi模块 httpd client通信示例-用户使用网页通过服务器收发串口数据 功能:用户使用网页通过服务器收发串口数据,转发信息通过文件转存.网页自动更新串口发来的数据,网页发送数据到 ...

  9. 配置Dot1q终结子接口实现同设备VLAN间通信示例

    示例图 一.实验目的 1.配置Dot1q终结子接口实现同设备VLAN间通信示例 二.注意事项 1.Dot1q终结子接口和QinQ终结子接口不支持透传不带VLAN Tag的报文,收到不带VLAN Tag ...

最新文章

  1. hibernate mysql 设置时区_Hibernate连接MYSQL失败提示时区错误该怎么解决?
  2. ios应用的分发和上传
  3. dateformat java 格式_java Date日期类和SimpleDateFormat日期类格式
  4. 【Python3 SelectKBest 调用personer出现的错误】
  5. SQL手工注入入门级笔记(更新中)
  6. 博客园---博客美化汇总
  7. 计蒜客 - T1012 A*B问题
  8. DoIP专栏 - DoIP概述
  9. java根据日期计算星期几_利用Java计算某个日期是星期几
  10. QT5的软键盘输入法实现
  11. 泰拉瑞亚 服务器linux,泰拉瑞亚Linux主机打造指南
  12. Java根据图片提取文字
  13. java工程师怎么找兼职,快来看鸭~
  14. tp+layui 时间戳转换
  15. 推荐系统[八]:推荐系统常遇到问题和解决方案[物品冷启动问题、多目标平衡问题、数据实时性问题等]
  16. 软件测试/测试开发丨Docker 容器技术与常用命令
  17. ssi 指令 php,SSI使用详解_PHP教程
  18. 玩电脑玩出的 Linux 专家 - Google(谷歌)开发者日演讲者之苏哲
  19. python 读文件数据并画图
  20. Django实用技巧--后台管理

热门文章

  1. 关于Rost ContentMining 6.0情感分析出现空白的解决方案
  2. js将php时间戳转换成格式化日期
  3. For Developer-友盟+官网体验升级的打开方式
  4. Splatter Painting
  5. 【电子技术】如何抑制共模、差模噪声?
  6. 给 32 位系统装 8g 内存条能用吗?为什么?
  7. 转行学什么就业前景好?
  8. Unbound服务的安装与运行管理
  9. 遨博机械臂——末端工具ROS驱动
  10. 国外免费3D模型下载网站