Branch, Expression and Focused Expression Coverage

kindly what’s the difference between Branch Coverage, Expression Coverage and Focused Expression Coverage? because I did not fully understand the difference between them while reading the Coverage Cookbook, It will be great if there is a simple example.

These are various levels of code coverage with increasing complexity. Take this example single line of code

if (A&B || C&D) somestatement;
  • Line coverage will tell you that the if statement got executed, but since somestatement is on the same line, you will not know if that was executed or not.
  • Statement coverage will tell you whether both were executed
  • Branch coverage will tell you if the if statement executed both the true and false branches. since there is no else clause, statement coverage would not uncover the false branch.
  • Since different tools have different terminology and metrics for expression and focused expression coverage, it is best to consult the documentation for the tool you are using. The basic premise is for each of the 4 variables in the expression, the state of each variable needs to control the state of the entire expression. For example, if B==1, and C or D = 0, then the state of A will control whether the expression is true or false. If B was always false, there is no way to cover the expression true by making A true.

In reply to dave_59:

Thank you Dave, from your answer can I say that “focused expression coverage should cover the whole combinations to make this condition true ?!”

In reply to Elbosily:

Hi Dave,

Can u elaborate the difference between the conditional coverage and the branch coverage with the example?

Thanks,
sagar

In reply to sagar@aceic.com:

The terminology used in code coverage varies from tool to tool. All of this is explained in the Questa User Manual, and likely in whatever tool you may be using for code coverage. I’m not going to read the manual for you. I will help explain anything in the manual that is unclear or missing that is not tool specific.

Branch coverage looks at all the conditional branching statements and counts each branch taken. Conditional coverage looks at all Boolean expressions and counts the number of times the expression was true or false. In my example above, there is no difference between the two types of coverage. But each type of coverage covers cases that the other does not. The choice of which one to use, or all of them, is based on the performance hit you are willing to take for code coverage analysis. You might try branch coverage for quick analysis, and then switch to FEC later towards the end of your testing.

In reply to dave_59:

Thank you Dave.

In reply to Elbosily:

Hi Dave,
I am checking the code coverage for one of my Module’s testbench, but the expression coverage is appearing as “n/a” , why is that so ? there are if-else & assignments in the RTL…

In reply to Saraswati:
This forum is not for tool related support.

In reply to dave_59:

This is my understanding on Expression coverage ,Please correct me if I am wrong

Expression coverage takes each condition of a expression and checks for true or false states.

Ex :

out = (a && b) || (c && d) 

In the above example for (a && b) it checks for both true and false states, similarly for
(c && d) it checks for both 0 and 1 states and finally as a whole (a && b) || (c && d) checks for both true and false states.
So, total number of possibilities are 6 ???

Thank you
Durga