You are on page 1of 18

Assertions

Primarily used to validate the behavior of a design Two types :


1.Immediate Follow simulation event semantics, like code in always block 2.Concurrent Based on clock semantics, like always block with clock

mmediate Assertions

Test of an e!pression "!pression evaluates to #, $ or % False

Assertion Fail Assertion Pass assertion(label : assert )e!pression* pass block code+ else fail block code+

&therwise e!pression True

'ynta! :

'everity of an assertion failure


By default, it is error &ther severity levels ,


-fatal -error -warning -info

Triggering a event, or increment a counter, or calling function in pass.fail block code/

0oncurrent Assertions

'pans over time, evaluated based on events 1ifference between clock tick and simulation ticks

"!pressions such as )clk 22 gating(signal* and )clk iff gating(signal* can be used to represent a gated clock/

'e3uences

To build and manipulate se3uential behaviors "!ample :


se3uence s4+ 5)posedge clk* a 664 b 664 c+ endse3uence

n place of a,b or c there can be any Boolean e!pression or se3/ A 66 followed by a number or range specifies the delay from the current clock tick to the beginning of the se3uence that follows/

'e3uences "!amples

re3 667 gnt

a 668 b , when a is true after 8 clock ticks b must be true concatenation of overlapped se3uences

)a 664 b 664 c* 66% )d 664 e 664 f* same as )a 664 b 664 c2d 664 e 664 f*

'e3uences "!amples

9hen delay is not fi!ed value but in specific time window it can be specified as follows :

a 66:4:;< b
same as ))a 664 b* or )a 667 b* or )a 66; b* *

a 66:=:>%< b a 66:8:-< b - indicates end of simulation when a is true b must be true after 8 clock ticks/

'e3uences "!amples

Consecutive repetition

a :?;< means a 664 a 664 a a 664 b :?;< 664 c b 664 a:?%:4< 667 c means )b 667 c* or )b 664 a 667 c* )a 667 b* :?@< same as )a 667 b 664 a 667 b 664 a 667 b 664 a 667 b 664 a 667 b*

'e3uences "!amples

Goto repetition ( [-> )


a 664 b :,A=< 664 c indicates after a is true b must be true four times with no gap between b and c , same as a 664 ))Bb:?%:-< 664 b* :?=<* 664 c a 664 b :CA=< 664 c indicates after a is true b must be true four times with gap between b and c , same as a 664 ))B b:?%:-< 664 b* :?=<* 664 Bb:?%:-< 664 c

Non-consecutive repetition ( [= )

and operation

se34 and se37 'e3uence must start at the same time and can end at any time/ Datch is done after last se3uence is ended )te4 667 te7* and )te; 667 te= 667 te@*

Or operation

se34 or se37 'e3uence must start at the same time and can end at any time/ Datch is done at both the se3uences ends

intersect operation )and with length restriction*

se34 intersect se37 se3uences must start at the same time and end at same time/ Datch is done at the end time/ )te4 66:4:@< te7* intersect )te; 667 te= 667 te@*

first_matc 2 t rou! out operation

first_matc operation :

first_matc )se34* Datches only the first match and ignores other matches A t rou! out se34 Boolean e!pression A must be throughout se34

t rou! out operation :


Arguments in 'e3uence

Passing arguments with no data types


se3uence rule>(with(no(type)!, y*+ 664 ! 66:7:4%< y+ endse3uence

Passing arguments with data type


se3uence rule>(with(type)bit !, bit y*+ 664 ! 66:7:4%< y+ endse3uence

'ampled value functions

'ystem functions available for accessing sampled values of an e!pression "samp#ed$

Function -sampled returns the sampled value of the e!pression with respect to the last occurrence of the clocking event/ 9hen -sampled is invoked prior to the occurrence of the first clocking event, the value of # is returned/ "!ample:
always 5)posedge clk* begin cnt C cnt E 4%+ temp C -sampled)cnt*+ end

'ampled value functions

"rose$ returns true if F'B of the e!pression changed to 4/ &therwise, it returns false "fe##$ returns true if F'B of the e!pression changed to %/ &therwise, it returns false "sta%#e$ returns true if the value of the e!pression did not change/ &therwise, it returns false

'ampled value functions

"past$
past) e!pression4 :, number(of(ticks< :, e!pression7< :, clocking(event<* Three optional arguments are provided:

e&pression2 is used as a gating e!pression for the clocking event num%er_of_tic's specifies the number of clock ticks in the past c#oc'in!_event specifies the clocking event for sampling e!pression4 -past)in4, , enable*+ always 5)posedge clk* reg4 GC a 2 -past)b*+ -past)3, 7,enable*+

"!amples:

Thank You

You might also like