扫描二维码
随时随地手机看文章
//文件dut.v , dut很简单,每个clk上升沿到来时对输入a取反。`timescale 1ns/1nsmodule DUT (clk,a,b);input clk;input a;output b;reg b; always @ (posedge clk )begin b<=~a;end`include "assertion.svh"endmodule//文件 test.v`timescale 1ns/1nsmodule TOP;reg clk;reg a;wire b;always #5 clk=~clk;initial begin clk <=0; a <=1;#30 $finish;endDUT dut(.clk(clk),.a(a) ,.b(b));//bind TOP.dut dut_assertion dut_assertion_check(.a_(a),.b_(b),.clk_(clk));endmodule每个clk上升沿,如果a=0,则是空成功,不满足第一个a=1的条件,b就不需要判断是否等于1,直接判断为成功。如果a=1,则对b进行判断,b为1则为成功,否则断言失败。//assertion.svh文件property check_p; @(posedge clk) a |->b;endpropertycheck_a : assert property (check_p);运行命令:irun -sv dut.v test.vERROR:ncsim: *E,ASRTST (./assertion.svh,6): (time 5 NS) Assertion TOP.dut.check_a has failedmodule dut_assertion(a_,b_,clk_);input logic a_,b_,clk_;property check_p;@(posedge clk_) a_ |->b_;endproperty check_a : assert property (check_p);endmodule运行命令:irun -sv dut.v test.v assertion_module.svERROR:ncsim: *E,ASRTST (./assertion_module.sv,12): (time 5 NS) Assertion TOP.dut.dut_assertion_check.check_a has failed