what is the difference between those two assertions? - system-verilog-assertions

let' say I have two properties;
property p1;
sig_a ##1 sig_b;
endproperty
property p2;
sig_a |=> sig_b;
endproperty
now if i do assertion like this:
a1: assert property (p1);
a2: assert property (p2);
Does a1 and a2 make any difference?

There is difference between system_verilog property and sequence syntax.
property p1 doesn't have triggering condition. In other words , it will always being checked on clocking event. It just mentions sequence of operation to be checked. i.e. sequence in sv assertion. You could assume property p1 in below manner.
property p1;
1'b1 |-> sig_a ##1 sig_b;
endproperty
It will always fail , if sig_a is zero-value.
Now property p2 is having triggering condition which is sig_a == non_zero value. if this condition is true then it will evaluate sig_b value after 1 clocking event.

Related

When to use implication and when to use ##delay in system verilog assertions

I have scenario of assertion where first a should be high 1 cycle after this b should be high and 1 cycle after that c should be high, after this with 1 cycle delay d should be high
I am confused as to how these assertions should be coded. I have three options please help me which should be followed as correct solution
Option1 : a |=> b |=> c |=> d ;
Option2 : a |=> b ##1 c ##1 d;
Option3 : a ##1 b |=> c ##1 d;
I am getting stuck at these options which one to follow . Please guide me about best solution and as to why
According to me best coding from description would be
a |=> b |=> c ##1 d
Reason : Operator used is Non overlapping Implication operator which tells if antecedent is true then evaluate consequent at next clock tick.Use of this operator is needed as b has to be high only if a is high else not necessary.so,condition of a is implying condition of b.so is the case with c.
But in case of d, statement says delay which means to use ## to specify number of clock cycles delay.
Option 2 is the only correct option (assuming you want this triggered whenever a is high). Implication is true if the antecedent is false or if the consequent is true.
Option1 : a |=> b |=> c |=> d ; -> If !a, this is true, if a ##1 !b, then this is true, if a ##1 b ##1 !c, then this is true. As soon as the antecedent is false, the whole statement is true.
Basically (b |=> c) is true when b is false, which means Option1 says that if a is high AND if b is high on the next cycle AND if c is high on the next cycle then d must be high on the last cycle. That is not what you need.
Although your question is actually requires a then b then c then d. That would require this:
a ##1 b ##1 c ##1 d

Is there a way to skip the first evaluation of an SVA?

I have the following property:
property p_0;
$rose(signal_a) |-> $rose(signal_b) ;
endproperty
my problem is, after HW RST, signal_b rises (normal behavior) but the assertion fails, and I want this check to be evaluated only later.
I wanted to work with first_match() with something like below:
p_0_a : assert property ( ! first_match(p_0)) else `uvm_fatal(...)
so that I skip the first match of this property but the compiler generates a syntax error.
Is there a way to skip the evaluation of SVAs after specific number of iterations?
Cascaded implication operators may well help you out, for example something along the lines of:
assert property (reset |-> p_0);
Basically, |=> and |-> are right-associative:
A |=> B |=> C
means
A |=> ( B |=> C )
ie If A happens, check (B |=> C) immediately afterwards. If A does not happen, don't check (B |=> C).

How to write a property in System verilog assertions?

I want to write a property in SVA to formally verify a behavior.
Here is what I want to:
property prop1(sig1,sig2,sig3,sig4);
#(posedge clk)
$fell(sig1) ##[1:$] first_match($fell(sig2)) ##0 sig3 |-> sig4 == sig3;
endproperty
How can I rewrite the above property so that after sig1 falls, it stays LOW during remaining Evaluation cycles?
Note: I do not want to put sig1 as disable iff (sig1)
property prop1(sig1,sig2,sig3,sig4);
#(posedge clk)
(!sig1) throughout (##[1:$] first_match($fell(sig2)) ##0 sig3)
|-> sig4 == sig3;
endproperty
See section 16.9.9 Conditions over sequences in the 1800-2012 LRM

system verilog assertions: Using a reg value in a repition operator

I am trying to do something like this:
assert property (#(posedge clk) disable iff (!rst) a[*c] -> $rose(b))
Here c is not a 'constant' but a value coming from some bits of a register. eg: reg[4:0] which is written only once. The check is to see if b is asserted only when a is high for "c" number of cycles.
However, SVAs do not accept a variable like this : [*reg[4:0]]. Any ideas??
Introduce a local variable ctr. At every posedge a new assertion with a new instance of ctr will be created. Set ctr equal to the value in reg1. Check that a is true throughout the down count. Decrement the counter as long as it is larger than zero. The (ctr>0, ctr--)[*0:$] statement will count down until ctr == 0 is true.
You might want to change (ctr>0, ctr--)[*0:$] to (ctr>0, ctr--)[*1:$], depending on what results you expect if reg == 0.
property pr_aRegTimes;
integer ctr;
disable iff (!rst)
#(posedge clk)
(1, ctr = reg1) ##0 a throughout ((ctr>0, ctr--)[*0:$] ##1 (ctr == 0)) |-> $rose(b);
endproperty
as_aRegTimes: assert property (pr_aRegTimes)
else $error("aRegTimes failed");
Working example:
http://www.edaplayground.com/x/Xh9
Sources:
https://www.doulos.com/knowhow/sysverilog/tutorial/assertions/
http://www.win.tue.nl/~jschmalt/teaching/2IMF20/SvaFvTutorialHVC2013.pdf
property pr_aRegTimes;
integer ctr;
disable iff (!rst)
#(posedge clk)
($rose(a), ctr = reg1) ##0 (a&&ctr>0,ctr--)[*] |-> $rose(b);
endproperty

system verilog assertion disable condition

I have this assertion in order to check clk freq:
assert property clk_freq;
int cnt;
#(posedge fast_clk, clk_1MHz) disable_iff(!enable_check)
($rose(clk_1MHz), cnt=0) |=> (!$rose(clk_1MHz),cnt++) [*0:$] ##1 $rose(clk_1MHz), cnt==fast_clk_freq;
endproperty
fast_clk starts to toggle during (not from beginning) of the simulation after disable_check is asserted.
The problem is that it seems that the assertion ignores the disable_iff
Question: is a $rose(clk_1Mhz) event "registered" even though the assertion is disabled (or am I missing something else ?)
There is no disable_iff keywords, it is disable iff (without the underscore). Properties can have local variables but the local variables cannot be defined inline with assert. Separate the property definition and the assertion instantiation.
The clock sampling doesn't seem to be correct. #(posedge fast_clk, clk_1MHz) mean on rising fast_clk or any change to clk_1MHz. clk_1MHz is the sampled data value, therefore it should not be a clock.
$rose(clk_1MHz), cnt==fast_clk_freq is ilegal syntax, sugest: $rose(clk_1MHz) ##0 cnt==fast_clk_freq
Suggested property definition and the assertion instantiation:
property p_clk_freq;
int cnt;
#(posedge fast_clk) disable iff(!enable_check)
($rose(clk_1MHz), cnt=0) |=> (!$rose(clk_1MHz),cnt++)[*0:$] ##1 $rose(clk_1MHz) ##0 cnt==fast_clk_freq;
endproperty
a_clk_freq : assert property(p_clk_freq);
For more on assertions refer to section 16 of IEEE Std 1800-2012.