Hi,
I am trying to write an assertion to check signal propagation. I want to see that if a “src” signal changes, then after some constant number of local clk cycles, the “dest” signal is equal to the “src” signal.
I tried writing the following way:
module try();
logic clk = 0;
logic src_s;
logic src_stable;
logic src;
logic dest;
initial begin
clk = 0;
src = 0;
dest = 0;
#100;
src = 1;
#100;
dest = 1;
#20
$finish;
end
initial forever begin
#20;
clk = ~clk;
end
always_ff @(negedge clk) begin
src_s <= src;
end
assign src_stable = (src == src_s);
MY_PROP: assert property (
@(posedge clk)
disable iff (src_stable)
(1) |=> ##10 (src == dest))
else $error("Propagation check failed");
endmodule
I expect this assertion to fail - but it does not fail.
Seems like the “disable_iff” argument is always 1, and I do not understand why, since src signal indeed toggles.
Indeed your property stays all the time ‘INACTIVE’ because src and src_s have on each rising edge of clk the same value.
Additionally your simulation is too short (shorter than 10 clk cycles. If you are disabling the condition the property becomes ACTIVE. But it completes never.
Your assertion does not meet your requirements for
// if a “src” signal changes, then after some constant number of local clk
// cycles, the “dest” signal is equal to the “src” signal.
I corrected it below.
You’re basically saying “when src changes, dest will be at the same value after n clocks”.
I think the problem is that if src doesn’t change, then dest can be wiggling randomly but the property would still be happy. And I guess this is not the point of the test. So, I would maybe change the property to check src vs dest on every clock cycle (and hope that there’s are no glitches that fall between clk edges).
That was the original requirement. Yes, the following meets that req.
($changed(src), v=src) |-> ##n v== dest;
You’re basically saying “when src changes, dest will be at the same value after n clocks”.
[YOU] think the problem is that if src doesn’t change, then dest can be wiggling randomly but the property would still be happy. And I guess this is not the point of the test. So, I would maybe change the property to check src vs dest on every clock cycle (and hope that there’s are no glitches that fall between clk edges).
[Ben] then you have to redefine the requirements if this is what you want.
See Reflections on Users’ Experiences with SVA, part 1
Important concepts on EXPRESSING REQUIREMENTS,
Terminology, threads in ranges and repeats in antecedents, multiple antecedents.
Ben Cohen Ben@systemverilog.us
Link to the list of papers and books that I wrote, many are now donated.