Assertion for D Flip Flop

Hi everyone, I was trying to write assertion for my D-Flip Flop code but I am getting “assertion error” for my second property. My DFF is Asynchronous active high reset. Here is my code :
/////////////////////////////////////////////////ASSERTION LOGIC////////////////////////////
property check_reset;
@(reset)
reset |-> q==0;
endproperty

property check_d;
@(posedge clk)
disable iff (reset)
(q ==$past(d));
endproperty

acheck_reset:assert property(check_reset);
acheck_d: assert property(check_d);
////////////////////////////////////////////DFF LOGIC///////////////////////////////////////////
always@(posedge clk,reset)
begin
if(reset)
begin
q <= 4’b0000;
end
else if (!reset)
q<= d;
end
//////////////////////////////////////////////////////////////////////////////////////////////

In reply to navjeet1503:
1800 16.9.3 Sampled value functions states: If there do not exist k strictly prior time steps in which the event ev iff expression2 occurred, then the value returned from the $past function is the default sampled value of expression1 (see 16.5.1).
Thus, on the very first clocking event, $past(d) is the default value of d.
Therefore, in the very first clocking event, (q ==$past(d)) will fail if q=='X.
To fix this, do the following


property check_d;
  @(posedge clk) disable iff (reset)
   (##1 q ==$past(d));
endproperty 

Meaning that every assertion test of q is delayed by 1 clock. In other words, at clock 3, q is tested at clock 4, and its value should be the value of d at clock 3.

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us
For training, consulting, services: contact Home - My cvcblr


  1. VF Horizons:PAPER: SVA Alternative for Complex Assertions | Verification Academy
  2. http://systemverilog.us/vf/SolvingComplexUsersAssertions.pdf
  3. “Using SVA for scoreboarding and TB designs”
    http://systemverilog.us/papers/sva4scoreboarding.pdf
  4. “Assertions Instead of FSMs/logic for Scoreboarding and Verification”
    October 2013 | Volume 9, Issue 3 | Verification Academy
  5. SVA in a UVM Class-based Environment
    SVA in a UVM Class-based Environment | Verification Horizons | Verification Academy

In reply to ben@SystemVerilog.us:

Thank you Ben for a quick response. I got your point.

Regards
Navjeet