23 UVM Event

even机制提供进程之间的同步。与System Verilo event相比,UVM event提供了额外的灵活性,如保持事件等待器/event waiters的数量和设置回调。

uvm_event类声明:

virtual class uvm_event_base extends uvm_object
class uvm_event#(type T=uvm_object) extends uvm_event_base;

1 uvm_event class hierarchy

对于UVM 1.2,uvm_event_base类是System Verilog event构造上的抽象包装类,uvm_event类是uvm_event_base类的扩展。
对于UVM1.1d,抽象的uvm_event_base类不存在。uvm_event类直接派生自uvm_object类。

event通过从一个进程触发事件并等待另一个进程中的事件触发来提供进程之间的同步。UVM事件也可以在触发时传递数据,这使其与SV event不同。


2 uvm_event_base class methods

3 uvm_event class methods

4 UVM Event Examples

4.1  I. Event is triggered and waiting for the event to be triggered via the wait_trigger method

例如,有两个进程A和B。process_A任务用于触发事件e1,process_B任务用于等待事件。

4.1.1 Type A: An event is triggered after waiting for the event trigger

process_A任务有10ns的延迟,确保在等待事件触发后触发事件e1。使用wait_trigger方法调用等待事件触发,一旦触发e1事件,该方法调用将被解除阻止。

`include "uvm_macros.svh"
import uvm_pkg::*;module event_example();uvm_event e1;task process_A();#10;$display("@%0t: Before triggering event e1", $time);e1.trigger;$display("@%0t: After triggering event e1", $time);endtasktask process_B();$display("@%0t: waiting for the event e1", $time);e1.wait_trigger;$display("@%0t: event e1 is triggered", $time);endtaskinitial begine1 = new();forkprocess_A();process_B();joinend
endmodule

Output:

@0: waiting for the event e1
@10: Before triggering event e1
@10: After triggering event e1
@10: event e1 is triggered

4.1.2 Type B: An event is triggered before waiting for the event trigger

process_B任务有10ns的延迟,确保在等待事件触发之前触发事件e1。由于之前触发了e1事件,因此不会解除对事件触发的等待。因此,等待触发器后的语句将不会执行。

`include "uvm_macros.svh"
import uvm_pkg::*;module event_example();uvm_event e1;task process_A();$display("@%0t: Before triggering event e1", $time);e1.trigger;$display("@%0t: After triggering event e1", $time);endtasktask process_B();#10;$display("@%0t: waiting for the event e1", $time);e1.wait_trigger;$display("@%0t: event e1 is triggered", $time);endtaskinitial begine1 = new();forkprocess_A();process_B();joinend
endmodule

Output:

@0: Before triggering event e1
@0: After triggering event e1
@10: waiting for the event e1

4.1.3 Type C: An event is triggered at the same time as waiting for the event trigger

process_A和process_B没有延迟,以确保触发事件并等待事件触发同时发生。由于这两个进程是同时触发的,因此wait_trigger方法不会检测到事件触发。uvm_event提供了一个wait_ptrigger方法来解决这个race-around问题.

`include "uvm_macros.svh"
import uvm_pkg::*;module event_example();uvm_event e1;task process_A();$display("@%0t: Before triggering event e1", $time);e1.trigger;$display("@%0t: After triggering event e1", $time);endtasktask process_B();$display("@%0t: waiting for the event e1", $time);e1.wait_trigger;$display("@%0t: event e1 is triggered", $time);endtaskinitial begine1 = new();forkprocess_A();process_B();joinend
endmodule

Output:

@0: Before triggering event e1
@0: After triggering event e1
@0: waiting for the event e1

4.2 II. Event is triggered and waiting for the event to be triggered via the wait_ptrigger method

例如,有两个进程A和B。process_A任务用于触发事件e1,process_B任务用于使用wait_ptrigger等待事件。

4.2.1 Type A: An event is triggered after waiting for the event trigger.

process_A任务有10ns的延迟,确保在等待事件触发后触发事件e1。一旦e1事件被触发,通过wait_ptrigger()方法触发事件的等待将被解除阻止。

`include "uvm_macros.svh"
import uvm_pkg::*;module event_example();uvm_event e1;task process_A();#10;$display("@%0t: Before triggering event e1", $time);e1.trigger;$display("@%0t: After triggering event e1", $time);endtasktask process_B();$display("@%0t: waiting for the event e1", $time);e1.wait_ptrigger;$display("@%0t: event e1 is triggered", $time);endtaskinitial begine1 = new();forkprocess_A();process_B();joinend
endmodule

Output:

@0: waiting for the event e1
@10: Before triggering event e1
@10: After triggering event e1
@10: event e1 is triggered

4.2.2 Type B: An event is triggered before waiting for event trigger

process_B任务有10ns的延迟,确保在等待事件触发之前触发事件e1。由于之前触发了e1事件,因此通过wait()构造触发事件的等待不会被解除阻止。因此,等待触发器(使用@operator)后的语句将不会执行。

`include "uvm_macros.svh"
import uvm_pkg::*;module event_example();uvm_event e1;task process_A();$display("@%0t: Before triggering event e1", $time);e1.trigger;$display("@%0t: After triggering event e1", $time);endtasktask process_B();#10;$display("@%0t: waiting for the event e1", $time);e1.wait_ptrigger;$display("@%0t: event e1 is triggered", $time);endtaskinitial begine1 = new();forkprocess_A();process_B();joinend
endmodule

Output:

@0: Before triggering event e1
@0: After triggering event e1
@10: waiting for the event e1

4.2.3 Type C: An event is triggered at the same time as waiting for the event trigger.

`include "uvm_macros.svh"
import uvm_pkg::*;module event_example();uvm_event e1;task process_A();$display("@%0t: Before triggering event e1", $time);e1.trigger;$display("@%0t: After triggering event e1", $time);endtasktask process_B();$display("@%0t: waiting for the event e1", $time);e1.wait_ptrigger;$display("@%0t: event e1 is triggered", $time);endtaskinitial begine1 = new();forkprocess_A();process_B();joinend
endmodule

Output:

@0: Before triggering event e1
@0: After triggering event e1
@0: waiting for the event e1
@0: event e1 is triggered

4.3 III. Event is triggered with data and waiting for the event to be triggered and retrieve data using wait_on and get_trigger_data.

例如,有两个进程A和B。process_A任务用于触发事件e1,将事务对象作为数据发送,process_B任务用于等待事件和检索数据。

4.3.1 Type A: retrieve data using wait_on and get_trigger_data.

process_A任务具有10ns的延迟,确保在等待事件触发后触发事件e1。使用wait_on方法调用等待事件触发,一旦触发e1事件,就会取消阻止该方法调用。get_trigger_data用于检索上次调用触发器方法提供的数据。

`include "uvm_macros.svh"
import uvm_pkg::*;class transaction extends uvm_object;rand bit [7:0] addr;rand bit [7:0] data;function new(string name = "transaction");super.new(name);endfunction`uvm_object_utils_begin(transaction)`uvm_field_int(addr, UVM_PRINT);`uvm_field_int(data, UVM_PRINT);`uvm_object_utils_end
endclassmodule event_example();uvm_event e1;task process_A();transaction tr_A = new();#10;$display("@%0t: Before triggering event e1", $time);assert(tr_A.randomize);tr_A.print();e1.trigger(tr_A);$display("@%0t: After triggering event e1", $time);endtasktask process_B();uvm_object event_data;transaction tr_B;$display("@%0t: waiting for the event e1", $time);e1.wait_on();event_data = e1.get_trigger_data();$cast(tr_B, event_data);$display("@%0t: event e1 is triggered and data received = \n%s", $time, tr_B.sprint());endtaskinitial begine1 = new();forkprocess_A();process_B();joinend
endmodule

output:

@0: waiting for the event e1
@10: Before triggering event e1
-------------------------------------
Name         Type         Size  Value
-------------------------------------
transaction  transaction  -     @336 addr       integral     8     'ha3 data       integral     8     'h8f 
-------------------------------------
@10: After triggering event e1
@10: event e1 is triggered and data received = 
-------------------------------------
Name         Type         Size  Value
-------------------------------------
transaction  transaction  -     @336 addr       integral     8     'ha3 data       integral     8     'h8f 
-------------------------------------

相似的,也可以用wait_on和get_ptrigger_data。

4.3.2 Type B: retrieve data using wait_trigger_data

process_A任务具有10ns的延迟,确保在等待事件触发后触发事件e1。使用wait_trigger_data方法调用等待事件被触发,一旦e1事件被触发,该方法调用将被取消阻止。

wait_trigger_data = wait_trigger + get_trigger_data.// wait_trigger_data definition
virtual task wait_trigger_data (output T data); wait_trigger();data = get_trigger_data();
endtask

Example:

`include "uvm_macros.svh"
import uvm_pkg::*;class transaction extends uvm_object;rand bit [7:0] addr;rand bit [7:0] data;function new(string name = "transaction");super.new(name);endfunction`uvm_object_utils_begin(transaction)`uvm_field_int(addr, UVM_PRINT);`uvm_field_int(data, UVM_PRINT);`uvm_object_utils_end
endclassmodule event_example();uvm_event e1;task process_A();transaction tr_A = new();#10;$display("@%0t: Before triggering event e1", $time);assert(tr_A.randomize);tr_A.print();e1.trigger(tr_A);$display("@%0t: After triggering event e1", $time);endtasktask process_B();uvm_object event_data;transaction tr_B;$display("@%0t: waiting for the event e1", $time);e1.wait_trigger_data(event_data);$cast(tr_B, event_data);$display("@%0t: event e1 is triggered and data received = \n%s", $time, tr_B.sprint());endtaskinitial begine1 = new();forkprocess_A();process_B();joinend
endmodule

output:

@0: waiting for the event e1
@10: Before triggering event e1
-------------------------------------
Name         Type         Size  Value
-------------------------------------
transaction  transaction  -     @1798addr       integral     8     'h2f data       integral     8     'hb3 
-------------------------------------
@10: After triggering event e1
@10: event e1 is triggered and data received = 
-------------------------------------
Name         Type         Size  Value
-------------------------------------
transaction  transaction  -     @1798addr       integral     8     'h2f data       integral     8     'hb3 
-------------------------------------

类似的,可以用wait_ptrigger_data。

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

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

相关文章

云原生|kubernetes|kubernetes资源备份和集群迁移神器velero的部署和使用

前言: kubernetes集群需要灾备吗?kubernetes需要迁移吗? 答案肯定是需要的 那么,如何做kubernetes灾备和迁移呢?当然了,有很多的方法,例如,自己编写shell脚本,或者使用…

2023年终总结 —— 我和CSDN相遇的第一年之“技术学习和个人成长的回顾与展望”

​ ​ 🌈个人主页: Aileen_0v0 🔥热门专栏: 华为鸿蒙系统学习|计算机网络|数据结构与算法 💫个人格言:"没有罗马,那就自己创造罗马~" 目录 🎊对2023的总结与回顾🎊 🏅获奖记录 📚学…

用CSS中的动画效果做一个转动的表

<!DOCTYPE html> <html lang"en"><head><meta charset"utf-8"><title></title><style>*{margin:0;padding:0;} /*制作表的样式*/.clock{width: 500px;height: 500px;margin:0 auto;margin-top:100px;border-rad…

华为ensp网络设计期末测试题-复盘

网络拓扑图 地址分配表 vlan端口分配表 需求 The device is running!<Huawei>sys Enter system view, return user view with CtrlZ. [Huawei]un in en Info: Information center is disabled. [Huawei]sys S1 [S1]vlan 99 [S1-vlan99]vlan 100 [S1-vlan100]des IT [S1-…

机器学习系列--R语言随机森林进行生存分析(1)

随机森林&#xff08;Breiman 2001a&#xff09;&#xff08;RF&#xff09;是一种非参数统计方法&#xff0c;需要没有关于响应的协变关系的分布假设。RF是一种强大的、非线性的技术&#xff0c;通过拟合一组树来稳定预测精度模型估计。随机生存森林&#xff08;RSF&#xff0…

CSS之元素转换

我想大家在写代码时有一个疑问&#xff0c;块级元素可以转换成其他元素吗&#xff1f; 让我为大家介绍一下元素转换 1.display:block(转换成块元素) display&#xff1a;block可以把我们的行内元素或者行内块元素转换成块元素 接下来让我为大家演示一下&#xff1a; <!DO…

Blender:从新手到专家的全方位指南

Blender&#xff0c;这款强大的开源3D建模和渲染软件&#xff0c;已经成为了CG行业的标准工具之一。它不仅拥有丰富的教程资源&#xff0c;而且还在不断发展和完善中。尽管Blender的教程主要集中在国外网站和YouTube上&#xff0c;但其全面的功能和易用性使它成为许多人的首选工…

springcloud微服务篇--6.网关Gateway

一、为什么需要网关&#xff1f; 网关功能&#xff1a; 身份认证和权限校验 服务路由、负载均衡 请求限流 在SpringCloud中网关的实现包括两种&#xff1a; gateway zuul Zuul是基于Servlet的实现&#xff0c;属于阻塞式编程。而SpringCloudGateway则是基于Spring5中提供的Web…

初始Java

前言&#xff1a; 从今天开始&#xff0c;我们就进入Java的学习了&#xff0c;前期有很多语法是和C语言相同的&#xff0c;所以有些细节肯能会跳过&#xff08;希望各位有一门语言基础&#xff0c;最好是C&#xff09;。 配置环境变量&#xff1a; 在使用Java编译之前&#xf…

第2课 使用FFmpeg读取rtmp流并用openCV显示视频

本课对应源文件下载链接&#xff1a; https://download.csdn.net/download/XiBuQiuChong/88680079 这节课我们开始利用ffmpeg和opencv来实现一个rtmp播放器。播放器的最基本功能其实就两个:显示画面和播放声音。在实现这两个功能前&#xff0c;我们需要先用ffmpeg连接到rtmp服…

副业类小报童热门专栏TOP15

今天介绍15个副业小报童&#xff0c;可以说是当前小报童平台&#xff0c;副业类专栏的天花板内容了 这些专栏&#xff0c;都有免费内容可以查看&#xff0c;而且还是3天无理由退款的&#xff0c;完全可以尝试着订阅一波 关键单价都非常亲民&#xff0c;怎么都不亏&#xff01…

蓝桥杯嵌入式KEY

1.按键原理图 2.按键GPIO引脚设置成输入&#xff0c;上拉模式 3.设置TIM4时钟源为外部时钟源 PSC为80-1 Period为10000-1 打开NVIC 中断时间为10ms 4.在bsp文件中添加interrupt.c文件 5.按键单击代码 6.长按键 7.按键过程和显示过程