Thought Leadership

Understanding Formal Verification

By Nicolae Tusinschi

What is formal verification?

Formal verification is a method to ensure that a hardware design behaves as intended by using mathematical analysis to check its correctness relative to its specifications. Unlike traditional verification methods, which rely on testing and simulation, formal verification mathematically proves that a design will always function correctly under all possible scenarios.

Example: Imagine the design of a microprocessor where the specification mandates that every instruction fetch must be followed by an instruction decode before execution. In formal verification, this requirement is represented as an assertion, and the verification tool checks that in all possible cases – no matter the order or combination of operations – this sequence is maintained. This approach eliminates the need to simulate every possible scenario, providing a higher level of confidence in the design’s correctness.

How is formal verification different from simulation?

Simulation tests specific scenarios, meaning it can only cover a fraction of all possible design behaviors. It is a probabilistic method where the goal is to test as many scenarios as possible, but it’s limited by time and resources. Conversely, formal verification is exhaustive – it analyzes all possible states and input combinations, identifying any potential violations of the design’s intended behavior. This makes it particularly effective at uncovering corner-case bugs that might be missed in simulation.

Example: In an automotive safety system, a simulation might run thousands of tests to mimic various crash scenarios. However, a rare combination of sensor inputs might trigger a bug that the simulation misses. Formal verification, on the other hand, would systematically analyze all possible input sequences to ensure that the safety system reacts correctly in every conceivable situation, ensuring the highest level of reliability.

Is it possible to verify every design exhaustively?

While formal verification aims to exhaustively verify a design, practical limitations, such as hardware resources and the complexity of the design, can make this challenging. In large-scale designs, not all assertions can be fully proven due to these constraints. Therefore, formal verification is often applied selectively, focusing on critical components while using simulation for the remainder.

Example: Consider a network router handling millions of packets with complex routing algorithms. Verifying every possible state of the router exhaustively would be impractical. However, by applying formal verification to key components like packet forwarding and error handling, and using simulation for broader testing, the design team can ensure that the most critical parts of the router are robustly verified.

What is a bounded proof?

A bounded proof is a type of formal verification that checks an assertion within a specific number of clock cycles. While it doesn’t provide a complete proof across all possible states, it quantifies the depth of analysis, offering valuable insights into the design’s behavior over a defined period.

Example: Suppose you’re working on a digital communication protocol that requires data integrity over multiple clock cycles. A bounded proof might demonstrate that the protocol maintains data integrity for up to 50 cycles. If the protocol usually stabilizes within 20 cycles, this bounded proof could be considered sufficient, providing confidence that the protocol functions correctly in practical scenarios.

Leave a Reply

This article first appeared on the Siemens Digital Industries Software blog at https://blogs.sw.siemens.com/verificationhorizons/2024/09/05/understanding-formal-verification/