如何在Systemverilog中使用递归属性

时间:2015-06-24 01:17:17

标签: recursion properties system-verilog assertion system-verilog-assertions

要验证的模块如下...... 模块在交替的时钟周期内有输入in1和输出out1,out1是in1的缓冲和反转值。

我尝试使用递归属性对checker模块进行编码。

module check (input in1, out1, clk);

    property p1(bit state);
        bit nxt;
        @(posedge clk) 
        (1 ,nxt=!state) |-> (out1 == (nxt) ? !in1 : in1) and 
                             nexttime p1(nxt);
    endproperty

    initial assert property(p1(0)) else $fatal(3, "Failed!");

endmodule

但是,在edaplayground上运行代码会引发此错误...

  

RROR VCP2000"语法错误。意外的令牌:nexttime [_NEXTTIME]。该   ' nexttime'是SystemVerilog关键字,不能用作   标识符

我知道这个断言可以在没有递归的情况下完成,但是我想使用递归来编写它。

1 个答案:

答案 0 :(得分:2)

错误表明您以错误的方式使用了nexttime这是一个systemverilog属性关键字。该运算符检查“如果时钟再次滴答,那么a将在下一个时钟滴答时为真”,如下代码所示

property p1;
  nexttime a;
endproperty

默认情况下,应在每个时钟脉冲上检查并发断言,因此这里不需要递归。 粗略,您可以这样做:

module check (input in1, out1, clk);
bit o_nxt;

function bit update(input bit nxt);
o_nxt = nxt;
return 1;
endfunction

    property p1(bit state);
        bit nxt;
        @(posedge clk) 
        (1 ,nxt=!state) |-> (out1 == (nxt) ? !in1 : in1) and 
                             update(nxt);
    endproperty

    initial assert property(p1(o_nxt)) else $fatal(3, "Failed!");

endmodule