SystemVerilog -- 3.0 SystemVerilog Threads

news/2024/9/25 17:22:00

SystemVerilog Threads

What are SystemVerilog threads or processes ?

thread 或 process 是作为单独实体执行的任何一段代码。在 verilog 中,每个initialalways块都作为单独的 thread 生成,这些 threads 从 0 time 开始并行运行。block 还会创建并运行的不同 threads。fork join

What are different fork - join styles ?

我们在 SystemVerilog 中有三种不同的风格。fork join

/ /
fork join Finshes when all child threads are over
fork join_any Finshes when any child thread ges over
fork join_none Finshes when soon after child threads are spawned

Where is this used in the testbench ?

验证环境中的组件可能需要能够同行运行多个tasks。例如,一个 process 可能会等待某些事情发生,而另一个 process 继续执行其他一些 tasks。他们都通过fork ... join作为单独的线程生成。例如,checker 可以并行生成不同的tasks,以捕获和验证来自测试平台不同部分的数据。 fork ... join

What is the limitation of a Verilog fork join ?

只有在 fork-join 内生成的所有 threads 都完成时,才会执行 a 之后的代码。因此,checker 必须等到在 fork-join 中生成的所有 thrads 完成,然后才能继续。 fork ... join

fork join Example

SystemVerilog 会等到所有 forked processes 都完成。 fork join

module tb_top;initial begin#1 $display ("[%0t ns] Start fork ...", $time);// Main Process: Fork these processes in parallel and wait untill all of them finishfork// Thread1 : Print this statement after 5ns from start of fork#5 $display ("[%0t ns] Thread1: Orange is named after orange", $time);// Thread2 : Print these two statements after the given delay from start of forkbegin#2 $display ("[%0t ns] Thread2: Apple keeps the doctor away", $time);#4 $display ("[%0t ns] Thread2: But not anymore", $time);end// Thread3 : Print this statement after 10ns from start of fork#10 $display ("[%0t ns] Thread3: Banana is a good fruit", $time);join// Main Process: Continue with rest of statements once fork-join is over$display ("[%0t ns] After Fork-Join", $time);end
endmodule

模拟日志

ncsim> run
[1 ns] Start fork ...
[3 ns] Thread2: Apple keeps the doctor away
[6 ns] Thread1: Orange is named after orange
[7 ns] Thread2: But not anymore
[11 ns] Thread3: Banana is a good fruit
[11 ns] After Fork-Join
ncsim: *W,RNQUIE: Simulation is complete.

fork join_any Example

SystemVerilog 会等待,直到任何一个 forked processes 是完成的。fork join_any

module tb_top;initial begin#1 $display ("[%0t ns] Start fork ...", $time);// Main Process: Fork these processes in parallel and wait untill any one of them finishfork// Thread1 : Print this statement after 5ns from start of fork#5 $display ("[%0t ns] Thread1: Orange is named after orange", $time);// Thread2 : Print these two statements after the given delay from start of forkbegin#2 $display ("[%0t ns] Thread2: Apple keeps the doctor away", $time);#4 $display ("[%0t ns] Thread2: But not anymore", $time);end// Thread3 : Print this statement after 10ns from start of fork#10 $display ("[%0t ns] Thread3: Banana is a good fruit", $time);join_any// Main Process: Continue with rest of statements once fork-join is exited$display ("[%0t ns] After Fork-Join", $time);end
endmodule

模拟日志

ncsim> run
[1 ns] Start fork ...
[3 ns] Thread2: Apple keeps the doctor away
[6 ns] Thread1: Orange is named after orange
[6 ns] After Fork-Join
[7 ns] Thread2: But not anymore
[11 ns] Thread3: Banana is a good fruit
ncsim: *W,RNQUIE: Simulation is complete.

fork join_none Example

SystemVerilog 不会等待并立即退出block,允许 forked processes 在后台运行。main thread 恢复执行block之后的语句。 fork join_none fork join_none

module tb_top;initial begin#1 $display ("[%0t ns] Start fork ...", $time);// Main Process: Fork these processes in parallel and exits immediatelyfork// Thread1 : Print this statement after 5ns from start of fork#5 $display ("[%0t ns] Thread1: Orange is named after orange", $time);// Thread2 : Print these two statements after the given delay from start of forkbegin#2 $display ("[%0t ns] Thread2: Apple keeps the doctor away", $time);#4 $display ("[%0t ns] Thread2: But not anymore", $time);end// Thread3 : Print this statement after 10ns from start of fork#10 $display ("[%0t ns] Thread3: Banana is a good fruit", $time);join_none// Main Process: Continue with rest of statements once fork-join is exited$display ("[%0t ns] After Fork-Join", $time);end
endmodule

模拟日志

ncsim> run
[1 ns] Start fork ...
[1 ns] After Fork-Join
[3 ns] Thread2: Apple keeps the doctor away
[6 ns] Thread1: Orange is named after orange
[7 ns] Thread2: But not anymore
[11 ns] Thread3: Banana is a good fruit
ncsim: *W,RNQUIE: Simulation is complete.

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

24年5.12流片复盘

非常值得纪念的一天,因为去年这个时候流片delay,今年顺利流出去了,这是一个大的进步,但是还是要做复盘。 首先是进度整体上的复盘。这次流片从一月初开始进行规划,到五月初投片,总共花费五个月时间,五个月内,按照最初的时间规划,一月是把规划基本都做完,给项目参与人…

kettle从入门到精通 第五十九课 ETL之kettle 邮件发送多个附件,使用正则轻松解决

问题场景: 一个朋友说他用kettle将生成好的多个文件(a.xls和b.xls,文件在data目录下)发送给客户,但是data目录下还有其他的文件,他如果指定data目录发送会把 data目录下面的所有文件都作为附件进行发送,显然不符合要求,所以他当时的临时解决方法是创建个临时目录,里面…

VSCode养宠物

安装扩展vscode-pets https://marketplace.visualstudio.com/items?itemName=tonybaloney.vscode-pets 安装好后点击右下角的小松鼠图标选择一个宠物 选择一个颜色 起一个名字 回车 如果想要删除 ctrl + shift + p Pet Coding: Remove pet

抽丝剥茧:详述一次DevServer Proxy配置无效问题的细致排查过程

事情的起因是这样的,在一个已上线的项目中,其中一个包含登录和获取菜单的接口因响应时间较长,后端让我尝试未经服务转发的另一域名下的新接口,旧接口允许跨域请求,但新接口不允许本地访问(只允许发布测试/生产的域名访问)。 问题 那么问题来了,本地环境该如何成功访问到…

QT: Expression:c = -1 c = 255

报错内容分析错误 注意看报错位置位于isctype.cpp文件的Line:36我们打开isctype.cpp,其36行内容如下 extern "C" int __cdecl _chvalidator(int const c, int const mask) {_ASSERTE(c >= -1 && c <= 255);return _chvalidator_l(nullptr, c, mask); …

Pyqt6Pyside6 信号与槽详解

信号与槽 对于可视化编程,需要将界面上的控件有机结合起来,实现控件功能的联动和交互操作。比如点击按钮,实现某项功能。对按钮功能的定义,是通过信号(signal)与槽(slot)机制实现的。信号与槽是PySide6编程的基础,也是Qt的一大创新,有了信号与槽的编程机制,在PySide6中处…

minio依赖报错

引入minio-sdk后启动报错 现象一 1缺失kotlin.collections.ArraysKt.copyInto([B[BIII)[B解决方法 提升kotlin-stdin依赖 <dependency><groupId>org.jetbrains.kotlin</groupId><artifactId>kotlin-stdlib</artifactId><version>1.3.70<…

黄河流域挑战赛WEB部分-gxngxngxn

黄河流域公安院校挑战赛WEB部分-gxngxngxn myfavorPython pickle反序列话,开启debug,用报错 import os import pickle import base64 class A():def __reduce__(self):return (exec,("raise Exception(__import__(os).popen(cat flag.txt).read())",))a = A() b = …