I understood the first condition before implication operator. It says PSEL will change its state and after changing its value only 1 bit of PSEL will become 1 and all others zero. At this time this condition will become true.
But facing difficulty in understanding part after |-> . stable(PSEL)[*1:] mean that PSEL will be stable for at least 1 clock and
##1 $fell(PENABLE) mean that after 1 cycle delay PENABLE will become 0. But I am not able to make relation between |->, stable(PSEL)[*1:] and ##1 $fell(PENABLE).
There is a problem with the
(!$stable(PSEL) && $onehot(PSEL)) |-> stable(PSEL)[*1:] ##1 $fell(PENABLE);
because it will ALWAYS FAIL; You cannot have !$stable(PSEL) AND**$stable(PSEL)** in the SAME cycle!
The fix
$stable(PSEL)[*1:$] ##1 $fell(PENABLE);
// is equivalent to:
$stable(PSEL)[*1] ##1 $fell(PENABLE) or
$stable(PSEL)[*2] ##1 $fell(PENABLE) or
...
$stable(PSEL)[*n] ##1 $fell(PENABLE); // when "n" is infinity
// This sequence will succeed only when at some cycle
// $stable(PSEL)==1 AND at the next cycle $fell(PENABLE)==1
// FROM PSEL being active, then signal must be stable until end of cycle
property PSEL_ASSERT_SIGNAL_STABLE(signal);
@(posedge PCLK)
(!$stable(PSEL) && $onehot(PSEL)) |-> $stable(signal)[*1:$] ##1 $fell(PENABLE);
endproperty: PSEL_ASSERT_SIGNAL_STABLE
PSEL_STABLE: assert property(PSEL_ASSERT_SIGNAL_STABLE(PSEL));
In reply to vickydhudashia:
Well, as humans, we make mistakes.
Assertions, particularly if complex, should be tested, I have in my SVA 4th Edition book, a chapter about verifying assertions. Below is an example in verifying this particular assertions using my guidelines:
import uvm_pkg::*; `include "uvm_macros.svh"
module stb;
bit pclk, enb;
bit[3:0] psel;
default clocking @(posedge pclk); endclocking
initial forever #10 pclk=!pclk;
property PSEL_ASSERT_SIGNAL_STABLE(psel);
@(posedge pclk)
(!$stable(psel) && $onehot(psel)) |-> $stable(psel)[*1:$] ##1 $fell(enb);
endproperty: PSEL_ASSERT_SIGNAL_STABLE
apsel_ASSERT_SIGNAL_STABLE: assert property(PSEL_ASSERT_SIGNAL_STABLE(psel));
property PSEL_ASSERT_SIGNAL_STABLE2(psel);
@(posedge pclk)
(!$stable(psel) && $onehot(psel)) |=> $stable(psel)[*1:$] ##1 $fell(enb);
endproperty: PSEL_ASSERT_SIGNAL_STABLE2
apsel_ASSERT_SIGNAL_STABLE2: assert property(PSEL_ASSERT_SIGNAL_STABLE2(psel));
initial begin
repeat(200) begin
@(posedge pclk);
if (!randomize(psel, enb) with
{ psel dist {4'b1000:=1, 4'b0001:=3};
enb dist {1'b1:=1, 1'b0:=7};
}) `uvm_error("MYERR", "This is a randomize error")
end
$finish;
end
endmodule