uvm-tlm-nonblocking-get-port

前文展示了使用本质为阻塞性质的uvm_blocking_get_port TLM端口的示例,其中接收方会停滞等待发送方完成get任务。

类似地,UVM TLM还提供非阻塞类型的uvm_nonblocking_get_port,发送方需通过try_get来检测get是否成功,或通过can_get方法判断发送方是否已准备好启动传输。与之前相同,UVM TLM非阻塞get端口最终应连接到非阻塞get实现端口。

UVM TLM Nonblocking Get Example

下面定义了一个名为Packet的类,作为将在组件之间传输的数据项。该类的对象将包含两个随机变量,这些变量可以在发送前进行随机化处理。

// Create a class data object that can be sent from one
// component to another
class Packet extends uvm_object;rand bit[7:0] addr;rand bit[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

1. Create receiver class with a port of type uvm_nonblocking_get_port

创建了一个名为componentB的类,其中实例化了一个参数化的uvm_nonblocking_get_port端口,用于接收Packet类型的数据对象。该端口最好在该组件的build_phase阶段通过new()方法进行实例化。

在本示例中,通过调用try_get方法从get_port句柄接收Packet类型的类对象。通过由可配置变量控制的简单循环,可以接收多个此类数据包。理想情况下,当传输成功时try_get函数应返回1,失败时返回0,该功能应由实现该函数的发送方提供。

class componentB extends uvm_component;`uvm_component_utils (componentB)// Create a get_port to request for data from componentAuvm_nonblocking_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);// Try to get a transaction which does not consume simulation time// as try_get() is a functionrepeat (m_num_tx) beginif (m_get_port.try_get(pkt))`uvm_info ("COMPB", "ComponentA just gave me the packet", UVM_LOW)else`uvm_info ("COMPB", "ComponentA did not give packet", UVM_LOW)pkt.print (uvm_default_line_printer);endphase.drop_objection(this);endtask
endclass

3. Create sender class that implements the get method

发送方类需要使用uvm_nonblocking_get_imp定义一个实现端口。由于该端口本质上是非阻塞的,try_get实现必须由该组件定义为函数。

class componentA extends uvm_component;`uvm_component_utils (componentA)uvm_nonblocking_get_imp #(Packet, componentA) m_get_imp;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_imp = new ("m_get_imp", this);endfunctionvirtual function bit try_get (output Packet pkt);pkt = new();assert (pkt.randomize());`uvm_info ("COMPA", "ComponentB has requested for a packet", UVM_LOW)pkt.print (uvm_default_line_printer);return 1;endfunctionvirtual function bit can_get();endfunction
endclass

tlm-get

4. Connect port and its implementation at a higher level

端口与其实现之间的连接必须在更高的层次结构中进行。由于在这个示例中,两个组件都直接实例化在测试类中,它们之间的连接可以在测试的connect_phase阶段完成。如果这两个组件实例化在另一个组件或环境中,则必须在该组件或环境的connect_phase阶段进行连接。

class my_test extends uvm_test;`uvm_component_utils (my_test)componentA compA;componentB compB;function new (string name = "my_test", uvm_component parent = null);super.new (name, parent);endfunction// Create objects of both components, set number of transfersvirtual function void build_phase (uvm_phase phase);super.build_phase (phase);compA = componentA::type_id::create ("compA", this);compB = componentB::type_id::create ("compB", this);endfunction// Connection between componentA and componentB is done herevirtual function void connect_phase (uvm_phase phase);compB.m_get_port.connect (compA.m_get_imp);endfunctionvirtual function void end_of_elaboration_phase(uvm_phase phase);super.end_of_elaboration_phase(phase);uvm_top.print_topology();endfunction
endclass

 Simulation Log

UVM_INFO @ 0: reporter [RNTST] Running test my_test...
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_root.svh(579) @ 0: reporter [UVMTOP] UVM testbench topology:
-----------------------------------------------------
Name            Type                      Size  Value
-----------------------------------------------------
uvm_test_top    my_test                   -     @1836compA         componentA                -     @1905m_get_imp   uvm_nonblocking_get_imp   -     @1971compB         componentB                -     @1936m_get_port  uvm_nonblocking_get_port  -     @2010
-----------------------------------------------------UVM_INFO testbench.sv(97) @ 0: uvm_test_top.compA [COMPA] ComponentB has requested for a packet
Packet: (Packet@1903) { addr: 'he8  data: 'hc5  } 
UVM_INFO testbench.sv(67) @ 0: uvm_test_top.compB [COMPB] ComponentA just gave me the packet
Packet: (Packet@1903) { addr: 'he8  data: 'hc5  } 
UVM_INFO testbench.sv(97) @ 0: uvm_test_top.compA [COMPA] ComponentB has requested for a packet
Packet: (Packet@2058) { addr: 'hd6  data: 'hd  } 
UVM_INFO testbench.sv(67) @ 0: uvm_test_top.compB [COMPB] ComponentA just gave me the packet
Packet: (Packet@2058) { addr: 'hd6  data: 'hd  } 
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_objection.svh(1271) @ 0: reporter [TEST_DONE] 'run' phase is ready to proceed to the 'extract' phase
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_report_server.svh(847) @ 0: reporter [UVM/REPORT/SERVER] 
--- UVM Report Summary ---

UVM TLM can_get Example

接收方可以先通过can_get函数查询发送方是否已准备就绪,而不是直接尝试获取数据包,然后再获取数据包。

class componentB extends uvm_component;`uvm_component_utils (componentB)// Create a get_port to request for data from componentAuvm_nonblocking_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);// Try to get a transaction which does not consume simulation time// as try_get() is a functionrepeat (m_num_tx) beginwhile (!m_get_port.can_get()) begin#10 `uvm_info("COMPB", $sformatf("See if can_get() is ready"), UVM_LOW)end`uvm_info("COMPB", $sformatf("COMPA ready, get packet now"), UVM_LOW)m_get_port.try_get(pkt);pkt.print (uvm_default_line_printer);endphase.drop_objection(this);endtask
endclass

在此示例中,componentA 中的 can_get 函数被设置为返回随机值,以模拟接收方的准备状态。

class componentA extends uvm_component;`uvm_component_utils (componentA)uvm_nonblocking_get_imp #(Packet, componentA) m_get_imp;// Rest of the code remains samevirtual function bit try_get (output Packet pkt);pkt = new();assert (pkt.randomize());`uvm_info ("COMPA", "ComponentB has requested for a packet", UVM_LOW)pkt.print (uvm_default_line_printer);return 1;endfunctionvirtual function bit can_get();bit ready;std::randomize(ready) with { ready dist {0:/70, 1:/30}; };return ready;endfunction
endclass

 Simulation Log

UVM_INFO @ 0: reporter [RNTST] Running test my_test...
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_root.svh(579) @ 0: reporter [UVMTOP] UVM testbench topology:
-----------------------------------------------------
Name            Type                      Size  Value
-----------------------------------------------------
uvm_test_top    my_test                   -     @1837compA         componentA                -     @1906m_get_imp   uvm_nonblocking_get_imp   -     @1972compB         componentB                -     @1937m_get_port  uvm_nonblocking_get_port  -     @2011
-----------------------------------------------------UVM_INFO testbench.sv(60) @ 10: uvm_test_top.compB [COMPB] See if can_get() is ready
UVM_INFO testbench.sv(60) @ 20: uvm_test_top.compB [COMPB] See if can_get() is ready
UVM_INFO testbench.sv(60) @ 30: uvm_test_top.compB [COMPB] See if can_get() is ready
UVM_INFO testbench.sv(62) @ 30: uvm_test_top.compB [COMPB] COMPA ready, get packet now
UVM_INFO testbench.sv(97) @ 30: uvm_test_top.compA [COMPA] ComponentB has requested for a packet
Packet: (Packet@2065) { addr: 'h8c  data: 'h99  } 
Packet: (Packet@2065) { addr: 'h8c  data: 'h99  } 
UVM_INFO testbench.sv(62) @ 30: uvm_test_top.compB [COMPB] COMPA ready, get packet now
UVM_INFO testbench.sv(97) @ 30: uvm_test_top.compA [COMPA] ComponentB has requested for a packet
Packet: (Packet@2095) { addr: 'h97  data: 'hb8  } 
Packet: (Packet@2095) { addr: 'h97  data: 'hb8  } 
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_objection.svh(1271) @ 30: reporter [TEST_DONE] 'run' phase is ready to proceed to the 'extract' phase
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_report_server.svh(847) @ 30: reporter [UVM/REPORT/SERVER] 
--- UVM Report Summary ---

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

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

相关文章

【NCS随笔】如何在hello_world添加蓝牙功能(一)

如何在hello_world添加蓝牙功能(一)环境准备 硬件:nRF54L15DK 软件版本:NCS3.0.2 例程:hello_world 宏的配置 # Config loggerCONFIG_LOGyCONFIG_USE_SEGGER_RTTyCONFIG_LOG_BACKEND_RTTyCONFIG_LOG_BACKEND_UARTnONFI…

机器学习——KNN实现手写数字识别:基于 OpenCV 和 scikit-learn 的实战教学 (超级超级超级简单)

用KNN实现手写数字识别:基于 OpenCV 和 scikit-learn 的实战教学在这篇文章中,我们将使用 KNN(K-Nearest Neighbors)算法对手写数字进行分类识别。我们会用 OpenCV 读取图像并预处理数据,用 scikit-learn 构建并训练模…

【Git】分支

文章目录理解分支创建分支切换分支合并分支删除分支合并冲突分支管理策略分支策略bug 分支删除临时分支小结理解分支 本章开始介绍 Git 的杀手级功能之一(注意是之一,也就是后面还有之二,之三……):分支。分支就是科幻…

【32】C# WinForm入门到精通 ——打开文件OpenFileDialog 【属性、方法、事件、实例、源码】

WinForm 是 Windows Form 的简称,是基于 .NET Framework 平台的客户端(PC软件)开发技术,是 C# 语言中的一个重要应用。 .NET 提供了大量 Windows 风格的控件和事件,可以直接拿来使用。 本专栏内容是按照标题序号逐渐…

Wan2.2开源第1天:动态灯光功能开启创意氛围新境界

在开源软件蓬勃发展的今天,每一次新版本的发布都如同在创意的星空中点亮了一颗璀璨的新星。今天,(通义万相国际版wan)Wan2.2正式开源,它带着令人眼前一亮的动态灯光功能惊艳登场,为所有追求创意与氛围营造的…

Excel制作滑珠图、哑铃图

Excel制作滑珠图、哑铃图效果展示在较长时间周期内,很多参数都是在一定范围内浮动的,并不是一成不变的,为了直观表达各类别的浮动范围,使用“滑珠图”就是一个不错的选择,当滑珠图两侧均有珠子的时候,又称为…

Day07 JDBC+MyBatis

1.JDBC入门程序2.JDBC执行DQL语句3.JDBC预编译SQL 防止SQL注入随便输入用户名,密码为or1 1,sql注入4.Mybatis入门 Mapper 持久层XxxMapper替代Dao4.1调用接口的findAll()方法时自动执行上方的SQL语句,并将SQL查询的语句自动封装到返回值中5.Mybatis辅助…

OSS-服务端签名Web端直传+STS获取临时凭证+POST签名v4版本开发过程中的细节

这里写自定义目录标题配置OSS服务端代码初始化STS Client获取STS临时凭证创建policy计算SigningKeyOSSUtil.javaSTSPolicyDTO.java提供接口Apifox模拟Web端文件直传本文主要结合服务端STS获取临时凭证(签名)直传官方文档对开发中比较容易出错的地方加以提醒;建议主要…

uniapp实现微信小程序导航功能

1.导航按钮<button click"navigation()">导航到仓库</button>2.导航功能const navigation (item) > {let address item.province item.city item.district item.address //地址let latitude Number(item.latitude) …

07.4-使用 use 关键字引入路径

使用 use 关键字引入路径 每次调用函数时都必须写出完整路径&#xff0c;可能会感觉不便且重复。在清单7-7中&#xff0c;无论我们选择绝对路径还是相对路径来调用 add_to_waitlist 函数&#xff0c;每次调用时都必须指定 front_of_house 和 hosting。幸运的是&#xff0c;有一…

7.Linux :进程管理,进程控制与计划任务

Linux &#xff1a;进程管理&#xff0c;进程控制与计划任务 一、进程管理 1. 进程与程序 程序&#xff1a;静态的可执行文件&#xff08;存储于磁盘&#xff09;。进程&#xff1a;动态执行的程序实例&#xff08;占用CPU/内存&#xff09;。 2. 查看进程命令作用常用组合ps静…

Matplotlib(四)- 图表样式美化

文章目录一、Matplotlib图表样式介绍1. 图表样式简介2. 默认图表样式2.1 查看默认配置2.2 常用的配置3. 图表样式修改3.1 局部修改3.1.1 通过绘图方法设置参数修改3.1.2 通过rcParams修改3.1.3 通过rc()方法修改3.2 全局修改二、颜色设置1. 颜色的三种表示方式1.1 颜色单词1.2 …

三十四、【Linux常用工具】rsync+inotify实时同步演示

实时同步演示技术架构全景核心组件详解1. inotify 内核子系统2. Rsync 高效同步工具实践演示一、环境准备与安装1. 检查内核支持2. 安装 inotify-tools二、配置 Rsync 服务端&#xff08;目标机&#xff09;1. 创建 Rsync 配置文件2. 启动 Rsync 守护进程三、配置实时同步脚本&…

windows环境下MySQL 8.0 修改或重置密码

windows环境下MySQL 8.0 修改或重置密码 1打开命令窗口cmd&#xff0c;输入命令&#xff1a;net stop mysql&#xff0c; 停止MySQL服务&#xff0c; 开启跳过密码验证登录的MySQL服务 2输入命令 mysqld --console --skip-grant-tables --shared-memory 再打开一个新的cmd&…

基于YOLOP与GAN的图像修复与防御系统设计与实现

基于YOLOP与GAN的图像修复与防御系统设计与实现 前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家&#xff0c;觉得好请收藏。点击跳转到网站。 1. 引言 1.1 研究背景 随着深度学习技术在计算机视觉领域的…

将目录文件转移到D盘,使之后的下载缓存数据转移,不再存入c盘

将 C:\Users 文件夹&#xff08;用户文件夹&#xff09;转移到其他盘是一个复杂且风险较高的操作。C:\Users 文件夹包含了系统中每个用户的个人数据和配置文件&#xff0c;修改这个路径可能会导致系统出现问题&#xff0c;包括程序无法正常工作或无法登录。因此&#xff0c; 强…

Cesium大气散射效果

由于做全球体积云效果的需要&#xff0c;再来研究下大气散射效果和体积云类似&#xff0c;关于大气散射颜色计算的过程也仅发生在这两个球体之间。如图所示。计算从相机出发的视线与球壳的交点&#xff0c;如果不相交&#xff0c;则该视线方向上不会发生大气散射&#xff0c;直…

预过滤环境光贴图制作教程:第二步 - 生成环境贴图图集

核心目标 本步骤的核心是生成一张包含 6 级分辨率的环境贴图图集(envAtlas),实现: 将第一步的立方体贴图(sourceCube)重新映射为等矩形投影(适合存储和采样); 生成 6 级不同分辨率的等矩形数据(0 级最高清,5 级最模糊); 用 RGBP 编码压缩 HDR 数据(平衡精度与存…

1. ESP开发之实体按键(KEYPADBUTTON)控制LVGL控件

说明LV_INDEV_TYPE_BUTTON的使用LV_INDEV_TYPE_KEYPAD的使用 说明 本实验使用LVGL版本为v9.2 LVGL中有四种输入设备,如下LV_INDEV_TYPE_POINTER, /**< Touch pad, mouse, external button*/ LV_INDEV_TYPE_KEYPAD, /**< Keypad or keyboard*/ LV_INDEV_TYPE_BUTTON, /*…

C++:STL中list的使用和模拟实现

C中的list是标准模板库&#xff08;STL&#xff09;提供的双向链表容器&#xff0c;支持高效的元素插入和删除操作。在上一篇中讲解了vector的使用和模拟实现&#xff0c;vector是具有连续的空间&#xff0c;迭代器是可以随机的&#xff0c;而list却于vector不同&#xff0c;li…