【问题标题】:Why are "if..else" statements not encouraged within systemverilog assertion property?为什么 systemverilog 断言属性中不鼓励“if..else”语句?
【发布时间】:2021-01-23 06:53:49
【问题描述】:

我正在为以下结构编写断言检查

基本上,我想检查选择信号为 0 时输出是否等于 d1,选择信号为 1 时输出是否等于 d2。

我做了这样的事情:

property check_mux_out (clk, rst, en, d1, output, d2, select);
   @(posedge clk)
   if (select)
      (rst==0) && (en==1) |-> (output === d2);
   else
      (rst==0) && (en==1) |-> (output === d1);
endproperty

a1: assert property (check_mux_out(inst1_clk, inst1_rst, latch_en, signal1, inst_out, signal2, inst_select)) else $error("ERROR: output not equal input");

但是我发现了一些来自 https://verificationacademy.com/forums/systemverilog/conditional-statement-assertion-propertyhttps://verificationacademy.com/forums/systemverilog/clock-period-checker-sva 这似乎表明 if..else 语句不应在 systemverilog 属性中使用。为什么会这样?我做错了什么,为什么?

【问题讨论】:

    标签: verilog system-verilog hdl system-verilog-assertions


    【解决方案1】:

    我想,唯一的建议是避免编写大属性。很容易弄乱代码。 if/else 只是增加了大小并有可能进一步混淆它。

    您的代码存在语法错误。您不能使用关键字outptut 作为变量名。在您的代码中,if 子句之后还有一个额外的;

    property check_mux_out (clk, rst, en, d1, out, d2, select);
       @(posedge clk)
       if (select)
          (rst==0) && (en==1) |-> (out === d2) // << no ';'
       else
          (rst==0) && (en==1) |-> (out === d1);
    endproperty
    

    你也可以用不同的方式重写它:

    property check_mux_out (clk, rst, en, d1, out, d2, select);
       @(posedge clk)
         (rst==0) && (en==1) |-> if (select) (out === d2) else (out === d1);
    endproperty
    

    甚至没有 if/else

    property check_mux_out (clk, rst, en, d1, out, d2, select);
       @(posedge clk)
      (rst==0) && (en==1) |-> (select) ? (out === d2) : (out === d1);
    endproperty
    

    【讨论】:

      猜你喜欢
      • 2020-03-01
      • 2012-10-03
      • 1970-01-01
      • 2015-02-03
      • 1970-01-01
      • 1970-01-01
      • 2015-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多