首页 > 其他分享 >SystemVerilog -- 3.5 SystemVerilog repeat

SystemVerilog -- 3.5 SystemVerilog repeat

时间:2024-05-05 19:56:06浏览次数:12  
标签:begin Repeat num -- 3.5 SystemVerilog statement end repeat

一组给定的语句可以使用构造执行N次。repeat

Syntax

repeat (<number>)
  // Single Statement

repeat (<number>) begin
  // Multiple Statements
end

Example #1

module tb;
  initial begin
    repeat (5) begin
      $display ("Repeat this statement");
    end
  end
endmodule

模拟日志

ncsim> run
Repeat this statement
Repeat this statement
Repeat this statement
Repeat this statement
Repeat this statement
ncsim: *W,RNQUIE: Simulaltion is complete.

循环也可以使用循环实现,但更冗长。如果不需要在循环中引用变量i,则循环会更合适。repeat for repeat

for (int i = 0; i < number; i++) begin
  // Code
end

在下面显示的代码中,我们有一个循环来等待给定数量的时钟周期。repeat

module tb;
  bit clk;
  always #10 clk = ~clk;

  initial begin
    bit [2:0] num = $random;

    $display ("[%0t] Repeat loop is going to start with num = %0d", $time, num);
    repeat (num) @(posedge clk);
    $display ("[%0t] Repeat loop has finished", $time);
    $finish;
  end
endmodule

在此示例中,时钟周期为20ns,时钟的第一个位置发生在10ns。接下来的3个时钟位置发生在30ns、50ns和70ns之间,之后初始块结束。因此,此循环成功等待,直到4个时钟结束。repeat

模拟日志

ncsim> run
[0]  Repeat loop is going to start with num = 4
[70] Repeat loop has finished
ncsim: *W,RNQUIE: Simulaltion is complete.

标签:begin,Repeat,num,--,3.5,SystemVerilog,statement,end,repeat
From: https://www.cnblogs.com/sys-123456/p/18173783

相关文章

  • NVIDIA的ROS项目 —— Isaac ROS
    文档地址:https://nvidia-isaac-ros.github.io/index.htmlGithub地址:https://github.com/NVIDIA-ISAAC-ROS......
  • qoj1138 Counting Mushrooms
    交互题。有一个隐藏的01序列\(a\),你只知道\(a\)的长度,并记为\(n\)。保证\(a_1=0\)。你可以执行以下操作:询问一个序列\(b\),满足两两不同且长度在\([2,1000]\)之间。交互库会返回\(\sum[a(b_i)\not=a(b_{i+1})]\)。请在\(226\)次操作内求出\(a\)中\(0\)......
  • 2024 年12个好用的开源 Wiki 软件工具盘点
    在任何成功的公司中,部门间的知识共享是至关重要的。如果没有一个简单的信息交流方法,团队怎样才能有效合作呢?Wiki软件提供了一种创建、组织及在全公司范围内分享知识的直接方法。但是,哪一种Wiki软件是最佳的选择呢?本文将深入讨论这个问题。什么是Wiki软件Wiki是一个集中式的、基......
  • 讯飞听见软件介绍
    讯飞听见是一款智能语音转文字软件,具有以下功能:•实时语音转文字:支持录音实时转文字,准确率较高,且能自动区分角色和分段。•实时翻译:提供8国语种随时互译。•边录边拍:可以在录音的同时拍照记录,方便重点标记。•悬浮字幕:支持在观看视频时实时显示悬浮字幕,提供无障碍观影体......
  • Less11基于post提交的单引号闭合的字符型注入
    Less11基于post提交的单引号闭合的字符型注入一、手工注入1.判断注入点判断注入类型是否为数字型1or1=11or1=2发现页面显示相同,因此不是数字型判断注入类型是否为字符型1'or1=1#1'or1=2#发现1=2页面异常报错,1=1正常。所以是单引号字符型闭合。2.爆破字段......
  • SystemVerilog -- 3.4 SystemVerilog forever loop
    SystemVerilogforeverloop循环永远运行,或者无限时间运行。foreverSyntaxforever//Singlestatementforeverbegin//Multiplestatementsend循环类似于下面Verilog中所示的代码。两者都运行无限的仿真时间,并且在它们内部有一个延迟元件很重要。foreverAn......
  • C. Game on Permutation
    链接:https://codeforces.com/problemset/problem/1860/C洛谷链接:https://www.luogu.com.cn/problem/CF1860C相关知识点复习:LIS最长上升子序列链接:https://blog.csdn.net/lxt_Lucia/article/details/81206439关键:这题的思路在于找到LIS长度为2的点,比如13254那么显然3,2是......
  • 0505一般质疑
    一般质疑底层逻辑质疑方式无论据有结论A和非A的矛盾有理由的得出相反的结论有论据有结论--近似看成A=》B-和A且非B矛盾绝大多数肯定论据得出相反结论--得不出该结论......
  • SystemVerilog -- 3.3 SystemVerilog for loop
    SystemVerilogforloopSystemVerilog中的循环多次重复一组给定的语句,直到不满足给定的表达式。与所有其他过程块一样,循环中需要多个语句被for和forbeginend关键字括起来。SyntaxFor循环使用三步方法控制其语句的执行:初始化影响循环运行次数的变量在执行循环之前,请检查条......
  • @FixMethodOrder(MethodSorters.NAME_ASCENDING)的作用
    importorg.junit.*;importstaticorg.junit.Assert.*;importorg.junit.Test;importorg.junit.runners.MethodSorters;/***UserService测试类*///TODO填写顺序执行的代码@FixMethodOrder(MethodSorters.NAME_ASCENDING)publicclassUserServiceTest{staticUserServ......