Contains functions for determining/reporting toggle coverage. More...
#include <stdio.h>
#include "defines.h"
Go to the source code of this file.
Functions | |
void | toggle_get_stats (func_unit *funit, unsigned int *hit01, unsigned int *hit10, unsigned int *excluded, unsigned int *total, bool *cov_found) |
Calculates the toggle coverage for the specifed expression and signal lists. | |
void | toggle_collect (func_unit *funit, int cov, sig_link **sig_head, sig_link **sig_tail) |
Collects all toggle expressions that match the specified coverage indication. | |
void | toggle_get_coverage (func_unit *funit, char *sig_name, int *msb, int *lsb, char **tog01, char **tog10, int *excluded, char **reason) |
Gets toggle coverage information for a single signal in the specified functional unit. | |
void | toggle_get_funit_summary (func_unit *funit, unsigned int *hit, unsigned int *excluded, unsigned int *total) |
Gets total and hit toggle signal status for the specified functional unit. | |
void | toggle_get_inst_summary (funit_inst *inst, unsigned int *hit, unsigned int *excluded, unsigned int *total) |
Gets total and hit toggle signal status for the specified functional unit instance. | |
void | toggle_report (FILE *ofile, bool verbose) |
Generates report output for toggle coverage. |
Contains functions for determining/reporting toggle coverage.
Collects all toggle expressions that match the specified coverage indication.
Searches the list of signals for the specified functional unit for signals that are either covered or uncovered. When a signal is found that meets the requirements, signal is added to the signal list.
funit | Pointer to functional unit | |
cov | Specifies to get uncovered (0) or covered (1) signals | |
sig_head | Pointer to head of list of covered/uncovered signals | |
sig_tail | Pointer to tail of list of covered/uncovered signals |
References FALSE, func_iter_dealloc(), func_iter_get_next_signal(), func_iter_init(), ssuppl_u::mba, ssuppl_u::part, PROFILE, PROFILE_END, sig_link_add(), SSUPPL_TYPE_DECL_REAL, SSUPPL_TYPE_DECL_SREAL, SSUPPL_TYPE_ENUM, SSUPPL_TYPE_IMPLICIT_REAL, SSUPPL_TYPE_IMPLICIT_SREAL, SSUPPL_TYPE_MEM, SSUPPL_TYPE_PARAM, SSUPPL_TYPE_PARAM_REAL, vsignal_s::suppl, TRUE, ssuppl_u::type, vsignal_s::value, vector_toggle_count(), and vector_s::width.
00122 { PROFILE(TOGGLE_COLLECT); 00123 00124 func_iter fi; /* Functional unit iterator */ 00125 vsignal* sig; /* Pointer to current signal */ 00126 unsigned int hit01; /* Number of bits that toggled from 0 to 1 */ 00127 unsigned int hit10; /* Number of bits that toggled from 1 to 0 */ 00128 00129 func_iter_init( &fi, funit, FALSE, TRUE ); 00130 00131 while( (sig = func_iter_get_next_signal( &fi )) != NULL ) { 00132 00133 hit01 = 0; 00134 hit10 = 0; 00135 00136 if( (sig->suppl.part.type != SSUPPL_TYPE_PARAM) && 00137 (sig->suppl.part.type != SSUPPL_TYPE_PARAM_REAL) && 00138 (sig->suppl.part.type != SSUPPL_TYPE_ENUM) && 00139 (sig->suppl.part.type != SSUPPL_TYPE_MEM) && 00140 (sig->suppl.part.type != SSUPPL_TYPE_DECL_REAL) && 00141 (sig->suppl.part.type != SSUPPL_TYPE_DECL_SREAL) && 00142 (sig->suppl.part.type != SSUPPL_TYPE_IMPLICIT_REAL) && 00143 (sig->suppl.part.type != SSUPPL_TYPE_IMPLICIT_SREAL) && 00144 (sig->suppl.part.mba == 0) ) { 00145 00146 vector_toggle_count( sig->value, &hit01, &hit10 ); 00147 00148 /* If this signal meets the coverage requirement, add it to the signal list */ 00149 if( ((cov == 1) && (hit01 == sig->value->width) && (hit10 == sig->value->width)) || 00150 ((cov == 0) && ((hit01 < sig->value->width) || (hit10 < sig->value->width))) ) { 00151 00152 sig_link_add( sig, sig_head, sig_tail ); 00153 00154 } 00155 00156 } 00157 00158 } 00159 00160 func_iter_dealloc( &fi ); 00161 00162 PROFILE_END; 00163 00164 }
void toggle_get_coverage | ( | func_unit * | funit, | |
char * | sig_name, | |||
int * | msb, | |||
int * | lsb, | |||
char ** | tog01, | |||
char ** | tog10, | |||
int * | excluded, | |||
char ** | reason | |||
) |
Gets toggle coverage information for a single signal in the specified functional unit.
Returns toggle coverage information for a specified signal in a specified functional unit. This is needed by the GUI for verbose toggle coverage display.
funit | Pointer to functional unit | |
sig_name | Name of signal within the specified functional unit to get toggle coverage information for | |
msb | Most-significant bit position of the requested signal | |
lsb | Least-significant bit position of the requested signal | |
tog01 | Toggle vector of bits transitioning from a 0 to a 1 | |
tog10 | Toggle vector of bits transitioning from a 1 to a 0 | |
excluded | Pointer to integer specifying if this signal should be excluded or not | |
reason | Reason for exclusion if one exists |
References vsignal_s::dim, exclude_find_exclude_reason(), ssuppl_u::excluded, FALSE, func_iter_dealloc(), func_iter_get_next_signal(), func_iter_init(), vsignal_s::id, dim_range_s::lsb, dim_range_s::msb, vsignal_s::name, ssuppl_u::part, PROFILE, PROFILE_END, exclude_reason_s::reason, strdup_safe, vsignal_s::suppl, TRUE, vector_s::ul, vector_s::value, vsignal_s::value, vector_get_toggle01_ulong(), vector_get_toggle10_ulong(), and vector_s::width.
00179 { PROFILE(TOGGLE_GET_COVERAGE); 00180 00181 func_iter fi; /* Functional unit iterator */ 00182 vsignal* sig; /* Pointer to current signal */ 00183 exclude_reason* er; /* Pointer to found exclude reason structure */ 00184 00185 /* Find the matching signal */ 00186 func_iter_init( &fi, funit, FALSE, TRUE ); 00187 while( ((sig = func_iter_get_next_signal( &fi )) != NULL) && (strcmp( sig->name, sig_name ) != 0) ); 00188 func_iter_dealloc( &fi ); 00189 00190 assert( sig != NULL ); 00191 assert( sig->dim != NULL ); 00192 00193 *msb = sig->dim[0].msb; 00194 *lsb = sig->dim[0].lsb; 00195 *tog01 = vector_get_toggle01_ulong( sig->value->value.ul, sig->value->width ); 00196 *tog10 = vector_get_toggle10_ulong( sig->value->value.ul, sig->value->width ); 00197 *excluded = sig->suppl.part.excluded; 00198 00199 /* If the toggle is currently excluded, check to see if there's a reason associated with it */ 00200 if( (*excluded == 1) && ((er = exclude_find_exclude_reason( 'T', sig->id, funit )) != NULL) ) { 00201 *reason = strdup_safe( er->reason ); 00202 } else { 00203 *reason = NULL; 00204 } 00205 00206 PROFILE_END; 00207 00208 }
void toggle_get_funit_summary | ( | func_unit * | funit, | |
unsigned int * | hit, | |||
unsigned int * | excluded, | |||
unsigned int * | total | |||
) |
Gets total and hit toggle signal status for the specified functional unit.
Looks up summary information for specified functional unit.
funit | Pointer to found functional unit | |
hit | Pointer to total number of toggles hit in this functional unit | |
excluded | Pointer to number of excluded bits | |
total | Pointer to total number of toggles in this functional unit |
References PROFILE, PROFILE_END, func_unit_s::stat, statistic_s::tog01_hit, statistic_s::tog10_hit, statistic_s::tog_excluded, and statistic_s::tog_total.
00218 { PROFILE(TOGGLE_GET_FUNIT_SUMMARY); 00219 00220 *hit = (funit->stat->tog01_hit + funit->stat->tog10_hit); 00221 *excluded = funit->stat->tog_excluded; 00222 *total = (funit->stat->tog_total * 2); 00223 00224 PROFILE_END; 00225 00226 }
void toggle_get_inst_summary | ( | funit_inst * | inst, | |
unsigned int * | hit, | |||
unsigned int * | excluded, | |||
unsigned int * | total | |||
) |
Gets total and hit toggle signal status for the specified functional unit instance.
Looks up summary information for specified functional unit instance.
inst | Pointer to found functional unit instance | |
hit | Pointer to total number of toggles hit in this functional unit instance | |
excluded | Pointer to number of excluded bits | |
total | Pointer to total number of toggles in this functional unit instance |
References PROFILE, PROFILE_END, funit_inst_s::stat, statistic_s::tog01_hit, statistic_s::tog10_hit, statistic_s::tog_excluded, and statistic_s::tog_total.
00236 { PROFILE(TOGGLE_GET_INST_SUMMARY); 00237 00238 *hit = (inst->stat->tog01_hit + inst->stat->tog10_hit); 00239 *excluded = inst->stat->tog_excluded; 00240 *total = (inst->stat->tog_total * 2); 00241 00242 PROFILE_END; 00243 00244 }
void toggle_get_stats | ( | func_unit * | funit, | |
unsigned int * | hit01, | |||
unsigned int * | hit10, | |||
unsigned int * | excluded, | |||
unsigned int * | total, | |||
bool * | cov_found | |||
) |
Calculates the toggle coverage for the specifed expression and signal lists.
Searches specified expression list and signal list, gathering information about toggled bits. For each bit that is found in the design, the total value is incremented by one. For each bit that toggled from a 0 to a 1, the value of hit01 is incremented by one. For each bit that toggled from a 1 to a 0, the value of hit10 is incremented by one.
funit | Pointer to named functional unit to search | |
hit01 | Number of bits toggling from 0 to 1 during simulation | |
hit10 | Number of bits toggling from 1 to 0 during simulation | |
excluded | Pointer to number of excluded bits | |
total | Total number of bits in the design/functional unit | |
cov_found | Set to TRUE if at least one signal was completely covered |
References ssuppl_u::excluded, FALSE, func_iter_dealloc(), func_iter_get_next_signal(), func_iter_init(), funit_is_unnamed(), ssuppl_u::mba, ssuppl_u::part, PROFILE, PROFILE_END, SSUPPL_TYPE_DECL_REAL, SSUPPL_TYPE_DECL_SREAL, SSUPPL_TYPE_ENUM, SSUPPL_TYPE_IMPLICIT_REAL, SSUPPL_TYPE_IMPLICIT_SREAL, SSUPPL_TYPE_MEM, SSUPPL_TYPE_PARAM, SSUPPL_TYPE_PARAM_REAL, vsignal_s::suppl, TRUE, ssuppl_u::type, vsignal_s::value, vector_toggle_count(), and vector_s::width.
Referenced by report_gather_funit_stats(), and report_gather_instance_stats().
00069 { PROFILE(TOGGLE_GET_STATS); 00070 00071 if( !funit_is_unnamed( funit ) ) { 00072 00073 func_iter fi; /* Functional unit iterator */ 00074 vsignal* sig; /* Pointer to current signal */ 00075 00076 func_iter_init( &fi, funit, FALSE, TRUE ); 00077 00078 /* Search signal list */ 00079 while( (sig = func_iter_get_next_signal( &fi )) != NULL ) { 00080 if( (sig->suppl.part.type != SSUPPL_TYPE_PARAM) && 00081 (sig->suppl.part.type != SSUPPL_TYPE_PARAM_REAL) && 00082 (sig->suppl.part.type != SSUPPL_TYPE_ENUM) && 00083 (sig->suppl.part.type != SSUPPL_TYPE_MEM) && 00084 (sig->suppl.part.type != SSUPPL_TYPE_DECL_REAL) && 00085 (sig->suppl.part.type != SSUPPL_TYPE_DECL_SREAL) && 00086 (sig->suppl.part.type != SSUPPL_TYPE_IMPLICIT_REAL) && 00087 (sig->suppl.part.type != SSUPPL_TYPE_IMPLICIT_SREAL) && 00088 (sig->suppl.part.mba == 0) ) { 00089 *total += sig->value->width; 00090 if( sig->suppl.part.excluded == 1 ) { 00091 *hit01 += sig->value->width; 00092 *hit10 += sig->value->width; 00093 *excluded += (sig->value->width * 2); 00094 } else { 00095 unsigned int tmp_hit01 = 0; 00096 unsigned int tmp_hit10 = 0; 00097 vector_toggle_count( sig->value, &tmp_hit01, &tmp_hit10 ); 00098 *hit01 += tmp_hit01; 00099 *hit10 += tmp_hit10; 00100 *cov_found |= ((sig->value->width == tmp_hit01) && (sig->value->width == tmp_hit10)); 00101 } 00102 } 00103 } 00104 00105 func_iter_dealloc( &fi ); 00106 00107 } 00108 00109 PROFILE_END; 00110 00111 }
void toggle_report | ( | FILE * | ofile, | |
bool | verbose | |||
) |
Generates report output for toggle coverage.
After the design is read into the functional unit hierarchy, parses the hierarchy by functional unit, reporting the toggle coverage for each functional unit encountered. The parent functional unit will specify its own toggle coverage along with a total toggle coverage including its children.
ofile | Pointer to file to output results to | |
verbose | Specifies whether or not to provide verbose information |
References curr_db, FALSE, funit_head, inst_link_s::inst, db_s::inst_head, funit_inst_s::name_diff, inst_link_s::next, PROFILE, PROFILE_END, report_covered, report_exclusions, report_instance, funit_inst_s::suppl, toggle_display_funit_summary(), toggle_display_instance_summary(), toggle_funit_summary(), toggle_funit_verbose(), toggle_instance_summary(), and toggle_instance_verbose().
Referenced by report_generate().
00680 { PROFILE(TOGGLE_REPORT); 00681 00682 bool missed_found = FALSE; /* If set to TRUE, indicates that untoggled bits were found */ 00683 inst_link* instl; /* Pointer to current instance link */ 00684 unsigned int acc_hits01 = 0; /* Accumulated 0 -> 1 toggle hit count */ 00685 unsigned int acc_hits10 = 0; /* Accumulated 1 -> 0 toggle hit count */ 00686 unsigned int acc_total = 0; /* Accumulated bit count */ 00687 00688 fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" ); 00689 fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ TOGGLE COVERAGE RESULTS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" ); 00690 fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" ); 00691 00692 if( report_instance ) { 00693 00694 fprintf( ofile, " Toggle 0 -> 1 Toggle 1 -> 0\n" ); 00695 fprintf( ofile, "Instance Hit/ Miss/Total Percent hit Hit/ Miss/Total Percent hit\n" ); 00696 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" ); 00697 00698 instl = db_list[curr_db]->inst_head; 00699 while( instl != NULL ) { 00700 missed_found |= toggle_instance_summary( ofile, instl->inst, (instl->inst->suppl.name_diff ? "<NA>" : "*"), &acc_hits01, &acc_hits10, &acc_total ); 00701 instl = instl->next; 00702 } 00703 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" ); 00704 (void)toggle_display_instance_summary( ofile, "Accumulated", acc_hits01, acc_hits10, acc_total ); 00705 00706 if( verbose && (missed_found || report_covered || report_exclusions) ) { 00707 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" ); 00708 instl = db_list[curr_db]->inst_head; 00709 while( instl != NULL ) { 00710 toggle_instance_verbose( ofile, instl->inst, (instl->inst->suppl.name_diff ? "<NA>" : "*") ); 00711 instl = instl->next; 00712 } 00713 } 00714 00715 } else { 00716 00717 fprintf( ofile, " Toggle 0 -> 1 Toggle 1 -> 0\n" ); 00718 fprintf( ofile, "Module/Task/Function Filename Hit/ Miss/Total Percent hit Hit/ Miss/Total Percent hit\n" ); 00719 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" ); 00720 00721 missed_found = toggle_funit_summary( ofile, db_list[curr_db]->funit_head, &acc_hits01, &acc_hits10, &acc_total ); 00722 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" ); 00723 (void)toggle_display_funit_summary( ofile, "Accumulated", "", acc_hits01, acc_hits10, acc_total ); 00724 00725 if( verbose && (missed_found || report_covered || report_exclusions) ) { 00726 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" ); 00727 toggle_funit_verbose( ofile, db_list[curr_db]->funit_head ); 00728 } 00729 00730 } 00731 00732 fprintf( ofile, "\n\n" ); 00733 00734 PROFILE_END; 00735 00736 }