SystemVerilog Assertions Without Using dist
SystemVerilog Assertions (SVA) are a powerful mechanism for verifying designs. While the dist
operator is frequently used for checking sequences and properties over time, it's entirely possible and often preferable to write effective assertions without relying on it. This approach often leads to clearer, more concise, and easier-to-understand assertions. This article explores various techniques for writing powerful SVA without using dist
.
Understanding the Role of dist
The dist
operator is primarily used to specify the number of times a particular sequence or property must occur within a given timeframe. Removing dist
often means explicitly defining the conditions for success or failure using other operators and constructs.
Alternative Techniques
Let's explore some common techniques for achieving the same verification goals as dist
without actually using it:
1. Using always
Blocks and Boolean Variables
For simple counting or sequence detection, an always
block coupled with a boolean variable can effectively replace dist
. This method provides more control and can be more readable for less complex scenarios.
logic [7:0] count;
always @(posedge clk) begin
if (condition_met)
count <= count + 1;
else
count <= 0; // Reset the count if the condition is not met
assert property (count >= 5); // Check if the condition has been met at least 5 times.
end
This code effectively replaces a potential use of dist
by explicitly tracking the count of occurrences within an always
block.
2. Leveraging Sequences and first_match
SystemVerilog sequences are powerful tools that can check for specific patterns in data without requiring dist
. Combined with the first_match
operator, we can create assertions that react to specific occurrences of a sequence.
sequence my_sequence;
a ##1 b ##2 c;
endsequence
property my_property;
$rose(start_signal) |-> ##[1:10] first_match(my_sequence);
endproperty
assert property (my_property);
This checks if sequence my_sequence
occurs at least once within 1 to 10 clock cycles after start_signal
rises.
3. Using Multiple Assertions for Different Conditions
For more complex scenarios where dist
might have been used to check for a range of occurrences, we can break the verification into multiple assertions, each checking a specific condition. This improves readability and makes debugging simpler.
assert property (@(posedge clk) disable iff (reset) (a |-> b) ); //Check for a single occurrence
assert property (@(posedge clk) disable iff (reset) (a ##1 b) ); //Check for sequential occurrence
// ... add more assertions for other conditions
4. Employing next
and until
operators
The next
and until
operators can be used effectively to define temporal relationships within sequences and properties without the need for dist
. These operators allow us to define precisely when a condition must be true or false relative to other events.
property my_property;
a until b; // 'a' must be true until 'b' becomes true.
endproperty
assert property (my_property);
Conclusion
While dist
offers a convenient shorthand for some assertion scenarios, mastering alternatives provides greater flexibility and often results in more maintainable and understandable verification code. By leveraging sequences, always
blocks, multiple assertions, and operators like next
and until
, we can create comprehensive and efficient SystemVerilog assertions without relying on the dist
operator. Choosing the appropriate technique depends largely on the specific verification requirements and the complexity of the design being verified. Remember to prioritize clarity and maintainability in your assertion writing.