16.14.17 推断值函数
下面这些详尽的时间系统函数可用于查询推断的时钟事件表达式和禁用表达式:
(1)$inferred_clock 返回推断的时钟事件的表达式
(2)$inferred_disable 返回推断的禁用表达式
module m(logic a, b, c, d, rst1, clk1, clk2);
logic rst;
default clocking @(negedge clk1); endclocking
default disable iff rst1;
property p_triggers(start_event, end_event, form, clk = $inferred_clock,
rst = $inferred_disable);
@clk disable iff (rst)
(start_event ##0 end_event[->1]) |=> form;
endproperty
property p_multiclock(clkw, clkx = $inferred_clock, clky, w, x, y, z);
@clkw w ##1 @clkx x |=> @clky y ##1 z;
endproperty
a1: assert property (p_triggers(a, b, c));
a2: assert property (p_triggers(a, b, c, posedge clk1, 1'b0) );
always @(posedge clk2 or posedge rst) begin
if (rst) ... ;
else begin
a3: assert property (p_triggers(a, b, c));
...
end
end
a4: assert property(p_multiclock(negedge clk2, , posedge clk1,
a, b, c, d) );
endmodule
上述代码在逻辑上等价于如下代码:
module m(logic a, b, c, d, rst1, clk1, clk2);
logic rst;
a1: assert property (@(negedge clk1) disable iff (rst1)
a ##0 b[->1] |=> c);
a2: assert property (@(posedge clk1) disable iff (1'b0)
a ##0 b[->1] |=> c);
always @(posedge clk2 or posedge rst) begin
if (rst) ... ;
else begin
...
end
end
a3: assert property
(
@(posedge clk2) disable iff (rst1)
(a ##0 b[->1]) |=> c
);
a4: assert property (@(negedge clk2) a ##1 @(negedge clk1) b |=>
@(posedge clk1) c ##1 d);
endmodule
在断言a1中,时钟事件是从默认时钟推断出来的,因此$inferred_clock是a1的negedge clk1。在断言a2中,事件表达式posedge clk1被传递给属性p_triggers实例中的形式参数clk。因此,在该实例中$inferred_clock不用于clk;在断言a3中,always程序的事件控制推断出断言a3的时钟事件,因此,a3的$inferred_clock是posedge clk2;在断言a4中,当属性p_multiclock在assert property语句中实例化时,clkw被实际参数(negedge clk2)替换,clkx被默认参数值$experted_clock替换,该默认参数值是断言中属性实例位置处的默认时钟(negedge clk1)。第三个时钟clky被实际参数(posedge clk1)替换,因为它是显式指定的。从默认的disable语句推断断言a1和a3的禁用条件rst1,断言a2使用显式重置值1'b0,在这种情况下,可以在等效断言中完全省略disable iff语句。