Search the courses, subjects, tracks, games and features, or jump straight to a page.
Learn it your way
A short class with Sarah and her students. The other ways are under More.
Sign up free to listen. Transcripts are free to read.
Today, we're going to talk about code coverage. Can anyone tell me why code coverage might be important in verifying RTL designs?
I think it helps us know which parts of our code have been tested.
Exactly! Code coverage measures how much of the RTL code is exercised during simulation. What do you think happens if we don't track this?
We might miss bugs in parts of the code that weren't tested.
That's right! Let’s remember the acronym 'SBC' for Statement, Branch, and Toggle coverage, which are the main types. Can anyone explain what statement coverage is?
It checks if every line of code has been executed at least once.
Perfect! And what about branch coverage?
It ensures all paths, like if and else statements, are tested.
Well done! To summarize, code coverage helps us identify untested parts of our design to ensure we cover all possible scenarios.
Now, let's discuss functional coverage. How does it differ from code coverage?
Functional coverage checks if all functional scenarios are tested, right?
Exactly! It's about ensuring that we evaluate all input combinations to see if the design behaves as expected. What do you think could happen without functional coverage?
We might not test all possible inputs and miss defects.
Exactly! It ensures we cover every working scenario. You can define functional coverage in the testbench or let the simulator track it for you. Can anyone give an example of how to define it in Verilog?
I think we can use covergroups, right?
"Yes! Here’s an example:
Why do we think code and functional coverage are crucial for design validation?
They help ensure that we are not missing any potential faults in the design.
Correct! They provide a structured approach to ensuring comprehensive testing. Can anyone summarize the benefits we discussed today?
They help identify untested areas, ensure all scenarios are tested, and ultimately improve design quality.
Great summary! Remember, thorough coverage is key to reducing bugs and ensuring robust designs.
The measurement of code execution during tests to identify untested parts.
Ensures all functional scenarios have been evaluated in design validation.
Only checks if each line of code is executed.
Focuses on testing all possible branches for comprehensive validation.
Tracks changes in signal states during testing.
When testing code, don’t forget, cover each line, don’t regret; branches, toggles, watch them go, code coverage helps improve your flow.
Once upon a time, in a land of codes, a wise tester decided to see all paths. He measured statements, branches, and toggles, ensuring that no path remained unexplored.
SBC - Statement, Branch, Toggle Coverage helps you remember the key types of code coverage.
CFC - Code and Functional Coverage makes testing complete, ensuring quality you can repeat.
Term
Code Coverage
Click to flip
Term
Functional Coverage
Click to flip
Term
Statement Coverage
Click to flip
Term
Branch Coverage
Click to flip
Term
Toggle Coverage
Click to flip
A measure of how much of the RTL code has been exercised during simulation.
Tracks whether all functional scenarios have been tested during RTL verification.
Ensures each line of code in the design is executed at least once.
Verifies that all possible branches in the code are exercised.
Measures how often signals change from one state to another during simulation.
This section discusses code coverage and functional coverage as vital components of RTL verification, helping to measure the extent to which designs are tested during simulation.
Code coverage assesses how well the RTL code is tested, including statement, branch, and toggle coverage, while functional coverage ensures that all expected functional scenarios are evaluated during testing. This dual approach aids in identifying under-tested sections of the code and ensures comprehensive verification.
In RTL verification, code coverage and functional coverage play crucial roles in ensuring that designs are thoroughly tested and validated.
Code coverage measures the extent to which the RTL code has been exercised during simulation, helping to identify untested areas within the design. It includes various types of coverage:
This coverage is integral to improving overall code quality by revealing sections needing additional testing.
Functional coverage tracks whether all functional scenarios have been tested, ensuring completeness in verifying the design's intended operation. It encompasses all possible input combinations to verify that the design behaves correctly across various conditions. Functional coverage can be defined in the testbench or automatically tracked by the simulator to provide insights into areas not covered by existing tests.
For example, a coverage block in Verilog can be defined as follows:
covergroup cg;
coverpoint signal_a;
coverpoint signal_b;
endgroup
This block captures how often signal_a and signal_b have been exercised during simulation, thereby enhancing the validation process. Overall, employing both code and functional coverage is crucial for effective RTL verification, ensuring designs meet specifications and function as intended.