I am trying to implement a checker using assertion to check all th clocks of clock divider must be phase alligned w.r.to a strobe signal.
I wrote assertion following way -
There are many issues with your assertions because of the clocking and sampling in SVA.
I suggest creating 2 stobe signals, one before and and one after the edge you are verifying, and checking th values of the signals of interest, I. E., 0 before, 1 after.
Thus, in an assertion, that would be a 2 clock ckeck of the values of the signals, no rose.
Following @(posedge div_clk_strb)you want to check that that clk_div1, clk_div2 and clk_div4 signals rose after being clocked by dfe_clk_src. This is how I read you timing diagram.
My assertion states that
Following @(posedge div_clk_strb)
at the next @(posedge dfe_clk_src), the sampling values of lk_div1, clk_div2 and clk_div4 are all zeros
This is then followed that at the next @(negedge dfe_clk_src) the sampling values of lk_div1, clk_div2 and clk_div4 are all ONES
THUS ESSENTIALLY TESTING FOR A ROSE OF THESE 3 SIGNALS.
You can always create the sampling of these signals using SystemVerilog with the #n delays and test for when they should be all 0’s and all 1’s.
Did I miss something here?
My paper (below) expresses the use of SystemVerilog with tasks to verify complex assertions. Perhaps that paper may give ideas on a different approach.
Ben Cohen http://www.systemverilog.us/ben@systemverilog.us
For training, consulting, services: contact http://cvcblr.com/home
module m;
realtime t1, t2, half_time_period;
bit clk1, clk2;
initial forever #10 clk1 = !clk1;
bit[3:0] state=4'b0010;
always @(posedge clk1) begin
t1 = $realtime;
@(negedge clk1)
t2 = $realtime - t1;
half_time_period = t2/2; // half time period of clock 1 divided by 2 to get 90 degree phase shifted time period
end
always @(posedge clk1) begin
realtime full;
full=2*half_time_period;
#half_time_period;
clk2 <= 1'b1;
#full;
clk2 <= 1'b0;
end
property phase_aligned_90_degrees_chk(clk1, clk2, state, realtime half_time_period);
realtime t1, t2;
@(posedge clk1) (1, t1=$realtime) ##0 state == 4'h2 |-> @(posedge clk2) (1, t2=$realtime) ##0 ((t2-t1) == half_time_period);
endproperty
ap_phase_aligned_90_degrees_chk: assert property(phase_aligned_90_degrees_chk(clk1, clk2, state, half_time_period) );
// I implemented it this way and see a mix of failures and success in the waveform. It's very confusing, kindly help.
endmodule
I apologize for not stating my requirements clearly. I just ran your code on EDA playground and got this error:
Compiler version Q-2020.03-SP1-1; Runtime version Q-2020.03-SP1-1; Dec 8 04:32 2021
“testbench.sv”, 28: m.ap_phase_aligned_90_degrees_chk: started at 10ns failed at 35ns
Offending ‘((t2 - t1) == half_time_period)’