toggle.c File Reference

#include <stdio.h>
#include <assert.h>
#include "db.h"
#include "defines.h"
#include "exclude.h"
#include "func_iter.h"
#include "func_unit.h"
#include "link.h"
#include "obfuscate.h"
#include "ovl.h"
#include "report.h"
#include "toggle.h"
#include "util.h"
#include "vector.h"

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.
static bool toggle_display_instance_summary (FILE *ofile, char *name, int hits01, int hits10, int total)
static bool toggle_instance_summary (FILE *ofile, funit_inst *root, char *parent_inst, unsigned int *hits01, unsigned int *hits10, unsigned int *total)
static bool toggle_display_funit_summary (FILE *ofile, const char *name, const char *fname, unsigned int hits01, unsigned int hits10, unsigned int total)
static bool toggle_funit_summary (FILE *ofile, funit_link *head, unsigned int *hits01, unsigned int *hits10, unsigned int *total)
static void toggle_display_verbose (FILE *ofile, func_unit *funit, rpt_type rtype)
static void toggle_instance_verbose (FILE *ofile, funit_inst *root, char *parent_inst)
static void toggle_funit_verbose (FILE *ofile, funit_link *head)
void toggle_report (FILE *ofile, bool verbose)
 Generates report output for toggle coverage.

Variables

db ** db_list
unsigned int curr_db
bool report_covered
bool report_instance
isuppl info_suppl
bool report_exclusions
bool flag_output_exclusion_ids

Detailed Description

Author:
Trevor Williams (phase1geo@gmail.com)
Date:
3/31/2002

Function Documentation

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.

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.

Parameters:
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 }

static bool toggle_display_funit_summary ( FILE *  ofile,
const char *  name,
const char *  fname,
unsigned int  hits01,
unsigned int  hits10,
unsigned int  total 
) [static]
Returns:
Returns TRUE if at least one bit was found to not be toggled; otherwise, returns FALSE.

Displays the toggle functional unit summary information to the given output file, calculating the miss and percentage information.

Parameters:
ofile Pointer to file to output summary information to
name Name of instance to output
fname Name of file containing instance to output
hits01 Number of bits that toggled from 0 -> 1
hits10 Number of bits that toggled from 1 -> 0
total Total number of bits in given instance

References calc_miss_percent(), PROFILE, and PROFILE_END.

Referenced by toggle_funit_summary(), and toggle_report().

00357   { PROFILE(TOGGLE_DISPLAY_FUNIT_SUMMARY);
00358 
00359   float percent01;  /* Percentage of bits that toggled from 0 to 1 */
00360   float percent10;  /* Percentage of bits that toggled from 1 to 0 */
00361   int   miss01;     /* Number of bits that did not toggle from 0 to 1 */
00362   int   miss10;     /* Number of bits that did not toggle from 1 to 0 */
00363 
00364   calc_miss_percent( hits01, total, &miss01, &percent01 );
00365   calc_miss_percent( hits10, total, &miss10, &percent10 );
00366 
00367   fprintf( ofile, "  %-20.20s    %-20.20s   %5u/%5d/%5u      %3.0f%%         %5u/%5d/%5u      %3.0f%%\n",
00368            name, fname, hits01, miss01, total, percent01, hits10, miss10, total, percent10 );
00369 
00370   PROFILE_END;
00371 
00372   return( (miss01 > 0) || (miss10 > 0) );
00373 
00374 }

static bool toggle_display_instance_summary ( FILE *  ofile,
char *  name,
int  hits01,
int  hits10,
int  total 
) [static]
Returns:
Returns TRUE if at least one bit was found to not be toggled; otherwise, returns FALSE.

Displays the toggle instance summary information to the given output file, calculating the miss and percentage information.

Parameters:
ofile Pointer to file to output summary information to
name Name of instance to output
hits01 Number of bits that toggled from 0 -> 1
hits10 Number of bits that toggled from 1 -> 0
total Total number of bits in given instance

References calc_miss_percent(), PROFILE, and PROFILE_END.

Referenced by toggle_instance_summary(), and toggle_report().

00258   { PROFILE(TOGGLE_DISPLAY_INSTANCE_SUMMARY);
00259 
00260   float percent01;  /* Percentage of bits toggled from 0 -> 1 */
00261   float percent10;  /* Percentage of bits toggled from 1 -> 0 */
00262   int   miss01;     /* Number of bits not toggled from 0 -> 1 */
00263   int   miss10;     /* Number of bits not toggled from 1 -> 0 */
00264 
00265   calc_miss_percent( hits01, total, &miss01, &percent01 );
00266   calc_miss_percent( hits10, total, &miss10, &percent10 );
00267 
00268   fprintf( ofile, "  %-43.43s    %5d/%5d/%5d      %3.0f%%         %5d/%5d/%5d      %3.0f%%\n",
00269            name, hits01, miss01, total, percent01, hits10, miss10, total, percent10 );
00270 
00271   PROFILE_END;
00272 
00273   return( (miss01 > 0) || (miss10 > 0) );
00274 
00275 }

static void toggle_display_verbose ( FILE *  ofile,
func_unit funit,
rpt_type  rtype 
) [static]

Displays the signals that did not achieve 100% toggle coverage to standard output from the specified signal list.

Parameters:
ofile Pointer to file to output results to
funit Pointer to current named functional unit
rtype Specifies the type of output to generate

References db_gen_exclusion_id(), db_get_exclusion_id_size(), exclude_find_exclude_reason(), ssuppl_u::excluded, FALSE, flag_output_exclusion_ids, free_safe, func_iter_dealloc(), func_iter_get_next_signal(), func_iter_init(), gen_char_string(), vsignal_s::id, ssuppl_u::mba, vsignal_s::name, ssuppl_u::part, PROFILE, PROFILE_END, exclude_reason_s::reason, report_output_exclusion_reason(), RPT_TYPE_EXCL, RPT_TYPE_HIT, RPT_TYPE_MISS, scope_gen_printable(), 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, vector_s::ul, vector_s::value, vsignal_s::value, vector_display_toggle01_ulong(), vector_display_toggle10_ulong(), vector_toggle_count(), and vector_s::width.

Referenced by toggle_funit_verbose(), and toggle_instance_verbose().

00432   { PROFILE(TOGGLE_DISPLAY_VERBOSE);
00433 
00434   func_iter    fi;        /* Functional unit iterator */
00435   vsignal*     sig;       /* Pointer to current signal being evaluated */
00436   unsigned int hit01;     /* Number of bits that toggled from 0 to 1 */
00437   unsigned int hit10;     /* Number of bits that toggled from 1 to 0 */
00438   char*        pname;     /* Printable version of signal name */
00439   unsigned int eid_size;  /* String length of exclusion ID */
00440 
00441   switch( rtype ) {
00442     case RPT_TYPE_HIT  :  fprintf( ofile, "    Signals getting 100%% toggle coverage\n\n" );      break;
00443     case RPT_TYPE_MISS :  fprintf( ofile, "    Signals not getting 100%% toggle coverage\n\n" );  break;
00444     case RPT_TYPE_EXCL :  fprintf( ofile, "    Signals excluded from toggle coverage\n\n" );      break;
00445   }
00446 
00447   if( flag_output_exclusion_ids && (rtype != RPT_TYPE_HIT) ) { 
00448     eid_size = db_get_exclusion_id_size();
00449   }
00450 
00451   if( rtype != RPT_TYPE_HIT ) {
00452     if( flag_output_exclusion_ids ) {
00453       char tmp[30];
00454       gen_char_string( tmp, ' ', (eid_size - 3) );
00455       fprintf( ofile, "      EID%s   Signal                    Toggle\n", tmp );
00456     } else {
00457       fprintf( ofile, "      Signal                    Toggle\n" );
00458     }
00459   }
00460 
00461   fprintf( ofile, "      ---------------------------------------------------------------------------------------------------------\n" );
00462 
00463   func_iter_init( &fi, funit, FALSE, TRUE );
00464 
00465   while( (sig = func_iter_get_next_signal( &fi )) != NULL ) {
00466 
00467     hit01 = 0;
00468     hit10 = 0;
00469 
00470     /* Get printable version of the signal name */
00471     pname = scope_gen_printable( sig->name );
00472 
00473     if( (sig->suppl.part.type != SSUPPL_TYPE_PARAM)          &&
00474         (sig->suppl.part.type != SSUPPL_TYPE_PARAM_REAL)     &&
00475         (sig->suppl.part.type != SSUPPL_TYPE_ENUM)           &&
00476         (sig->suppl.part.type != SSUPPL_TYPE_MEM)            &&
00477         (sig->suppl.part.type != SSUPPL_TYPE_DECL_REAL)      &&
00478         (sig->suppl.part.type != SSUPPL_TYPE_DECL_SREAL)     &&
00479         (sig->suppl.part.type != SSUPPL_TYPE_IMPLICIT_REAL)  &&
00480         (sig->suppl.part.type != SSUPPL_TYPE_IMPLICIT_SREAL) &&
00481         (sig->suppl.part.mba == 0) ) {
00482 
00483       if( ((sig->suppl.part.excluded == 0) && (rtype != RPT_TYPE_EXCL)) ||
00484           ((sig->suppl.part.excluded == 1) && (rtype == RPT_TYPE_EXCL)) ) {
00485 
00486         vector_toggle_count( sig->value, &hit01, &hit10 );
00487 
00488         if( rtype == RPT_TYPE_HIT ) {
00489 
00490           if( (hit01 == sig->value->width) && (hit10 == sig->value->width) ) {
00491         
00492             fprintf( ofile, "      %-24s\n", pname );
00493 
00494           }
00495 
00496         } else {
00497 
00498           if( (((hit01 < sig->value->width) || (hit10 < sig->value->width)) && (rtype == RPT_TYPE_MISS)) ||
00499               ((sig->suppl.part.excluded == 1) && (rtype == RPT_TYPE_EXCL)) ) {
00500 
00501             exclude_reason* er;
00502 
00503             if( flag_output_exclusion_ids ) {
00504               char tmp[30];
00505               fprintf( ofile, "      (%s)  %-24s  0->1: ", db_gen_exclusion_id( 'T', sig->id ), pname );
00506               vector_display_toggle01_ulong( sig->value->value.ul, sig->value->width, ofile );      
00507               gen_char_string( tmp, ' ', (eid_size - 1) );
00508               fprintf( ofile, "\n       %s   ......................... 1->0: ", tmp );
00509               vector_display_toggle10_ulong( sig->value->value.ul, sig->value->width, ofile );      
00510               fprintf( ofile, " ...\n" );
00511               if( (rtype == RPT_TYPE_EXCL) && ((er = exclude_find_exclude_reason( 'T', sig->id, funit )) != NULL) ) {
00512                 report_output_exclusion_reason( ofile, (12 + (eid_size - 1)), er->reason, TRUE );
00513               }
00514             } else {
00515               fprintf( ofile, "      %-24s  0->1: ", pname );
00516               vector_display_toggle01_ulong( sig->value->value.ul, sig->value->width, ofile );      
00517               fprintf( ofile, "\n      ......................... 1->0: " );
00518               vector_display_toggle10_ulong( sig->value->value.ul, sig->value->width, ofile );      
00519               fprintf( ofile, " ...\n" );
00520               if( (rtype == RPT_TYPE_EXCL) && ((er = exclude_find_exclude_reason( 'T', sig->id, funit )) != NULL) ) {
00521                 report_output_exclusion_reason( ofile, 8, er->reason, TRUE );
00522               }
00523             }
00524 
00525           }
00526 
00527         }
00528 
00529       }
00530 
00531     }
00532 
00533     free_safe( pname, (strlen( pname ) + 1) );
00534 
00535   }
00536 
00537   func_iter_dealloc( &fi );
00538 
00539   fprintf( ofile, "\n" );
00540 
00541   PROFILE_END;
00542 
00543 }

static bool toggle_funit_summary ( FILE *  ofile,
funit_link head,
unsigned int *  hits01,
unsigned int *  hits10,
unsigned int *  total 
) [static]
Returns:
Returns TRUE if any bits were found to be untoggled; otherwise, returns FALSE.

Iterates through the functional unit list displaying the toggle coverage for each functional unit.

Parameters:
ofile Pointer to file to display coverage results to
head Pointer to head of functional unit list to parse
hits01 Pointer to accumulated hit count for toggles 0 -> 1
hits10 Pointer to accumulated hit count for toggles 1 -> 0
total Pointer to accumulated total of bits

References isuppl_u::assert_ovl, FALSE, func_unit_s::filename, free_safe, funit_link_s::funit, funit_flatten_name(), funit_is_unnamed(), get_basename(), funit_link_s::next, obf_file, ovl_is_assertion_module(), isuppl_u::part, PROFILE, PROFILE_END, scope_gen_printable(), statistic_s::show, func_unit_s::stat, statistic_s::tog01_hit, statistic_s::tog10_hit, statistic_s::tog_total, and toggle_display_funit_summary().

Referenced by toggle_report().

00388   { PROFILE(TOGGLE_FUNIT_SUMMARY);
00389 
00390   bool  miss_found = FALSE;  /* Set to TRUE if missing toggles were found */
00391   char* pname;               /* Printable version of the functional unit name */
00392 
00393   while( head != NULL ) {
00394 
00395     /* If this is an assertion module, don't output any further */
00396     if( head->funit->stat->show && !funit_is_unnamed( head->funit ) &&
00397         ((info_suppl.part.assert_ovl == 0) || !ovl_is_assertion_module( head->funit )) ) {
00398 
00399       /* Get printable version of functional unit name */
00400       pname = scope_gen_printable( funit_flatten_name( head->funit ) );
00401 
00402       miss_found |= toggle_display_funit_summary( ofile, pname, get_basename( obf_file( head->funit->filename ) ),
00403                                                   head->funit->stat->tog01_hit, head->funit->stat->tog10_hit, head->funit->stat->tog_total );
00404 
00405       free_safe( pname, (strlen( pname ) + 1) );
00406 
00407       /* Update accumulated information */
00408       *hits01 += head->funit->stat->tog01_hit;
00409       *hits10 += head->funit->stat->tog10_hit;
00410       *total  += head->funit->stat->tog_total;
00411 
00412     }
00413 
00414     head = head->next;
00415 
00416   }
00417 
00418   PROFILE_END;
00419 
00420   return( miss_found );
00421 
00422 }

static void toggle_funit_verbose ( FILE *  ofile,
funit_link head 
) [static]
Parameters:
ofile Pointer to file to display coverage results to.
head Pointer to head of functional unit list to parse.

Displays the verbose toggle coverage results to the specified output stream on a functional unit basis (combining functional units that are instantiated multiple times). The verbose toggle coverage includes the signal names and their bits that did not receive 100% toggle coverage during simulation.

Parameters:
ofile Pointer to file to display coverage results to
head Pointer to head of functional unit list to parse

References func_unit_s::filename, funit_link_s::funit, FUNIT_AFUNCTION, FUNIT_ANAMED_BLOCK, FUNIT_ATASK, funit_flatten_name(), FUNIT_FUNCTION, funit_is_unnamed(), FUNIT_MODULE, FUNIT_NAMED_BLOCK, FUNIT_TASK, funit_link_s::next, obf_file, obf_funit, PROFILE, PROFILE_END, report_covered, report_exclusions, RPT_TYPE_EXCL, RPT_TYPE_HIT, RPT_TYPE_MISS, func_unit_s::stat, statistic_s::tog01_hit, statistic_s::tog10_hit, statistic_s::tog_cov_found, statistic_s::tog_excluded, statistic_s::tog_total, toggle_display_verbose(), and func_unit_s::type.

Referenced by toggle_report().

00630   { PROFILE(TOGGLE_FUNIT_VERBOSE);
00631 
00632   while( head != NULL ) {
00633 
00634     if( !funit_is_unnamed( head->funit ) &&
00635         ((!report_covered && ((head->funit->stat->tog01_hit < head->funit->stat->tog_total) || (head->funit->stat->tog10_hit < head->funit->stat->tog_total))) ||
00636          ( report_covered && head->funit->stat->tog_cov_found) ||
00637          (report_exclusions && (head->funit->stat->tog_excluded > 0))) ) {
00638 
00639       fprintf( ofile, "\n" );
00640       switch( head->funit->type ) {
00641         case FUNIT_MODULE       :  fprintf( ofile, "    Module: " );       break;
00642         case FUNIT_ANAMED_BLOCK :
00643         case FUNIT_NAMED_BLOCK  :  fprintf( ofile, "    Named Block: " );  break;
00644         case FUNIT_AFUNCTION    :
00645         case FUNIT_FUNCTION     :  fprintf( ofile, "    Function: " );     break;
00646         case FUNIT_ATASK        :
00647         case FUNIT_TASK         :  fprintf( ofile, "    Task: " );         break;
00648         default                 :  fprintf( ofile, "    UNKNOWN: " );      break;
00649       }
00650       fprintf( ofile, "%s, File: %s\n", obf_funit( funit_flatten_name( head->funit ) ), obf_file( head->funit->filename ) );
00651       fprintf( ofile, "    -------------------------------------------------------------------------------------------------------------\n" );
00652 
00653       if( (!report_covered && ((head->funit->stat->tog01_hit < head->funit->stat->tog_total) || (head->funit->stat->tog10_hit < head->funit->stat->tog_total))) ||
00654           ( report_covered && head->funit->stat->tog_cov_found) ) {
00655         toggle_display_verbose( ofile, head->funit, (report_covered ? RPT_TYPE_HIT : RPT_TYPE_MISS) );
00656       }
00657       if( report_exclusions && (head->funit->stat->tog_excluded > 0) ) {
00658         toggle_display_verbose( ofile, head->funit, RPT_TYPE_EXCL );
00659       }
00660 
00661     }
00662 
00663     head = head->next;
00664 
00665   }
00666 
00667   PROFILE_END;
00668 
00669 }

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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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 }

static bool toggle_instance_summary ( FILE *  ofile,
funit_inst root,
char *  parent_inst,
unsigned int *  hits01,
unsigned int *  hits10,
unsigned int *  total 
) [static]
Returns:
Returns TRUE if any bits were found to be not toggled; otherwise, returns FALSE.

Displays the toggle instance summarization to the specified file. Recursively iterates through functional unit instance tree, outputting the toggle information that is found at that instance.

Parameters:
ofile File to output coverage information to
root Instance node in the functional unit instance tree being evaluated
parent_inst Name of parent instance
hits01 Pointer to number of 0 -> 1 toggles that were hit in the given instance tree
hits10 Pointer to number of 1 -> 0 toggles that were hit in the given instance tree
total Pointer to total number of bits that could be toggled in the given instance tree

References isuppl_u::assert_ovl, funit_inst_s::child_head, db_is_unnamed_scope(), FALSE, free_safe, funit_inst_s::funit, funit_is_unnamed(), funit_inst_s::name, funit_inst_s::name_diff, funit_inst_s::next, ovl_is_assertion_module(), isuppl_u::part, PROFILE, PROFILE_END, scope_gen_printable(), statistic_s::show, funit_inst_s::stat, funit_inst_s::suppl, statistic_s::tog01_hit, statistic_s::tog10_hit, statistic_s::tog_total, and toggle_display_instance_summary().

Referenced by toggle_report().

00291   { PROFILE(TOGGLE_INSTANCE_SUMMARY);
00292 
00293   funit_inst* curr;                /* Pointer to current child functional unit instance of this node */
00294   char        tmpname[4096];       /* Temporary name holder for instance */
00295   char*       pname;               /* Printable version of instance name */
00296   bool        miss_found = FALSE;  /* Specifies if at least one bit was not fully toggled */
00297 
00298   assert( root != NULL );
00299   assert( root->stat != NULL );
00300 
00301   /* Get printable version of this instance */
00302   pname = scope_gen_printable( root->name );
00303 
00304   if( db_is_unnamed_scope( pname ) || root->suppl.name_diff ) {
00305     strcpy( tmpname, parent_inst );
00306   } else if( strcmp( parent_inst, "*" ) == 0 ) {
00307     strcpy( tmpname, pname );
00308   } else {
00309     unsigned int rv = snprintf( tmpname, 4096, "%s.%s", parent_inst, pname );
00310     assert( rv < 4096 );
00311   }
00312 
00313   free_safe( pname, (strlen( pname ) + 1) );
00314 
00315   if( (root->funit != NULL) && root->stat->show && !funit_is_unnamed( root->funit ) &&
00316       ((info_suppl.part.assert_ovl == 0) || !ovl_is_assertion_module( root->funit )) ) {
00317 
00318     miss_found |= toggle_display_instance_summary( ofile, tmpname, root->stat->tog01_hit, root->stat->tog10_hit, root->stat->tog_total );
00319 
00320     /* Update accumulated information */
00321     *hits01 += root->stat->tog01_hit;
00322     *hits10 += root->stat->tog10_hit;
00323     *total  += root->stat->tog_total;
00324 
00325   }
00326 
00327   /* If this is an assertion module, don't output any further */
00328   if( (info_suppl.part.assert_ovl == 0) || !ovl_is_assertion_module( root->funit ) ) {
00329 
00330     curr = root->child_head;
00331     while( curr != NULL ) {
00332       miss_found |= toggle_instance_summary( ofile, curr, tmpname, hits01, hits10, total );
00333       curr = curr->next;
00334     }
00335 
00336   }
00337 
00338   PROFILE_END;
00339 
00340   return( miss_found );
00341 
00342 }

static void toggle_instance_verbose ( FILE *  ofile,
funit_inst root,
char *  parent_inst 
) [static]

Displays the verbose toggle coverage results to the specified output stream on an instance basis. The verbose toggle coverage includes the signal names and their bits that did not receive 100% toggle coverage during simulation.

Parameters:
ofile Pointer to file to display coverage results to
root Pointer to root of instance functional unit tree to parse
parent_inst Name of parent instance

References funit_inst_s::child_head, db_is_unnamed_scope(), func_unit_s::filename, free_safe, funit_inst_s::funit, FUNIT_AFUNCTION, FUNIT_ANAMED_BLOCK, FUNIT_ATASK, funit_flatten_name(), FUNIT_FUNCTION, funit_is_unnamed(), FUNIT_MODULE, FUNIT_NAMED_BLOCK, FUNIT_TASK, funit_inst_s::name, funit_inst_s::name_diff, funit_inst_s::next, obf_file, PROFILE, PROFILE_END, report_covered, report_exclusions, RPT_TYPE_EXCL, RPT_TYPE_HIT, RPT_TYPE_MISS, scope_gen_printable(), funit_inst_s::stat, funit_inst_s::suppl, statistic_s::tog01_hit, statistic_s::tog10_hit, statistic_s::tog_cov_found, statistic_s::tog_excluded, statistic_s::tog_total, toggle_display_verbose(), and func_unit_s::type.

Referenced by toggle_report().

00554   { PROFILE(TOGGLE_INSTANCE_VERBOSE);
00555 
00556   funit_inst* curr_inst;      /* Pointer to current instance being evaluated */
00557   char        tmpname[4096];  /* Temporary name holder of instance */
00558   char*       pname;          /* Printable version of the name */
00559 
00560   assert( root != NULL );
00561 
00562   /* Get printable version of the signal */
00563   pname = scope_gen_printable( root->name );
00564 
00565   if( db_is_unnamed_scope( pname ) || root->suppl.name_diff ) {
00566     strcpy( tmpname, parent_inst );
00567   } else if( strcmp( parent_inst, "*" ) == 0 ) {
00568     strcpy( tmpname, pname );
00569   } else {
00570     unsigned int rv = snprintf( tmpname, 4096, "%s.%s", parent_inst, pname );
00571     assert( rv < 4096 );
00572   }
00573 
00574   free_safe( pname, (strlen( pname ) + 1) );
00575 
00576   if( (root->funit != NULL) && !funit_is_unnamed( root->funit ) &&
00577       ((!report_covered && ((root->stat->tog01_hit < root->stat->tog_total) || (root->stat->tog10_hit < root->stat->tog_total))) ||
00578        ( report_covered && root->stat->tog_cov_found) ||
00579        (report_exclusions && (root->stat->tog_excluded > 0))) ) {
00580 
00581     pname = scope_gen_printable( funit_flatten_name( root->funit ) );
00582 
00583     fprintf( ofile, "\n" );
00584     switch( root->funit->type ) {
00585       case FUNIT_MODULE       :  fprintf( ofile, "    Module: " );       break;
00586       case FUNIT_ANAMED_BLOCK :
00587       case FUNIT_NAMED_BLOCK  :  fprintf( ofile, "    Named Block: " );  break;
00588       case FUNIT_AFUNCTION    :
00589       case FUNIT_FUNCTION     :  fprintf( ofile, "    Function: " );     break;
00590       case FUNIT_ATASK        :
00591       case FUNIT_TASK         :  fprintf( ofile, "    Task: " );         break;
00592       default                 :  fprintf( ofile, "    UNKNOWN: " );      break;
00593     }
00594     fprintf( ofile, "%s, File: %s, Instance: %s\n", pname, obf_file( root->funit->filename ), tmpname );
00595     fprintf( ofile, "    -------------------------------------------------------------------------------------------------------------\n" );
00596     free_safe( pname, (strlen( pname ) + 1) );
00597 
00598     if( (!report_covered && ((root->stat->tog01_hit < root->stat->tog_total) || (root->stat->tog10_hit < root->stat->tog_total))) ||
00599         ( report_covered && root->stat->tog_cov_found) ) {
00600       toggle_display_verbose( ofile, root->funit, (report_covered ? RPT_TYPE_HIT : RPT_TYPE_MISS) );
00601     }
00602     if( report_exclusions && (root->stat->tog_excluded > 0) ) {
00603       toggle_display_verbose( ofile, root->funit, RPT_TYPE_EXCL );
00604     }
00605 
00606   }
00607 
00608   curr_inst = root->child_head;
00609   while( curr_inst != NULL ) {
00610     toggle_instance_verbose( ofile, curr_inst, tmpname );
00611     curr_inst = curr_inst->next;
00612   }
00613 
00614   PROFILE_END;
00615 
00616 }

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.

Parameters:
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 }


Variable Documentation

unsigned int curr_db

Index of current database in db_list array that is being handled.

Array of database pointers storing all currently loaded databases.

Outputs the exclusion ID for an output coverage point. The exclusion ID can be used by the exclude command for excluding/including coverage points.

Informational line for the CDD file.

If set to a boolean value of TRUE, displays covered logic for a particular CDD file. By default, Covered will display uncovered logic. Must be used in conjunction with the -d v|d (verbose output) option.

If set to a boolean value of TRUE, displays excluded coverage points for a particular CDD file. By default, Covered will not display excluded coverage points. This can be useful when used in conjunction with the -x option for including excluded coverage points. Must be used in conjunction with the -d v|d (verbose output) option.

If set to a boolean value of TRUE, provides a coverage information for individual functional unit instances. If set to a value of FALSE, reports coverage information on a functional unit basis, merging results from all instances of same functional unit.

Generated on Sun Nov 21 00:55:41 2010 for Covered by  doxygen 1.6.3