首页 > 其他分享 >SystemVerilog -- 3.2 SystemVerilog Threads --> fork join_any

SystemVerilog -- 3.2 SystemVerilog Threads --> fork join_any

时间:2024-05-13 22:29:53浏览次数:20  
标签:fork join Thread -- time Main any SystemVerilog

fork join_any

在一个简单的SystemVerilog中,main thread会等到所有child thread都完成执行。这意味着如果任何child thread永远运行并且永远不会完成,则fork将挂起模拟。SystemVerilog还提供了带有fork joinfork join_any的原始版和变体。

如果任何一个child thread完成,则允许main thread继续执行位于fork之后的其它语句。如果启动了5 threads,则只有当5 threads中的任何一个thread完成执行时,main thread才会恢复执行。main thread恢复运行后,其余启动的4 threads将继续在后台运行。

Syntax

fork
  // Thread 1
  // Thread 2
  // ...
  // Thread N
join_any

fork join_any Example

module tb;
  initial begin
    $display ("[%0t] Main Thread: Fork join going to start", $time);
    fork
      print (20, "Thread1_0");
      print (30, "Thread1_1");
      print (10, "Thread2"); 
    join_any
    $display ("[%0t] Main Thread: Fork join has finished", $time);
  end

  // Note that this task needs to be automatic
  task automatic print (int _time, string t_name);
    #(_time) $display ("[%0t] %s", $time, t_name);
  endtask
endmodule

模拟日志

ncsim> run
[0] Main Thread: Fork join going to start
[10] Thread2
[10] Main Thread: Fork join has finished
[20] Thread1_0
[30] Thread1_1
ncsim: *W,RNQUIE: Simulation is complete.

Nested fork join_any

module tb;
  initial begin
    $display ("[%0t] Main Thread: Fork join going to start", $time);
    fork 
      fork
        print (20, "Thread1_0");
        print (30, "Thread1_1");
      join_any
    print (10, "Thread2");
    join_any
    $display ("[%0t] Main Thread: Fork join has finished", $time);
  end

  // Note that this task has to be automatic
  task automatic print (int _time, string t_name);
    #(_time) $display ("[%0t] %s", $time, t_name);
  endtask
endmodule

模拟日志

ncsim> run
[0] Main Thread: Fork join going to start
[10] Thread2
[10] Main Thread: Fork join has finished
[20] Thread1_0
[20] Thread1_1
ncsim: *W,RNQUIE: Simulation is complete.
ncsim> exit

标签:fork,join,Thread,--,time,Main,any,SystemVerilog
From: https://www.cnblogs.com/sys-123456/p/18188245

相关文章

  • vscode plantuml
    创建文件test.wsd@startumlBob->Alice:hello@endumlplantumlhttps://pdf.plantuml.net/1.2020.23/PlantUML_Language_Reference_Guide_zh.pdfplantumlideahttps://blog.csdn.net/qq_52302333/article/details/131341626plantuml......
  • 面向可复用性和可维护性的设计模式
    面向可复用性和可维护性的设计模式HITSoftwareConsturction哈工软件构造课程内容回顾——DesignPatternsforReuseandMaintainbality面向可复用性和可维护性的设计模式Outline(课件)CreationalpatternsFactorymethodpatterncreatesobjectswithoutspecifying......
  • 使用 Playwright 复用 Cookie:简化自动化测试的高效方法
    前言在进行自动化测试时,有时需要在多个测试用例之间共享相同的会话状态。为了实现这一目标,Playwright提供了一种称为Cookie复用的功能,可以让我们在不同的测试用例之间共享同一组Cookie数据。本文将深入介绍如何使用Playwright复用Cookie,并探讨其使用方法和优势。什么是......
  • js播放背景音乐失败处理
    <script>constmusic=newAudio('med/CanonInD.mp3');music.loop=true;document.addEventListener("DOMContentLoaded",function(event){console.log("页面加载完毕"); if(music.paused){//console.log('音频......
  • 无需手动操作:利用 Playwright 自动上传文件
    前言Playwright是一个由Microsoft开发的自动化测试工具,它提供了跨浏览器的自动化测试能力,包括Chrome、Firefox和Safari。除了测试之外,Playwright还可以用于执行浏览器操作,例如模拟用户行为来实现文件上传功能。在本文中,我们将使用Playwright和Python实现自动上传文件......
  • QT开发工具QTCreator设置格式美化,代码补全提示
    工欲善其事,必先利其器:下面介绍如何配置格式美化功能(1)先下载:astyle.exe (2)编辑astyle.astylerc点击Apply->OK (3)帮助 重启软件:测试效果 格式化化后: ......
  • HarmonyOS 使用关系型数据库进行增删改查
    HarmonyOS中的关系型数据库基于SQLite组件,提供了一套完整的对本地数据库进行管理的机制。它支持事务、索引、视图、触发器、外键、参数化查询和预编译SQL语句等特性。关系型数据库适用于存储包含复杂关系数据的场景,例如学生信息或雇员信息,这些数据之间有较强的对应关系。操......
  • 深入探索:使用 Playwright 处理下拉框的完整指南
    前言在Web应用程序中,下拉框是常见的用户界面元素之一,通常用于选择列表中的选项。在自动化测试中,与下拉框的交互是必不可少的一部分。Playwright是一个强大的自动化测试工具,提供了处理下拉框的灵活方法。本文将深入介绍如何使用Python结合playwright编写代码来处理各种类型......
  • 实验四代码审查
    目录一、实验题目:代码审查二、实验目的三、实验内容四、实验要求五、代码自动化格式审查结果截图六、根据审查结果修改代码格式前后对比图(可以截取部分)七、实验中遇到的问题及解决方法八、代码走查表九、有关链接一、实验题目:代码审查二、实验目的1、熟悉编码风格,利用开发环......
  • H&NCTF
    总排名:67不用看,没写几题总结:比赛真的不错,还有游戏可以玩,mc好玩,hnwanna玩得血压高misc签到、问卷、签退111mc题好玩cryptobabyAES有点偏杂项源码:fromCrypto.CipherimportAESfromCrypto.Util.Paddingimportpadfromsecretimportflagimporttimeimportr......