#include <stdio.h>
#include "defines.h"
Go to the source code of this file.
Functions | |
| void | memory_get_stat (vsignal *sig, unsigned int *wr_hit, unsigned int *rd_hit, unsigned int *ae_total, unsigned int *tog01_hit, unsigned int *tog10_hit, unsigned int *tog_total, unsigned int *excluded, bool *cov_found, bool ignore_excl) |
| Calculates the memory coverage numbers for a given memory signal. | |
| void | memory_get_stats (func_unit *funit, unsigned int *wr_hit, unsigned int *rd_hit, unsigned int *ae_total, unsigned int *tog01_hit, unsigned int *tog10_hit, unsigned int *tog_total, unsigned int *excluded, bool *cov_found) |
| Calculates memory coverage numbers for the specified signal list. | |
| void | memory_get_funit_summary (func_unit *funit, unsigned int *hit, unsigned int *excluded, unsigned int *total) |
| Gets memory summary information for a GUI request. | |
| void | memory_get_inst_summary (funit_inst *funit, unsigned int *hit, unsigned int *excluded, unsigned int *total) |
| Gets memory summary information for a GUI request. | |
| void | memory_get_coverage (func_unit *funit, const char *signame, char **pdim_str, char **pdim_array, char **udim_str, char **memory_info, int *excluded, char **reason) |
| Gets coverage information for the specified memory. | |
| void | memory_collect (func_unit *funit, int cov, sig_link **head, sig_link **tail) |
| Collects all signals that are memories and match the given coverage metric for the given functional unit. | |
| void | memory_report (FILE *ofile, bool verbose) |
| Generates report output for line coverage. | |
|
||||||||||||||||||||
|
Collects all signals that are memories and match the given coverage metric for the given functional unit. Collects all signals that are memories and match the given coverage type and stores them in the given signal list.
00506 { PROFILE(MEMORY_COLLECT);
00507
00508 func_iter fi; /* Functional unit iterator */
00509 vsignal* sig; /* Pointer to current signal */
00510 unsigned int wr_hit = 0; /* Total number of addressable elements written */
00511 unsigned int rd_hit = 0; /* Total number of addressable elements read */
00512 unsigned int ae_total = 0; /* Total number of addressable elements */
00513 unsigned int hit01 = 0; /* Number of bits that toggled from 0 to 1 */
00514 unsigned int hit10 = 0; /* Number of bits that toggled from 1 to 0 */
00515 unsigned int tog_total = 0; /* Total number of toggle bits */
00516 unsigned int excluded = 0; /* Number of excluded memory coverage points */
00517 bool cov_found;
00518
00519 func_iter_init( &fi, funit, FALSE, TRUE );
00520
00521 while( (sig = func_iter_get_next_signal( &fi )) != NULL ) {
00522
00523 if( sig->suppl.part.type == SSUPPL_TYPE_MEM ) {
00524
00525 ae_total = 0;
00526
00527 memory_get_stat( sig, &ae_total, &wr_hit, &rd_hit, &tog_total, &hit01, &hit10, &excluded, &cov_found, TRUE );
00528
00529 /* If this signal meets the coverage requirement, add it to the signal list */
00530 if( ((cov == 1) && (wr_hit > 0) && (rd_hit > 0) && (hit01 == tog_total) && (hit10 == tog_total)) ||
00531 ((cov == 0) && ((wr_hit == 0) || (rd_hit == 0) || (hit01 < tog_total) || (hit10 < tog_total))) ) {
00532
00533 sig_link_add( sig, head, tail );
00534
00535 }
00536
00537 }
00538
00539 }
00540
00541 func_iter_dealloc( &fi );
00542
00543 PROFILE_END;
00544
00545 }
|
|
||||||||||||||||||||||||||||||||||||
|
Gets coverage information for the specified memory. Retrieves memory coverage information for the given signal in the specified functional unit.
00413 { PROFILE(MEMORY_GET_COVERAGE);
00414
00415 func_iter fi; /* Functional unit iterator */
00416 vsignal* sig; /* Pointer to current signal */
00417 unsigned int i; /* Loop iterator */
00418 char tmp1[20]; /* Temporary string holder */
00419 char tmp2[20]; /* Temporary string holder */
00420 unsigned int rv; /* Return value */
00421 exclude_reason* er;
00422
00423 /* Find the signal in the functional unit */
00424 func_iter_init( &fi, funit, FALSE, TRUE );
00425 while( ((sig = func_iter_get_next_signal( &fi )) != NULL) && (strcmp( sig->name, signame ) != 0) );
00426 func_iter_dealloc( &fi );
00427 assert( sig != NULL );
00428
00429 /* Allocate and populate the pdim_array and pdim_width parameters */
00430 *pdim_array = (char*)malloc_safe( 1 );
00431 (*pdim_array)[0] = '\0';
00432 memory_create_pdim_bit_array( pdim_array, sig, "", sig->pdim_num );
00433
00434 /* Allocate and populate the pdim_str string */
00435 *pdim_str = NULL;
00436 for( i=sig->udim_num; i<(sig->pdim_num + sig->udim_num); i++ ) {
00437 unsigned int slen;
00438 rv = snprintf( tmp1, 20, "%d", sig->dim[i].msb );
00439 assert( rv < 20 );
00440 rv = snprintf( tmp2, 20, "%d", sig->dim[i].lsb );
00441 assert( rv < 20 );
00442 slen = strlen( tmp1 ) + strlen( tmp2 ) + 4;
00443 *pdim_str = (char*)realloc_safe( *pdim_str, (strlen( *pdim_str ) + 1), slen );
00444 if( i == sig->udim_num ) {
00445 rv = snprintf( *pdim_str, slen, "[%s:%s]", tmp1, tmp2 );
00446 assert( rv < slen );
00447 } else {
00448 strcat( *pdim_str, "[" );
00449 strcat( *pdim_str, tmp1 );
00450 strcat( *pdim_str, ":" );
00451 strcat( *pdim_str, tmp2 );
00452 strcat( *pdim_str, "]" );
00453 }
00454 }
00455
00456 /* Allocate and populate the udim_info string */
00457 *udim_str = NULL;
00458 for( i=0; i<sig->udim_num; i++ ) {
00459 unsigned int slen;
00460 rv = snprintf( tmp1, 20, "%d", sig->dim[i].msb );
00461 assert( rv < 20 );
00462 rv = snprintf( tmp2, 20, "%d", sig->dim[i].lsb );
00463 assert( rv < 20 );
00464 slen = strlen( tmp1 ) + strlen( tmp2 ) + 4;
00465 *udim_str = (char*)realloc_safe( *udim_str, (strlen( *udim_str ) + 1), slen );
00466 if( i == 0 ) {
00467 rv = snprintf( *udim_str, slen, "[%s:%s]", tmp1, tmp2 );
00468 assert( rv < slen );
00469 } else {
00470 strcat( *udim_str, "[" );
00471 strcat( *udim_str, tmp1 );
00472 strcat( *udim_str, ":" );
00473 strcat( *udim_str, tmp2 );
00474 strcat( *udim_str, "]" );
00475 }
00476 }
00477
00478 /* Populate the memory_info string */
00479 *memory_info = (char*)malloc_safe( 1 );
00480 (*memory_info)[0] = '\0';
00481 memory_get_mem_coverage( memory_info, sig, 0, "", 0, sig->value->width );
00482
00483 /* Populate the excluded value */
00484 *excluded = sig->suppl.part.excluded;
00485
00486 /* Populate the exclusion reason */
00487 if( (*excluded == 1) && ((er = exclude_find_exclude_reason( 'M', sig->id, funit )) != NULL) ) {
00488 *reason = strdup_safe( er->reason );
00489 } else {
00490 *reason = NULL;
00491 }
00492
00493 PROFILE_END;
00494
00495 }
|
|
||||||||||||||||||||
|
Gets memory summary information for a GUI request. Retrieves memory summary information for a given functional unit made by a GUI request.
00173 { PROFILE(MEMORY_GET_FUNIT_SUMMARY);
00174
00175 *hit = funit->stat->mem_wr_hit + funit->stat->mem_rd_hit + funit->stat->mem_tog01_hit + funit->stat->mem_tog10_hit;
00176 *excluded = funit->stat->mem_excluded;
00177 *total = (funit->stat->mem_ae_total * 2) + (funit->stat->mem_tog_total * 2);
00178
00179 PROFILE_END;
00180
00181 }
|
|
||||||||||||||||||||
|
Gets memory summary information for a GUI request. Retrieves memory summary information for a given functional unit instance made by a GUI request.
00191 { PROFILE(MEMORY_GET_INST_SUMMARY);
00192
00193 *hit = inst->stat->mem_wr_hit + inst->stat->mem_rd_hit + inst->stat->mem_tog01_hit + inst->stat->mem_tog10_hit;
00194 *excluded = inst->stat->mem_excluded;
00195 *total = (inst->stat->mem_ae_total * 2) + (inst->stat->mem_tog_total * 2);
00196
00197 PROFILE_END;
00198
00199 }
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
Calculates the memory coverage numbers for a given memory signal. Calculates the total and hit memory coverage information for the given memory signal.
00065 { PROFILE(MEMORY_GET_STAT);
00066
00067 unsigned int i; /* Loop iterator */
00068 unsigned int pwidth; /* Width of packed portion of memory */
00069 bool ae_cov_found = TRUE; /* Set to TRUE if wr/rd hits equals the total */
00070 bool tog_cov_found = FALSE; /* Set to TRUE if tog01/10 hits equals the total */
00071
00072 /* Calculate width of smallest addressable element */
00073 pwidth = 1;
00074 for( i=(sig->udim_num); i<(sig->udim_num + sig->pdim_num); i++ ) {
00075 if( sig->dim[i].msb > sig->dim[i].lsb ) {
00076 pwidth *= (sig->dim[i].msb - sig->dim[i].lsb) + 1;
00077 } else {
00078 pwidth *= (sig->dim[i].lsb - sig->dim[i].msb) + 1;
00079 }
00080 }
00081
00082 /* Calculate total number of addressable elements and their write/read information */
00083 for( i=0; i<sig->value->width; i+=pwidth ) {
00084 if( (sig->suppl.part.excluded == 1) && !ignore_excl ) {
00085 (*wr_hit)++;
00086 (*rd_hit)++;
00087 *excluded += 2;
00088 } else {
00089 unsigned int wr = 0;
00090 unsigned int rd = 0;
00091 vector_mem_rw_count( sig->value, (int)i, (int)((i + pwidth) - 1), &wr, &rd );
00092 if( wr > 0 ) {
00093 (*wr_hit)++;
00094 }
00095 if( rd > 0 ) {
00096 (*rd_hit)++;
00097 }
00098 ae_cov_found &= (wr > 0) && (rd > 0);
00099 }
00100 (*ae_total)++;
00101 }
00102
00103 /* Calculate toggle coverage information for the memory */
00104 *tog_total += sig->value->width;
00105 if( (sig->suppl.part.excluded == 1) && !ignore_excl ) {
00106 *tog01_hit += sig->value->width;
00107 *tog10_hit += sig->value->width;
00108 *excluded += (sig->value->width * 2);
00109 } else {
00110 unsigned int hit01 = 0;
00111 unsigned int hit10 = 0;
00112 vector_toggle_count( sig->value, &hit01, &hit10 );
00113 *tog01_hit += hit01;
00114 *tog10_hit += hit10;
00115 tog_cov_found = (hit01 == sig->value->width) && (hit10 == sig->value->width);
00116 }
00117
00118 *cov_found |= ae_cov_found && tog_cov_found;
00119
00120 PROFILE_END;
00121
00122 }
|
|
||||||||||||||||||||||||||||||||||||||||
|
Calculates memory coverage numbers for the specified signal list. Gathers memory statistics for the memories in the given signal list.
00137 { PROFILE(MEMORY_GET_STATS);
00138
00139 if( !funit_is_unnamed( funit ) ) {
00140
00141 func_iter fi;
00142 vsignal* sig;
00143
00144 func_iter_init( &fi, funit, FALSE, TRUE );
00145
00146 while( (sig = func_iter_get_next_signal( &fi )) != NULL ) {
00147
00148 /* Calculate only for memory elements (must contain one or more unpacked dimensions) */
00149 if( (sig->suppl.part.type == SSUPPL_TYPE_MEM) && (sig->udim_num > 0) ) {
00150
00151 memory_get_stat( sig, wr_hit, rd_hit, ae_total, tog01_hit, tog10_hit, tog_total, excluded, cov_found, FALSE );
00152
00153 }
00154
00155 }
00156
00157 func_iter_dealloc( &fi );
00158
00159 }
00160
00161 PROFILE_END;
00162
00163 }
|
|
||||||||||||
|
Generates report output for line coverage. Outputs the memory portion of the report to the given output stream.
01237 { PROFILE(MEMORY_REPORT);
01238
01239 bool missed_found = FALSE; /* If set to TRUE, indicates that untoggled bits were found */
01240 inst_link* instl; /* Pointer to current instance link */
01241 int acc_hits01 = 0; /* Accumulated hits 0 -> 1 count */
01242 int acc_hits10 = 0; /* Accumulated hits 1 -> 0 count */
01243 int acc_tog_total = 0; /* Accumulated bit toggle count */
01244 int acc_wr_hits = 0; /* Accumulated number of addressable elements written */
01245 int acc_rd_hits = 0; /* Accumulated number of addressable elements read */
01246 int acc_ae_total = 0; /* Accumulated number of addressable elements */
01247
01248 fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
01249 fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MEMORY COVERAGE RESULTS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
01250 fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
01251
01252 if( report_instance ) {
01253
01254 fprintf( ofile, " Toggle 0 -> 1 Toggle 1 -> 0\n" );
01255 fprintf( ofile, "Instance Hit/ Miss/Total Percent hit Hit/ Miss/Total Percent hit\n" );
01256 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01257
01258 instl = db_list[curr_db]->inst_head;
01259 while( instl != NULL ) {
01260 missed_found |= memory_toggle_instance_summary( ofile, instl->inst, (instl->inst->suppl.name_diff ? "<NA>" : "*"), &acc_hits01, &acc_hits10, &acc_tog_total );
01261 instl = instl->next;
01262 }
01263 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01264 (void)memory_display_toggle_instance_summary( ofile, "Accumulated", acc_hits01, acc_hits10, acc_tog_total );
01265
01266 fprintf( ofile, "\n" );
01267 fprintf( ofile, " Addressable elements written Addressable elements read\n" );
01268 fprintf( ofile, " Hit/ Miss/Total Percent hit Hit/ Miss/Total Percent hit\n" );
01269 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01270
01271 instl = db_list[curr_db]->inst_head;
01272 while( instl != NULL ) {
01273 missed_found |= memory_ae_instance_summary( ofile, instl->inst, (instl->inst->suppl.name_diff ? "<NA>" : "*"), &acc_wr_hits, &acc_rd_hits, &acc_ae_total );
01274 instl = instl->next;
01275 }
01276 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01277 (void)memory_display_ae_instance_summary( ofile, "Accumulated", acc_wr_hits, acc_rd_hits, acc_ae_total );
01278
01279 if( verbose && (missed_found || report_covered || report_exclusions) ) {
01280 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01281 instl = db_list[curr_db]->inst_head;
01282 while( instl != NULL ) {
01283 memory_instance_verbose( ofile, instl->inst, (instl->inst->suppl.name_diff ? "<NA>" : "*") );
01284 instl = instl->next;
01285 }
01286 }
01287
01288 } else {
01289
01290 fprintf( ofile, " Toggle 0 -> 1 Toggle 1 -> 0\n" );
01291 fprintf( ofile, "Module/Task/Function Filename Hit/ Miss/Total Percent hit Hit/ Miss/Total Percent hit\n" );
01292 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01293
01294 missed_found |= memory_toggle_funit_summary( ofile, db_list[curr_db]->funit_head, &acc_hits01, &acc_hits10, &acc_tog_total );
01295 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01296 (void)memory_display_toggle_funit_summary( ofile, "Accumulated", "", acc_hits01, acc_hits10, acc_tog_total );
01297
01298 fprintf( ofile, "\n" );
01299 fprintf( ofile, " Addressable elements written Addressable elements read\n" );
01300 fprintf( ofile, " Hit/ Miss/Total Percent hit Hit/ Miss/Total Percent hit\n" );
01301 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01302
01303 missed_found |= memory_ae_funit_summary( ofile, db_list[curr_db]->funit_head, &acc_wr_hits, &acc_rd_hits, &acc_ae_total );
01304 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01305 (void)memory_display_ae_funit_summary( ofile, "Accumulated", "", acc_wr_hits, acc_rd_hits, acc_ae_total );
01306
01307 if( verbose && (missed_found || report_covered || report_exclusions) ) {
01308 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01309 memory_funit_verbose( ofile, db_list[curr_db]->funit_head );
01310 }
01311
01312 }
01313
01314 fprintf( ofile, "\n\n" );
01315
01316 PROFILE_END;
01317
01318 }
|
1.3.4