SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: How and with what tools to check firmware code coverage in RTL simulation phase? ARM Cortex-M0/M0+?
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

How and with what tools to check firmware code coverage in RTL simulation phase? ARM Cortex-M0/M0+?

Jamie Kellett
Last updated: September 14, 2023 1:18 pm
Jamie Kellett 7 Min Read
Share
SHARE

To check firmware code coverage during RTL simulation for ARM Cortex-M0/M0+ cores, the main tools and techniques used are code coverage monitors built into the simulator, scripting to automate simulation runs, and coverage reports. The key steps are:

Contents
1. Selecting a Simulator with Coverage Monitoring2. Instrumenting the Design3. Creating Stimulus Testbenches4. Running Extensive Simulations5. Generating Coverage Reports6. Improving Stimulus to Increase Coverage7. Automating with ScriptingKey Tools SummaryImplementing the Flow with ModelSim1. Instrumenting RTL Code2. Creating Testbench3. Enabling Coverage4. Running Tests5. Coverage Reporting6. Improving Stimulus7. Automation with TclConclusion

1. Selecting a Simulator with Coverage Monitoring

The first step is choosing an RTL simulator that has built-in coverage monitoring capabilities, such as:

  • Mentor Graphics ModelSim
  • Synopsys VCS
  • Cadence Incisive
  • Aldec Active-HDL

These simulators have coverage monitors that can track code execution during simulation runs and generate coverage reports. For example, ModelSim has a Code Coverage tool that can monitor statement, expression, condition, toggle, FSM state, and assertion coverage.

2. Instrumenting the Design

Next, the firmware code needs to be instrumented to enable coverage monitoring. This involves inserting temporary tracking logic into the RTL code that the simulator can use to detect when parts of the code are exercised. For example, Synopsys VCS uses Verilog PLI routines and coverage groups to insert hooks into the code for coverage tracking.

3. Creating Stimulus Testbenches

Comprehensive stimulus testbenches need to be created to exercise the various features and use cases of the firmware code base. The testbenches should be designed to stimulate both nominal operations as well as corner cases using randomized, constrained test vectors. For a processor like Cortex-M0/M0+, the testbench can drive instruction sequences, interrupts, peripherals, and memory interactions.

4. Running Extensive Simulations

The instrumented firmware code is then co-simulated with the testbench stimulus to run extensive simulations. Thousands of randomized test cases may need to be executed to provide sufficient test coverage. When code is executed during simulation, the coverage monitors built into the simulator track which parts of the code are exercised.

5. Generating Coverage Reports

After simulation, detailed code coverage reports can be generated. ModelSim and other commercial simulators have built-in coverage viewing, analysis, and reporting capabilities. Reports may include:

  • Statement coverage – % of statements executed
  • Branch coverage – % of conditional branches tested
  • Expression coverage – % of operand expressions evaluated
  • FSM coverage – % of state transitions exercised

The reports quantify how thoroughly the stimulus vectors have exercised the firmware code. Engineers can analyze the reports to find untouched areas of code that may require additional test cases.

6. Improving Stimulus to Increase Coverage

Looking at code coverage reports, the stimulus testbenches can be improved to increase coverage. Additional tests can be added to exercise untested parts of the code. Randomization can be tuned to better cover corner cases. The goal is to incrementally increase code coverage by enhancing the simulation-based verification environment and testbenches.

7. Automating with Scripting

Checking code coverage requires running many iterative simulations, so the flow is often automated using scripting. Tcl is commonly used to script ModelSim, while Python can automate Synopsys VCS and other simulators. Scripts allow automatically compiling stimulus tests, running batches of simulations, generating coverage reports, and analyzing results.

Key Tools Summary

In summary, the key tools and techniques for checking firmware code coverage in RTL simulation for ARM Cortex-M0/M0+ include:

  • Coverage-capable RTL simulators like ModelSim, VCS, Incisive
  • Design instrumentation for tracking coverage
  • Stimulus testbenches to exercise firmware code
  • Automated simulation scripts to run tests
  • Coverage reporting to quantify test thoroughness
  • Iteratively improving tests to increase coverage

Using these tools and techniques allows thorough RTL simulation-based verification and firmware code coverage analysis during the pre-silicon development phase for ARM Cortex-M0/M0+ processor cores and associated subsystems.

Implementing the Flow with ModelSim

As a specific example, here is an overview of how the firmware code coverage flow can be implemented using ModelSim from Mentor Graphics:

1. Instrumenting RTL Code

The RTL design is instrumented for coverage tracking using PLI based monitors that can hook into the simulator. $coverage_control() and $coverage_db() system tasks insert tracking logic.

2. Creating Testbench

A testbench is created to exercise the RTL code functionality. Constrained random test cases, interrupts, peripheral models, and bus functional models are developed.

3. Enabling Coverage

In ModelSim, coverage is enabled using the vsim -coverage command line option. This activates monitoring based on the instrumentation.

4. Running Tests

The instrumented RTL and testbench are co-simulated, while ModelSim accumulates coverage data for each simulation run.

5. Coverage Reporting

Detailed code coverage reports can be generated from the ModelSim GUI or command line using commands like coverage report, coverage attribute, coverage save, etc.

6. Improving Stimulus

Tests are refined to increase coverage metrics based on analysis of reports. The overall verification environment improves iteratively.

7. Automation with Tcl

Tcl scripting allows automating compilation, simulation execution, coverage analysis, and results processing for efficient regression testing.

This demonstrates an example firmware code coverage methodology using the ModelSim toolset for RTL simulation of ARM Cortex-M0/M0+ designs.

Conclusion

Checking firmware code coverage during RTL simulation for ARM Cortex-M0/M0+ requires specialized verification techniques. Simulators with built-in coverage monitoring like ModelSim are used. The design is instrumented, testbenches created, and iterative simulations run to exercise the code. Automated flows generate detailed coverage reports to quantify coverage and find untested areas needing new stimulus. This rigorous approach ensures thorough pre-silicon firmware verification and maximal code coverage for ARM Cortex-M0/M0+ processors.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article Arm cortex m0 Dhrystone MIPS
Next Article M0 SDK Load Program From External SPI Flash
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

Troubleshooting “Failed to call GENERATE_APP” errors in Vitis w/ Cortext M1

The “Failed to call GENERATE_APP” error when building a Vitis…

9 Min Read

Using ST-Link debugger with Cortex-M1 FPGA design

The ST-Link debugger is an extremely useful tool for debugging…

6 Min Read

Dangers of Using Bit Banding for Peripheral Register Access in ARM Cortex M3

Bit banding is a useful feature in ARM Cortex M3…

5 Min Read

What is core lockup?

Core lockup refers to a situation where a CPU core…

10 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account