6
\$\begingroup\$

I read that testing and verification are different but in what way? I read that somebody writes theory to prove that the hardware is "correct" but how is that done? I tried reading Wikipedia and googling about it but I either end up in too advanced research (HOL4 and theoretical proofs) or brands, standards or outdated deprecated hardware abstraction layer ("HAL") that seems to be not used in general anymore.

I have created a 4-bit ALU (with Quartus) that actually works if I load the FPGA with the ALU. I used the logical primitives and wrote tests for the ALU. Now I want to learn more and understand the difference between testing and verifying in general and how to prove that an actual hardware is working correctly.

I see that ML is used in projects using HOL theorem prover. Is that something within my reach of understanding and handling if I am intermediate programmer and engineer? I know mathematics and programming but I'm not good at physics.

My ALU worked and I could test it in Quartus but I don't know what "formal verification" is. Can I do it and if yes, how and what should I learn?

I tried the proof assistant Isabelle and writing trivial theorems with HOL that I could compile and get the expected output. I don't have much experience with ML but I think I could use it since I have experience writing C, assembly and machine code.

Can you help me find what to read or answer what I should learn and study?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Since you mention Isabelle, have you taken their intensive course \$\endgroup\$ Commented Feb 3, 2017 at 12:29
  • \$\begingroup\$ @DmitryGrigoryev Thanks for mentioning it. I'm reading it now. \$\endgroup\$ Commented Feb 3, 2017 at 16:50

2 Answers 2

6
\$\begingroup\$

Formal verification is state-point mapping done to ensure a schematic matches verilog or RTL model of the module. This means that for every set of inputs and states defined in the RTL model, the design is checked against the schematic to ensure that for those same inputs and states, the outputs are the same. It is a bit more cumbersome than other verification methods because it does not scale as well for large inputs and circuits, and it requires that internal state nodes also match (you could probably hack the verification config files or play with some internal settings to ignore internal state points but that is a lot more work).

Other types of verification could be symbolic (pushing through tokens representing boolean valuse or high-z states) or in some cases just testing with a large enough set of test vectors to ensure some %-age coverage for all possible cases.

\$\endgroup\$
10
  • 3
    \$\begingroup\$ @DacSaunders: That would probably be considered test vector %-age coverage. And for your second question: yes. For example an entire CPU is way too large to verify at once. Instead individual modules are verified in the most stringent possible way. This bubbles up to the higher levels of abstraction (but I am less familiar with those as I work at the transistor level) \$\endgroup\$
    – jbord39
    Commented Jan 30, 2017 at 17:05
  • 4
    \$\begingroup\$ Formal verification certainly doesn't compare VHDL or RTL to synthesized schematic. If the two sides don't match, the recommended course of action is to dump the HDL compiler you're using and get a better one. \$\endgroup\$ Commented Feb 3, 2017 at 11:59
  • 2
    \$\begingroup\$ @Dmitry Grigoryev: yes, they do. Sure you would blame the hdl compiler but it is still a billion dollar mistake when making CPUs. They will just run it to cover their asses. Plus sometimes latches are inferred and there are corner cases that need to be considered. You might just do FPGA design -- please don't assume that everyone else does. Not to mention any eco work post synthesis that needs to be verified. \$\endgroup\$
    – jbord39
    Commented Feb 4, 2017 at 21:03
  • 1
    \$\begingroup\$ @DmitryGrigoryev: Not to mention that any decent compiler is going to be running verification under the covers the whole time anyway. It doesn't change my answer: the compiler is going to check itself against the RTL constantly. Maybe you don't run it as a seperate step at the end: regardless the explanation of what formal verification is remains. One industry example is Conformal by Synopsys. Heres a wiki article for your ignorance: en.wikipedia.org/wiki/Formal_equivalence_checking \$\endgroup\$
    – jbord39
    Commented Feb 6, 2017 at 18:08
  • 1
    \$\begingroup\$ It's misleading to say "Formal verification is state-point mapping done to ensure a schematic matches verilog or RTL model of the module" - that's equivalence checking, a kind of formal verification. Formal verification is also used for property checking of RTL Designs. \$\endgroup\$ Commented Aug 8, 2021 at 12:26
-1
\$\begingroup\$

How to learn practical Formal Verification

I recommend downloading and installing the free Yosys software and the free solvers on Ubuntu, and then follow the tutorials from Symbiotic EDA and try it out hands-on to gain experience with formal verification, because that's what I did as a senior year engineering undergraduate. The properties are written in a property specification language, like PSL and SystemVerilog Assertions. I have worked with SystemVerilog Assertions (SVA). SVA gives us a compact, easy-to-understand language to specify properties that can even span infinite cycles. Note that the open-source version of Symbiotic EDA does not support most SVA constructs.

Equivalence Checking Vs. Formal Verification

The other answer has mentioned formal equivalence checking, which is a kind of formal verification that checks 2 designs which may or may not be at the same abstraction level for logical / functional equivalency. For example, you can do RTL versus RTL formal equivalence checking or RTL versus gate-level netlist formal equivalence checking. Equivalence checking is one of the most common formal verification based techniques used in the semiconductor industry. Low-power formal verification and property checking are other kinds of formal verification. I have worked with property checking, so I can write a little about it.

Property Checking

Property checking is a technique where you specify properties, and the solver proves these properties are held true, either for all time i.e. induction, or for a certain number of cycles i.e. bounded model checking. 2 kinds of properties are specified: assumptions and assertions. Assumptions are properties which the solver assumes and assertions are the properties the solver needs to prove. So the problem of proving properties is represented as a SAT (Satisfiability, i.e. Boolean Satisfiability) problem, which is then solved by SAT solvers.

Limitations of Property Checking

  1. SAT is NP Complete i.e. no known polynomial time algorithm to solve this problem exists. So one might expect formal verification to be slow. Yes, formal verification can be slow for large designs and the tool can "choke" when the complexity of the proofs is high, due to the system running out of memory. The good news is there are clever techniques like blackboxes, cut-points and abstractions that can be applied by the one doing formal verification to speeden the verification process and reduce memory consumption. Adding a sufficient number of assumptions restricts the solver to check a smaller search space, and increases the probability of converging to a solution.
  2. The Incompleteness Theorem: The conclusion that has to be drawn from this theorem is that it is not possible to build a formal system that can be guaranteed to verify the correctness of any specifications. Tools that can solve most problems found in the real world do exist and are useful.
  3. Correctness and completeness of properties: The onus of the correctness and completeness of properties specified is on the one writing the properties. Writing correct properties is not very easy and it takes time to learn to write assertions.

Suggestions for property checking

  1. For a large design, it is recommended to break the problem of verifying the design into smaller, provable properties that verify the entire design. This enables the tool to use a Divide-and-Conquer approach to generate the proofs. For example, RISC-V Formal uses a set of simple properties to prove ISA compliance of RISC-V processors.
  2. It is also recommended to start with Bounded model checking and then try Induction proofs. This is because bounded model checking is easier to run and debug.

Is formal verification worth it?

  1. Formal verification is a somewhat challenging field, but the effort is worth it because some bugs like the Pentium Floating point division bug will most likely escape random testing, since the probability of the occurences leading to the detection of some bugs in random testing is extremely small.
  2. You can't verify that your design does not hang (enter a deadlock) at some point of time using constrained random, since there are only so many cycles you can run the simulation for. Formal verification can potentially prove the correctness of the logic design at the Register Transfer Level and gate level for infinite cycles.

In the end, it's not magic, and it has its limitations like any other technology. But it is a powerful technique that leverages cutting-edge research done in mathematics, computer science and formal logic.

\$\endgroup\$
11
  • 1
    \$\begingroup\$ "Formal verification...proves the entire design is bug-free" No, I don't think so. It shows that two representations of a design will behave in the same way, or are equivalent in some sense. The fact that this question has so little activity should tell you something about the importance of formal verification to real-world engineers, as opposed to academics. \$\endgroup\$ Commented Aug 8, 2021 at 16:52
  • 1
    \$\begingroup\$ I am not a verification engineer, so my knowledge is limited in this realm. In 2019, when I attended DVcon, Intel claimed that they use ONLY formal verification to prove their designs, and it stirredd some debates as well. I am not sure how formal verification alone can prove a whole complex design especially on control paths. I guess this is still an unexplored area as many of the verification engineers are still on Testbench based verification which is quite time consuming like 10 times slower. \$\endgroup\$
    – Mitu Raj
    Commented Aug 8, 2021 at 19:06
  • 3
    \$\begingroup\$ @ElliotAlderson is incorrect regarding the use of formal in industry, but I would caution that proving an entire design is bug free for infinite cycles is overstating formal's ability. Formal is phenomenal for finding shallow bugs and regression testing. You can increase your search depth with assumes and tricks, but you are also limited by your computing resources. Deeper bugs are still found by directed tests, and the two approaches are complementary. Both, of course, rely on how good your assertions are as well. \$\endgroup\$
    – awjlogan
    Commented Aug 10, 2021 at 11:56
  • 5
    \$\begingroup\$ It depends on your regulatory environment. Put some hardware in a Class III FDA device, and then tell me verification isn't a real world thing. \$\endgroup\$ Commented Aug 10, 2021 at 12:34
  • 1
    \$\begingroup\$ @ShashankVM - yes, I know this. My point is you can't write an arbitrary length sequence and expect it to always be solved. An approach is to break a sequence into multiple assertions and prove each step, thus turning it into an assumption for the next assertion in the chain. \$\endgroup\$
    – awjlogan
    Commented Aug 10, 2021 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.