Csce616 10
Csce616 10
Introduction
• Immediate Assertions
– Are executed like a statement in procedural code
– Primarily used in simulation
• Concurrent Assertions
– Based on clock semantics
– Executed independently from HDL code
– Used in simulation and formal
Immediate Assertions
Properties
property name[(list_of_formals)];
property_spec;
endproperty [: name]
property_expression ::=
sequence_expr
| (property_expression)
| property_operator
| if ( expression ) property_expression [else
property_expression]
| property_instance
| clocking_event property_expr
Property Operators
• Not
– not property_expression
• Or
– property_expression or property_expression
• And
– property_expression and property_expression
• Implication
– Overlapping implication
• property_expression |-> property_expression
• If there is a match for the antecedent property_expr, then the end point of the
match is the start point of the evaluation of the consequent property_expr.
– Non-Overlapping implication
• property_expression |=> property_expression
• The start point of the evaluation of the consequent property_expr is the clock
tick after the end point of the match.
CSCE 616 Fall 2022 8
Property Example
property p1;
@(posedge clk) disable iff(!res_n)
( s1 && s2 ) |=> s3;
endproperty : p1
A short form:
assert property(@(posedge clk) disable iff(!res_n)
( s1 && s2 ) |=> s3);
Sequences
Sequence Operators
Local Variables
property adder;
bit [63:0] x;
@(posedge clk) disable iff (!res_n)
(valid, x = data_in) |=> ##5 (data_out == (x+1));
endproperty : adder
Use instead:
property good;
@(posedge clk) disable iff(!res_n)
$rose(valid) && enable |-> a_very_long_sequence;
endproperty : good
• If b is rarely true and a is true very often, a better solution is the following one:
sequence good;
($past(a) && b) ##2 c;
endsequence : good
Example
wire data_valid,any_sox,any_eox;
sequence length_of_packet;
##[1:32] ##1 any_eox;
endsequence : length_of_packet
property legal_data_valid;
@(posedge clk) disable iff(!reset_n)
(data_valid && $rose(any_sox)) |->
data_valid throughout length_of_packet;
endproperty : legal_data_valid
• SVA can be defined either directly in the HDL code, or in an own Verilog
module, which is then binded to a design instance.
• This allows an easy reusability of SVAs.
• The bind statement can be used in
– Verilog code, e.g. in the testbench
– a bind file, which is loaded by the simulator
• Syntax:
bind module_type : hdl_instance module_with_assertion instance_name
port_list
Bind Example
module assertion_module(
input logic clk,
input logic res_n,
input logic req,
input logic gnt
);
req_gnt : assert property(
@(posedge clk) disable iff(!res_n) req |=> gnt);
endmodule
module tb_top;
wire clk_top, res_n_top, req_top, gnt_top;
dut dut_I( // of type dut
.clk(clk_top), .res_n(res_n_top),
.req(req_top), .gnt(gnt_top)
);
bind dut : tb_top.dut_I assertion_module assertions_I (
.clk(clk), .res_n(res_n), .req(req), .gnt(gnt)
);
endmodule
CSCE 616 Fall 2022 20