« Prev | Next » Using Toggle Coverage Introduction Toggle coverage reports describe design activity in terms of changes in signal values. Toggle coverage reports can identify a variety of issues in the design and the testbench, for example: Identify signals which were not initialized Locate areas of the design which are not properly tested by the testbench Measure power usage This document shows how to collect toggle coverage statistics for the v_bjack project and how to correlate toggle coverage with code coverage. Using Toggle Coverage This section presents how to collect toggle coverage data by using the GUI options and the command line and then analyze the results in the Toggle Coverage Viewer. The toggle coverage data collected during the simulation is saved to a database which is automatically created when the simulation is finished. The toggle coverage statistics can be presented in a graphical form in a stand-alone Toggle Coverage Viewer. The viewer shows a synchronized display of a design structure and the source code with the coverage results. Additionally, the viewer allows generating reports. Collecting Toggle Coverage Data To collect toggle coverage data for the v_bjack project do the following: Start Active-HDL and open the v_bjack workspace using the Open Workspace/Design Explorer option from the File menu. The v_bjack workspace is located in the Active-HDL\Samples\Verilog_Designs branch in the Workspace/Design Explorer window. Alternatively, you can type the following in the command line: workspace open C:\My_Designs\Samples_<version>\V_Bjack\V_Bjack.aws Compile all source files. The source files should be compiled in the following order: Gates.v, Bin2bcd.v, Bcd2led.v, Bjack_c.v (this file should be generated from Bjack_c.asf), Gen.v, Johnson8.v, Mux.v, V_bjack.v and Tb.v. This can be done either in the GUI by right-clicking the V_BJACK design file and choosing the Compile All option from the context menu or by selecting the Compile All option from the Design menu. Alternatively, you can type the following in the command line: alog -dbg $dsn\src\Gates.v $dsn\src\Bin2bcd.v $dsn\src\Bcd2led.v $dsn\src\Bjack_c.v $dsn\src\Gen.v $dsn\src\Johnson8.v $dsn\src\Mux.v $dsn\src\V_bjack.v $dsn\src\Tb.v You must pass the -dbg argument of the alog command to generate debugging information and in consequence, collect toggle coverage statistics. For more information, refer to the alog command. Locate the Tb.v file in the Files tab, expand it, right-click the V_Bjack_tb module icon and select the Set as Top-Level option from the pop-up menu. Figure 1. Selecting V_Bjack_tb as top-level Alternatively, you can type the following in the command line: module V_BJACK_tb Go to the Access to Design Objects category of the Design Settings dialog box. Uncheck the Limit read access to design top-level signals only option, check the Read(+r) option, and select the Apply button. Press the OK button to return to Active-HDL. Select the Initialize Simulation option from the Simulation menu or type the following command: asim +access +r V_BJACK_tb The +access +r argument of the asim command (and the corresponding Read(+r) option) enables read access to design regions and allows recording signals values to the simulation database. For more information, refer to the asim command. To initialize toggle coverage for the v_bjack project, go to the Structure tab, right-click V_BJACK_tb and select the Toggle Coverage | Toggle On option or go to the Simulation menu and select the Toggle Coverage | Toggle On option. The Toggle Coverage Options dialog box appears. In the Toggle Coverage Options dialog box check the following options: Add recursively option in the Signals section. Signal Type option in the Additional Information section. Press OK to start the toggle coverage. Figure 2. Toggle Coverage Options Alternatively, you can use the following command: toggle -toggle_type full -nosingle_edge -unknown_edge escape -rec -xml -o $dsn\toggle\toggle.xml -report all -type {/V_BJACK_tb/*} The -toggle_type full argument defines that the toggle report will be created in the full mode. In the full mode, the report shows if both rising and falling edge occurred on monitored signals. The -nosingle_edge argument defines that a signal should be considered as toggled if it experienced both a rising and a falling edge. The -unknown_edge escape argument specifies that the unknown value does not prevent recognizing the transition as the rising edge or as the falling edge. The format of the report is set to XML. The $dsn\toggle\toggle.xml argument sets the location of the report to be saved. The information about signal types will be included in the report which is specified by the -type argument. The -report all argument specifies that all signals will be included in the report. The previously mentioned arguments of the toggle command are used by default in the GUI options. The command specifies that data for the toggle coverage report should be collected from all signals in the V_BJACK_tb region and all its subregions (-rec /V_BJACK_tb/*). For more information, refer to the toggle command. To run the simulation, select the Run command from the Simulation menu or use the following command: run -all The simulator will run the simulation until there are no more events to process. When the simulation finishes, select the End Simulation command from the Simulation menu or use the following command: endsim The toggle coverage report will be saved automatically to the toggle subdirectory. You can display the XML report in any browser supporting XML, as shown in the picture below. Figure 3. XML report in Internet Explorer Toggle coverage data can also be viewed in a dedicated viewer - Toggle Coverage Viewer. The functionality of the Toggle Coverage Viewer is enhanced in comparison with a regular browser. To start the toggle coverage report in the Toggle Coverage Viewer, select Toggle Coverage Viewer from the Tools menu. The stand-alone Toggle Coverage Viewer window will be displayed. Select the Open command from the File menu, go to the toggle subdirectory and open the toggle.xml report. Figure 4. Toggle Coverage Viewer The Filter button and the neighboring combo box allow to filter out signals depending on whether they toggled during simulation. By default the Toggle Coverage Viewer displays all signals in a hierarchical view which allows to group signals by hierarchy region. If you prefer to see all signals in alphabetical order, click the Show/hide hierarchy browser button on the toolbar to enable a flat view. Figure 5. Flat View Correlating Code Coverage Data with Toggle Coverage Data If you want to verify how well your design was exercised by the testbench, you may confront code coverage results with toggle coverage results. The code coverage viewer shows how many times each HDL statement executed during simulation. Code coverage data for the v_bjack project is shown below. (For details on using code coverage consult Active-HDL documentation.) Figure 6. Correlating Code Coverage Data The Code Coverage Viewer shows statistics for a Johnson counter located in the UUT/I17 region. All executable statements defining the counter were executed at least once. Toggle coverage data for the same region is displayed below. Figure 7. Toggle Coverage for the Johnson counter UUT/I17 Toggle coverage reveals that several signals in the examined region (e.g. the tmp register) did not toggle. The example shows that combining toggle coverage with code coverage can provide the most comprehensive information about how well the design was exercised by the testbench. Previous article Next article