首页 > 其他分享 >SystemVerilog -- 3.7 SystemVerilog 'unique' and 'priority' if-else

SystemVerilog -- 3.7 SystemVerilog 'unique' and 'priority' if-else

时间:2024-05-05 20:55:55浏览次数:11  
标签:ncsim -- else priority 0d unique display SystemVerilog

SystemVerilog 'unique' and 'priority' if-else

条件语句用于决定是否执行语句。if else

SystemVerilog 引入了一下用于违规检查的构造。if else

  • unique-if
  • unique0-if
  • priority-if

unique-if, unique0-if

unique-if按任意顺序评估条件,并执行以下操作:

  • 当所有条件都不匹配时,报告错误,除非有显示。if else
  • 当在条件中找到超过1个匹配项时报告ERORR。if else
Unlike unique-if, unique0-if does not report a violation if none of the conditions match

No else block for unique-if

module tb;
  int x = 4;

  initial begin
    // This if else if construct is declared to be "unique"
    // Error is not reported here because there is a "else"
    // clause in the end which will be triggered when none of the conditions match
    unique if (x == 3)
      $display ("x is %0d", x);
    else if (x == 5)
      $display ("x is %0d", x);
    else
      $display ("x is neither 3 nor 5");

    // When none of the conditions become true and there is no "else" clause, then an error is reported
    unique if (x == 3)
      $display ("x is %0d", x);
    eles if (x == 5)
      $display ("x is %0d", x);
  end
endmodule

模拟日志

ncsim> run
x is neither 3 nor 5
ncsim: *W,NOCOND: Unique if violation: Every if clause was false.
        File: ./testbench.sv, line = 18, pos = 13
        Scope: tb
        Time: 0 FS + 1
ncsim: *W,RNQUIE: Simulation is complete.

Multiple matches in unique-if

module tb;
  int x = 4;

  initial begin
    // This if else if construct is declared to be "unique"
    // When multiple if blocks match, then error is reported
    unique if (x == 4)
      $display ("1. x is %0d", x);
    else if ()
      $display ("2. x is %0d", x);
    else
      $display ("x is not 4");
  end
endmodule

模拟日志

ncsim> run
1. x is 4
ncsim: *W,NOCOND: Unique if violation: Multiple true if clauses at {line=8:pos=15 and line=10:pos=13}.
        File: ./testbench.sv, line = 8, pos = 15
        Scope: tb
        Time: 0 FS + 1
ncsim: *W,RNQUIE: Simulation is complete.

priority-if

priority-if按顺序评估所有条件,并在以下情况下报告违规行为:

  • 没有一个条件为真,或者如果最终构造没有子句。else if

No else clause in priority-if

module tb;
  int x = 4;

  initial begin
    // This if else if construct is declared to be "priority"
    // Error is not reported here because there is a "else"
    // clause in the end which will be triggered when none of the conditions match
    priority if (x == 3)
      $display ("x is %0d", x);
    else if (x == 5)
      $display ("x is %0d", x);
    else
      $display ("x is neither 3 nor 5");

    // When none of the conditions become true and there is no "else" clause, then an error is reported
    priority if (x == 3)
      $display ("x is %0d", x);
    else if (x == 5)
      $display ("x is %0d", x);
  end
endmodule

模拟日志

ncsim> run
x is neither 3 nor 5
ncsim: *W,NOCOND: Unique if violation: Every if clause was false.
        File: ./testbench.sv, line = 18, pos = 15
        Scope: tb
        Time: 0 FS + 1
ncsim: *W,RNQUIE: Simulation is complete.

Exit after first match in priority-if

module tb;
  int x = 4;

  initial begin
    // Exits if-else block once the first match is found
    priority if (x == 4)
      $display ("x is %0d", x);
    else if (x != 5)
      $display ("x is %0d", x);
  end
endmodule

模拟日志

ncsim> run
x is 4
ncsim: *W,RNQUIE: Simulation is complete.

标签:ncsim,--,else,priority,0d,unique,display,SystemVerilog
From: https://www.cnblogs.com/sys-123456/p/18173812

相关文章

  • NVIDIA机器人仿真环境 —— NVIDIA Isaac Sim 的headless模式/无头模式 —— 非桌面模
    相关:https://developer.nvidia.com/isaac-sim可视化模式,也就是在桌面系统上直接安装软件,具体地址:https://developer.nvidia.com/isaac-sim无头模式则是使用docker安装,该种情况下不使用可视化界面,所有操作均在docker容器内,地址:https://catalog.ngc.nvidia.com/orgs/nvid......
  • 树上求一个点邻域信息的一种简单求法
    有人说,直接点分树,力大砖飞,非常不错!实际上这种做法非常的垃圾,很多时候我们使用点分树,一定是不得不使用点分树,比如模板题,强制在线,非常的恶心,所以我们使用点分树。而点分树是否必要呢?既然你能看到这篇blog,他肯定是不必要的!我们今天来发掘dsuontree的美妙性质,让他求解这个问题!然......
  • spring项目创建
    从springinitializer下载一个demoSpringboot 在idea中需要配置java版本和maven版本之后:mvnpackage不需要下载tomcat,Spring里面pom中包含内置tomcat<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-star......
  • [省选联考 2021 A 卷] 矩阵游戏
    如果直接构造的话由于有a范围的限制,同时还要满足b的性质,非常恶心。考虑将两个性质分开考虑。首先如果我们确定了矩阵的第一行和第一列,那么我们就可以确定这个矩阵了。我们先构造出一个合法的矩阵,然后再对矩阵的第一行和第一列进行微调,是所有数都没满足范围。容易想到,比如要将\(a_......
  • 高一下三调|ssy的队列|hash dp|题解
    SSY的队列题目链接解析:考场上看到这个题第一眼是绝望的,毕竟数论咱是一窍不通.但是往下细看了看这个数据范围,N是很小的,就想了想模拟.然而只骗到10分.这个题绩效较高的解法是状压dp,在N<15的范围之内均可薄纱(ppllxx_9G也是成功拿到这70rank1了orz),可得70,但是一到后......
  • Git——关于Git的一些补充(1)
    Git——关于Git的一些补充(1)提示:图床在国外且动图比较多的情况下,需要时间加载。目录:目录Git——关于Git的一些补充(1)提示:图床在国外且动图比较多的情况下,需要时间加载。目录:Git基础Git文件的生命周期Git文件的存储空间的划分Git安装过程补充说明Git的撤销操作修正上一次的提交撤......
  • UHF RFID 使用小记
    1,概念UHF:UltraHighFrequency;超高频。RFID:RadioFrequencyIdentification;射频识别。电子标签:即RFID标签,是RFID的俗称。PDA:PersonalDigitalAssistant;个人数字助理。发卡器:对卡进行读写操作的工具。EPC:Electronicproductcode;电子产品代码。2,原理标签进入阅读器发出的......
  • 3. SpringBoot 整合第三方技术
    1.整合Junit一般来说是不需要进行处理的,因为在创建SpringBoot工程时,会自动整合junit​的要说怎么配置的话?也可以写一下相关的配置:以下就是SpringBoot整合Junit相关步骤导入相关依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-b......
  • go高并发之路——缓存击穿
    缓存击穿,Redis中的某个热点key不存在或者过期,但是此时有大量的用户访问该key。比如xxx直播间优惠券抢购、xxx商品活动,这时候大量用户会在某个时间点一同访问该热点事件。但是可能由于某种原因,redis的这个热点key没有设置,或者过期了,那么这时候大量高并发对于该key的请求就得不到red......
  • JS实现获取当前URL和来源URL的方法
    通用模式:Javascript正常取来源网页的URL只要用:index.html:<!DOCTYPEhtml><htmllang="zh-cn"><head><metacharset="UTF-8"><metaname="viewport"content="width=device-width,initial-scale=1,maximum-scale=......