Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

/Users/trevorw/projects/release/covered-0.7.4/src/rank.c File Reference


Detailed Description

Author:
Trevor Williams (phase1geo@gmail.com)
Date:
6/28/2008

#include <stdio.h>
#include <assert.h>
#include "comb.h"
#include "defines.h"
#include "expr.h"
#include "fsm.h"
#include "func_iter.h"
#include "link.h"
#include "profiler.h"
#include "rank.h"
#include "util.h"
#include "vsignal.h"

Functions

comp_cdd_covrank_create_comp_cdd_cov (const char *cdd_name, bool required, uint64 timesteps)
void rank_dealloc_comp_cdd_cov (comp_cdd_cov *comp_cov)
void rank_usage ()
bool rank_parse_args (int argc, int last_arg, const char **argv)
void rank_check_index (unsigned type, uint64 index, int line)
void rank_gather_signal_cov (vsignal *sig, comp_cdd_cov *comp_cov)
void rank_gather_comb_cov (expression *exp, comp_cdd_cov *comp_cov)
void rank_gather_expression_cov (expression *exp, unsigned int exclude, comp_cdd_cov *comp_cov)
void rank_gather_fsm_cov (fsm_table *table, comp_cdd_cov *comp_cov)
void rank_calc_num_cps (funit_inst *inst, uint64 nums[CP_TYPE_NUM])
void rank_gather_comp_cdd_cov (funit_inst *inst, comp_cdd_cov *comp_cov)
void rank_read_cdd (const char *cdd_name, bool required, bool first, comp_cdd_cov ***comp_cdds, unsigned int *comp_cdd_num)
void rank_selected_cdd_cov (comp_cdd_cov **comp_cdds, unsigned int comp_cdd_num, uint16 *ranked_merged, uint16 *unranked_merged, unsigned int next_cdd, unsigned int selected_cdd)
void rank_perform_weighted_selection (comp_cdd_cov **comp_cdds, unsigned int comp_cdd_num, uint16 *ranked_merged, uint16 *unranked_merged, unsigned int next_cdd, unsigned int *cdds_ranked)
void rank_perform_greedy_sort (comp_cdd_cov **comp_cdds, unsigned int comp_cdd_num, uint16 *ranked_merged, uint64 num_ranked)
uint64 rank_count_cps (uint16 *list, unsigned int list_size)
void rank_perform (comp_cdd_cov **comp_cdds, unsigned int comp_cdd_num)
void rank_output (comp_cdd_cov **comp_cdds, unsigned int comp_cdd_num)
void command_rank (int argc, int last_arg, const char **argv)
 Parses command-line for rank options and performs rank command.


Variables

char user_msg [USER_MSG_LENGTH]
const exp_info exp_op_info [EXP_OP_NUM]
db ** db_list
uint64 num_timesteps
bool output_suppressed
bool debug_mode
int64 largest_malloc_size
bool report_line
bool report_toggle
bool report_combination
bool report_fsm
bool report_assertion
bool report_memory
bool allow_multi_expr
str_linkrank_in_head = NULL
str_linkrank_in_tail = NULL
char * rank_file = NULL
uint64 num_cps [CP_TYPE_NUM] = {0}
unsigned int cdd_type_weight [CP_TYPE_NUM] = {1,1,1,1,1,0}
bool cdd_type_set [CP_TYPE_NUM] = {0}
bool flag_names_only = FALSE
unsigned int cp_depth = 0
unsigned int longest_name_len = 0
bool rank_verbose = FALSE


Function Documentation

void command_rank int  argc,
int  last_arg,
const char **  argv
 

Parses command-line for rank options and performs rank command.

Performs merge command functionality.

Parameters:
argc  Number of arguments in command-line to parse
last_arg  Index of last parsed argument from list
argv  List of arguments from command-line to parse

01726   { PROFILE(COMMAND_RANK);
01727 
01728   int            i, j;
01729   unsigned int   rv;
01730   comp_cdd_cov** comp_cdds    = NULL;
01731   unsigned int   comp_cdd_num = 0;
01732   bool           error        = FALSE;
01733 
01734   /* Output header information */
01735   rv = snprintf( user_msg, USER_MSG_LENGTH, COVERED_HEADER );
01736   assert( rv < USER_MSG_LENGTH );
01737   print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01738 
01739   Try {
01740 
01741     unsigned int rv;
01742     bool         first  = TRUE;
01743     str_link*    strl;
01744     timer*       atimer = NULL;
01745 
01746     /* Parse score command-line */
01747     if( !rank_parse_args( argc, last_arg, argv ) ) {
01748 
01749       /* Make sure that all coverage points are accumulated */
01750       report_line        = TRUE;
01751       report_toggle      = TRUE;
01752       report_combination = TRUE;
01753       report_fsm         = TRUE;
01754       report_assertion   = TRUE;
01755       report_memory      = TRUE;
01756       allow_multi_expr   = FALSE;
01757 
01758       /* Start timer */
01759       if( rank_verbose ) {
01760         timer_clear( &atimer );
01761         timer_start( &atimer );
01762       }
01763 
01764       /* Read in databases to merge */
01765       strl = rank_in_head;
01766       while( strl != NULL ) {
01767         rv = snprintf( user_msg, USER_MSG_LENGTH, "Reading CDD file \"%s\"", strl->str );
01768         assert( rv < USER_MSG_LENGTH );
01769         print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01770         rv = fflush( stdout );
01771         assert( rv == 0 );
01772         rank_read_cdd( strl->str, (strl->suppl == 1), first, &comp_cdds, &comp_cdd_num );
01773         first = FALSE;
01774         strl  = strl->next;
01775       }
01776 
01777       if( rank_verbose ) {
01778         timer_stop( &atimer );
01779         rv = snprintf( user_msg, USER_MSG_LENGTH, "Completed reading in CDD files in %s", timer_to_string( atimer ) );
01780         assert( rv < USER_MSG_LENGTH );
01781         print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01782         free_safe( atimer, sizeof( timer ) );
01783       }
01784 
01785       /* Peaform the ranking algorithm */
01786       rank_perform( comp_cdds, comp_cdd_num );
01787 
01788       /* Output the results */
01789       rank_output( comp_cdds, comp_cdd_num );
01790 
01791       /*@-duplicatequals -formattype@*/
01792       rv = snprintf( user_msg, USER_MSG_LENGTH, "Dynamic memory allocated:   %llu bytes", largest_malloc_size );
01793       assert( rv < USER_MSG_LENGTH );
01794       /*@=duplicatequals =formattype@*/
01795       print_output( "", NORMAL, __FILE__, __LINE__ );
01796       print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01797       print_output( "", NORMAL, __FILE__, __LINE__ );
01798 
01799     }
01800 
01801   } Catch_anonymous {
01802     error = TRUE;
01803   }
01804 
01805   /* Deallocate other allocated variables */
01806   str_link_delete_list( rank_in_head );
01807 
01808   /* Deallocate the compressed CDD coverage structures */
01809   for( i=0; i<comp_cdd_num; i++ ) {
01810     rank_dealloc_comp_cdd_cov( comp_cdds[i] );
01811   }
01812   free_safe( comp_cdds, (sizeof( comp_cdd_cov* ) * comp_cdd_num) );
01813 
01814   free_safe( rank_file, (strlen( rank_file ) + 1) );
01815 
01816   if( error ) {
01817     Throw 0;
01818   }
01819 
01820   PROFILE_END;
01821 
01822 }

void rank_calc_num_cps funit_inst inst,
uint64  nums[CP_TYPE_NUM]
[static]
 

Recursively iterates through the instance tree, accumulating values for num_cps array.

Parameters:
inst  Pointer to instance tree to calculate num_cps array
nums  Array of coverage point numbers to populate

00966   { PROFILE(RANK_CALC_NUM_CPS);
00967 
00968   funit_inst* child;  /* Pointer to child instance */
00969 
00970   /* Iterate through children instances */
00971   child = inst->child_head;
00972   while( child != NULL ) {
00973     rank_calc_num_cps( child, nums );
00974     child = child->next;
00975   }
00976 
00977   /* Add totals to global num_cps array */
00978   nums[CP_TYPE_LINE]   += inst->stat->line_total;
00979   nums[CP_TYPE_TOGGLE] += (inst->stat->tog_total * 2);
00980   nums[CP_TYPE_MEM]    += (inst->stat->mem_ae_total * 2) + (inst->stat->mem_tog_total * 2);
00981   nums[CP_TYPE_LOGIC]  += inst->stat->comb_total;
00982   if( inst->stat->state_total > 0 ) {
00983     nums[CP_TYPE_FSM] += (unsigned int)inst->stat->state_total;
00984   }
00985   if( inst->stat->arc_total > 0 ) {
00986     nums[CP_TYPE_FSM] += (unsigned int)inst->stat->arc_total;
00987   }
00988   nums[CP_TYPE_ASSERT] += inst->stat->assert_total;
00989 
00990   PROFILE_END;
00991 
00992 }

void rank_check_index unsigned  type,
uint64  index,
int  line
[static]
 

Checks to make sure that index that will be used exceeds the maximum index (to eliminate memory overruns). Throws exception if the index that will be used violates this check.

Parameters:
type  Type of index that is being checked
index  Index value to check
line  Line number in source code that hit this error

00665   { PROFILE(RANK_CHECK_INDEX);
00666 
00667   if( index >= num_cps[type] ) {
00668     unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Last read in CDD file is incompatible with previously read in CDD files.  Exiting..." );
00669     print_output( user_msg, FATAL, __FILE__, line );
00670     Throw 0;
00671   }
00672 
00673   PROFILE_END;
00674 
00675 }

uint64 rank_count_cps uint16 list,
unsigned int  list_size
 

Returns:
Returns the number of coverage points hit in the given list.
Parameters:
list  List of cp counts
list_size  Number of elements in the list

01331   { PROFILE(RANK_COUNT_CPS);
01332 
01333   uint64       cps = 0;
01334   unsigned int i;
01335 
01336   for( i=0; i<list_size; i++ ) {
01337     cps += (list[i] > 0) ? 1 : 0;
01338   }
01339 
01340   PROFILE_END;
01341 
01342   return( cps );
01343 
01344 }

comp_cdd_cov* rank_create_comp_cdd_cov const char *  cdd_name,
bool  required,
uint64  timesteps
 

Returns:
Returns a pointer to a newly allocated and initialized compressed CDD coverage structure.
Parameters:
cdd_name  Name of CDD file that this structure was created from
required  Set to TRUE if this CDD is required to be ranked by the user
timesteps  Number of simulation timesteps that occurred in the CDD

00167   { PROFILE(RANK_CREATE_COMP_CDD_COV);
00168 
00169   comp_cdd_cov* comp_cov;
00170   unsigned int  i;
00171 
00172   /* Allocate and initialize */
00173   comp_cov             = (comp_cdd_cov*)malloc_safe( sizeof( comp_cdd_cov ) );
00174   comp_cov->cdd_name   = strdup_safe( cdd_name );
00175   comp_cov->timesteps  = timesteps;
00176   comp_cov->total_cps  = 0;
00177   comp_cov->unique_cps = 0;
00178   comp_cov->required   = required;
00179 
00180   /* Save longest name length */
00181   if( strlen( comp_cov->cdd_name ) > longest_name_len ) {
00182     longest_name_len = strlen( comp_cov->cdd_name );
00183   }
00184 
00185   for( i=0; i<CP_TYPE_NUM; i++ ) {
00186     comp_cov->cps_index[i] = 0;
00187     if( num_cps[i] > 0 ) {
00188       comp_cov->cps[i] = (ulong*)calloc_safe( (UL_DIV(num_cps[i]) + 1), sizeof( ulong ) );
00189     } else {
00190       comp_cov->cps[i] = NULL;
00191     }
00192   }
00193 
00194   PROFILE_END;
00195 
00196   return( comp_cov );
00197 
00198 }

void rank_dealloc_comp_cdd_cov comp_cdd_cov comp_cov  ) 
 

Deallocates the specified compressed CDD coverage structure.

Parameters:
comp_cov  Pointer to compressed CDD coverage structure to deallocate

00205   { PROFILE(RANK_DEALLOC_COMP_CDD_COV);
00206 
00207   if( comp_cov != NULL ) {
00208 
00209     unsigned int i;
00210 
00211     /* Deallocate name */
00212     free_safe( comp_cov->cdd_name, (strlen( comp_cov->cdd_name ) + 1) );
00213 
00214     /* Deallocate compressed coverage point information */
00215     for( i=0; i<CP_TYPE_NUM; i++ ) {
00216       free_safe( comp_cov->cps[i], (sizeof( ulong ) * (UL_DIV( num_cps[i] ) + 1)) );
00217     }
00218 
00219     /* Now deallocate ourselves */
00220     free_safe( comp_cov, sizeof( comp_cdd_cov ) );
00221 
00222   }
00223 
00224   PROFILE_END;
00225 
00226 }

void rank_gather_comb_cov expression exp,
comp_cdd_cov comp_cov
[static]
 

Recursively iterates through the given expression tree, gathering all combinational logic coverage information and populating the given compressed CDD coverage structure accordingly.

Parameters:
exp  Pointer to current expression to gather combinational logic coverage from
comp_cov  Pointer to compressed CDD coverage structure to populate

00796   { PROFILE(RANK_GATHER_COMB_COV);
00797 
00798   if( exp != NULL ) {
00799 
00800     /* Gather combination coverage information from children */
00801     rank_gather_comb_cov( exp->left,  comp_cov );
00802     rank_gather_comb_cov( exp->right, comp_cov );
00803 
00804     /* Calculate combinational logic coverage information */
00805     if( (EXPR_IS_MEASURABLE( exp ) == 1) && (ESUPPL_WAS_COMB_COUNTED( exp->suppl ) == 0) ) {
00806       
00807       /* Calculate current expression combination coverage */
00808       if( !expression_is_static_only( exp ) ) {
00809     
00810         uint64 index;
00811 
00812         if( EXPR_IS_COMB( exp ) == 1 ) {
00813           if( exp_op_info[exp->op].suppl.is_comb == AND_COMB ) {
00814             index = comp_cov->cps_index[CP_TYPE_LOGIC]++;
00815             rank_check_index( CP_TYPE_LOGIC, index, __LINE__ );
00816             comp_cov->cps[CP_TYPE_LOGIC][UL_DIV(index)] |= (ulong)ESUPPL_WAS_FALSE( exp->left->suppl ) << UL_MOD(index);
00817             index = comp_cov->cps_index[CP_TYPE_LOGIC]++;
00818             rank_check_index( CP_TYPE_LOGIC, index, __LINE__ );
00819             comp_cov->cps[CP_TYPE_LOGIC][UL_DIV(index)] |= (ulong)ESUPPL_WAS_FALSE( exp->right->suppl ) << UL_MOD(index);
00820             index = comp_cov->cps_index[CP_TYPE_LOGIC]++;
00821             rank_check_index( CP_TYPE_LOGIC, index, __LINE__ );
00822             comp_cov->cps[CP_TYPE_LOGIC][UL_DIV(index)] |= (ulong)exp->suppl.part.eval_11 << UL_MOD(index);
00823           } else if( exp_op_info[exp->op].suppl.is_comb == OR_COMB ) {
00824             index = comp_cov->cps_index[CP_TYPE_LOGIC]++;
00825             rank_check_index( CP_TYPE_LOGIC, index, __LINE__ );
00826             comp_cov->cps[CP_TYPE_LOGIC][UL_DIV(index)] |= (ulong)ESUPPL_WAS_TRUE( exp->left->suppl ) << UL_MOD(index);
00827             index = comp_cov->cps_index[CP_TYPE_LOGIC]++;
00828             rank_check_index( CP_TYPE_LOGIC, index, __LINE__ );
00829             comp_cov->cps[CP_TYPE_LOGIC][UL_DIV(index)] |= (ulong)ESUPPL_WAS_TRUE( exp->right->suppl ) << UL_MOD(index);
00830             index = comp_cov->cps_index[CP_TYPE_LOGIC]++;
00831             rank_check_index( CP_TYPE_LOGIC, index, __LINE__ );
00832             comp_cov->cps[CP_TYPE_LOGIC][UL_DIV(index)] |= (ulong)exp->suppl.part.eval_00 << UL_MOD(index);
00833           } else {
00834             index = comp_cov->cps_index[CP_TYPE_LOGIC]++;
00835             rank_check_index( CP_TYPE_LOGIC, index, __LINE__ );
00836             comp_cov->cps[CP_TYPE_LOGIC][UL_DIV(index)] |= (ulong)exp->suppl.part.eval_00 << UL_MOD(index);
00837             index = comp_cov->cps_index[CP_TYPE_LOGIC]++;
00838             rank_check_index( CP_TYPE_LOGIC, index, __LINE__ );
00839             comp_cov->cps[CP_TYPE_LOGIC][UL_DIV(index)] |= (ulong)exp->suppl.part.eval_01 << UL_MOD(index);
00840             index = comp_cov->cps_index[CP_TYPE_LOGIC]++;
00841             rank_check_index( CP_TYPE_LOGIC, index, __LINE__ );
00842             comp_cov->cps[CP_TYPE_LOGIC][UL_DIV(index)] |= (ulong)exp->suppl.part.eval_10 << UL_MOD(index);
00843             index = comp_cov->cps_index[CP_TYPE_LOGIC]++;
00844             rank_check_index( CP_TYPE_LOGIC, index, __LINE__ );
00845             comp_cov->cps[CP_TYPE_LOGIC][UL_DIV(index)] |= (ulong)exp->suppl.part.eval_11 << UL_MOD(index);
00846           }
00847         } else if( EXPR_IS_EVENT( exp ) == 1 ) {
00848           index = comp_cov->cps_index[CP_TYPE_LOGIC]++;
00849           rank_check_index( CP_TYPE_LOGIC, index, __LINE__ );
00850           comp_cov->cps[CP_TYPE_LOGIC][UL_DIV(index)] |= (ulong)ESUPPL_WAS_TRUE( exp->suppl ) << UL_MOD(index);
00851         } else {
00852           index = comp_cov->cps_index[CP_TYPE_LOGIC]++;
00853           rank_check_index( CP_TYPE_LOGIC, index, __LINE__ );
00854           comp_cov->cps[CP_TYPE_LOGIC][UL_DIV(index)] |= (ulong)ESUPPL_WAS_TRUE( exp->suppl ) << UL_MOD(index);
00855           index = comp_cov->cps_index[CP_TYPE_LOGIC]++;
00856           rank_check_index( CP_TYPE_LOGIC, index, __LINE__ );
00857           comp_cov->cps[CP_TYPE_LOGIC][UL_DIV(index)] |= (ulong)ESUPPL_WAS_FALSE( exp->suppl ) << UL_MOD(index);
00858         }
00859   
00860       }
00861   
00862     }
00863 
00864     /* Set the counted bit */
00865     exp->suppl.part.comb_cntd = 1;
00866 
00867   }
00868 
00869   PROFILE_END;
00870 
00871 }

void rank_gather_comp_cdd_cov funit_inst inst,
comp_cdd_cov comp_cov
[static]
 

Gathers all coverage point information from the given functional unit instance and populates the specified compressed CDD coverage structure accordingly.

01001   { PROFILE(RANK_GATHER_COMP_CDD_COV);
01002 
01003   sig_link*   sigl;   /* Pointer to signal link */
01004   fsm_link*   fsml;   /* Pointer to FSM link */
01005   funit_inst* child;  /* Pointer to current child instance */
01006 
01007   /* Don't gather information for placeholder instances */
01008   if( inst->funit != NULL ) {
01009 
01010     /* Gather coverage information from expressions */
01011     if( !funit_is_unnamed( inst->funit ) ) {
01012       func_iter  fi;
01013       statement* stmt;
01014 
01015       /* First, clear the comb_cntd bits in all of the expressions */
01016       func_iter_init( &fi, inst->funit, TRUE, FALSE );
01017       while( (stmt = func_iter_get_next_statement( &fi )) != NULL ) {
01018         combination_reset_counted_expr_tree( stmt->exp );
01019       }
01020       func_iter_dealloc( &fi );
01021 
01022       /* Then populate the comp_cov structure, accordingly */
01023       func_iter_init( &fi, inst->funit, TRUE, FALSE );
01024       while( (stmt = func_iter_get_next_statement( &fi )) != NULL ) {
01025         rank_gather_expression_cov( stmt->exp, stmt->suppl.part.excluded, comp_cov );
01026       }
01027       func_iter_dealloc( &fi );
01028     }
01029 
01030     /* Gather coverage information from signals */
01031     sigl = inst->funit->sig_head;
01032     while( sigl != NULL ) {
01033       rank_gather_signal_cov( sigl->sig, comp_cov );
01034       sigl = sigl->next;
01035     }
01036 
01037     /* Gather coverage information from FSMs */
01038     fsml = inst->funit->fsm_head;
01039     while( fsml != NULL ) {
01040       rank_gather_fsm_cov( fsml->table->table, comp_cov );
01041       fsml = fsml->next;
01042     }
01043 
01044   }
01045 
01046   /* Gather coverage information from children */
01047   child = inst->child_head;
01048   while( child != NULL ) {
01049     rank_gather_comp_cdd_cov( child, comp_cov );
01050     child = child->next;
01051   }
01052 
01053   PROFILE_END;
01054 
01055 }

void rank_gather_expression_cov expression exp,
unsigned int  exclude,
comp_cdd_cov comp_cov
[static]
 

Gathers line and combinational logic coverage point information from the given expression and populates the specified compressed CDD coverage structure accordingly.

Parameters:
exp  Pointer to expression to gather coverage information from
exclude  Specifies whether line coverage information should be excluded
comp_cov  Pointer to compressed CDD coverage structure to populate

00881   { PROFILE(RANK_GATHER_EXPRESSION_COV);
00882 
00883   /* Calculate line coverage information (NOTE:  we currently ignore the excluded status of the line) */
00884   if( (exp->suppl.part.root == 1) &&
00885       (exp->op != EXP_OP_DELAY)   &&
00886       (exp->op != EXP_OP_CASE)    &&
00887       (exp->op != EXP_OP_CASEX)   &&
00888       (exp->op != EXP_OP_CASEZ)   &&
00889       (exp->op != EXP_OP_DEFAULT) &&
00890       (exp->op != EXP_OP_NB_CALL) &&
00891       (exp->op != EXP_OP_FORK)    &&
00892       (exp->op != EXP_OP_JOIN)    &&
00893       (exp->op != EXP_OP_NOOP)    &&
00894       (exp->line != 0) ) {
00895     uint64 index = comp_cov->cps_index[CP_TYPE_LINE]++;
00896     rank_check_index( CP_TYPE_LINE, index, __LINE__ );
00897     if( (exp->exec_num > 0) || exclude ) {
00898       comp_cov->cps[CP_TYPE_LINE][UL_DIV(index)] |= (ulong)0x1 << UL_MOD(index);
00899     }
00900   }
00901 
00902   /* Calculate combinational logic coverage information */
00903   rank_gather_comb_cov( exp, comp_cov );
00904 
00905   PROFILE_END;
00906 
00907 }

void rank_gather_fsm_cov fsm_table table,
comp_cdd_cov comp_cov
[static]
 

Gathers the FSM coverage points from the given FSM and populates the compressed CDD coverage structure accordingly.

Parameters:
table  Pointer to FSM table to gather coverage information from
comp_cov  Pointer to compressed CDD coverage structure to populate

00916   { PROFILE(RANK_GATHER_FSM_COV);
00917 
00918   /* We can only create a compressed version of FSM coverage information if it is known */
00919   if( table->suppl.part.known == 0 ) {
00920 
00921     int*         state_hits = (int*)malloc_safe( sizeof( int ) * table->num_fr_states );
00922     unsigned int i;
00923 
00924     /* Initialize state_hits array */
00925     for( i=0; i<table->num_fr_states; i++ ) {
00926       state_hits[i] = 0;
00927     }
00928 
00929     /* Iterate through arc transition array and count unique hits */
00930     for( i=0; i<table->num_arcs; i++ ) {
00931       uint64 index;
00932       if( (table->arcs[i]->suppl.part.hit || table->arcs[i]->suppl.part.excluded) ) {
00933         if( state_hits[table->arcs[i]->from]++ == 0 ) {
00934           index = comp_cov->cps_index[CP_TYPE_FSM]++;
00935           rank_check_index( CP_TYPE_FSM, index, __LINE__ );
00936           comp_cov->cps[CP_TYPE_FSM][UL_DIV(index)] |= (ulong)0x1 << UL_MOD(index);
00937         }
00938         index = comp_cov->cps_index[CP_TYPE_FSM]++;
00939         rank_check_index( CP_TYPE_FSM, index, __LINE__ );
00940         comp_cov->cps[CP_TYPE_FSM][UL_DIV(index)] |= (ulong)0x1 << UL_MOD(index);
00941       } else {
00942         if( state_hits[table->arcs[i]->from]++ == 0 ) {
00943           index = comp_cov->cps_index[CP_TYPE_FSM]++;
00944           rank_check_index( CP_TYPE_FSM, index, __LINE__ );
00945         }
00946         index = comp_cov->cps_index[CP_TYPE_FSM]++;
00947         rank_check_index( CP_TYPE_FSM, index, __LINE__ );
00948       }
00949     }
00950 
00951     /* Deallocate state_hits array */
00952     free_safe( state_hits, (sizeof( int ) * table->num_fr_states) );
00953 
00954   }
00955 
00956   PROFILE_END;
00957 
00958 }

void rank_gather_signal_cov vsignal sig,
comp_cdd_cov comp_cov
[static]
 

Gathers all coverage point information from the given signal and populates the comp_cov structure accordingly.

Parameters:
sig  Pointer to signal to gather coverage information from
comp_cov  Pointer to compressed CDD coverage structure to populate

00683   { PROFILE(RANK_GATHER_SIGNAL_COV);
00684 
00685   /* Populate toggle coverage information */
00686   if( (sig->suppl.part.type != SSUPPL_TYPE_PARAM)      &&
00687       (sig->suppl.part.type != SSUPPL_TYPE_PARAM_REAL) &&
00688       (sig->suppl.part.type != SSUPPL_TYPE_ENUM)       &&
00689       (sig->suppl.part.type != SSUPPL_TYPE_MEM)        &&
00690       (sig->suppl.part.mba == 0) ) {
00691 
00692     unsigned int i;
00693     if( sig->suppl.part.excluded == 1 ) {
00694       for( i=0; i<sig->value->width; i++ ) {
00695         uint64 index = comp_cov->cps_index[CP_TYPE_TOGGLE]++;
00696         rank_check_index( CP_TYPE_TOGGLE, index, __LINE__ );
00697         comp_cov->cps[CP_TYPE_TOGGLE][UL_DIV(index)] |= (ulong)0x1 << UL_MOD(index);
00698         index = comp_cov->cps_index[CP_TYPE_TOGGLE]++;
00699         rank_check_index( CP_TYPE_TOGGLE, index, __LINE__ );
00700         comp_cov->cps[CP_TYPE_TOGGLE][UL_DIV(index)] |= (ulong)0x1 << UL_MOD(index);
00701       }
00702     } else {
00703       switch( sig->value->suppl.part.data_type ) {
00704         case VDATA_UL :
00705           for( i=0; i<sig->value->width; i++ ) {
00706             uint64 index = comp_cov->cps_index[CP_TYPE_TOGGLE]++;
00707             rank_check_index( CP_TYPE_TOGGLE, index, __LINE__ );
00708             comp_cov->cps[CP_TYPE_TOGGLE][UL_DIV(index)] |= ((sig->value->value.ul[UL_DIV(i)][VTYPE_INDEX_SIG_TOG01] >> UL_MOD(i)) & (ulong)0x1) << UL_MOD(index);
00709             index = comp_cov->cps_index[CP_TYPE_TOGGLE]++;
00710             rank_check_index( CP_TYPE_TOGGLE, index, __LINE__ );
00711             comp_cov->cps[CP_TYPE_TOGGLE][UL_DIV(index)] |= ((sig->value->value.ul[UL_DIV(i)][VTYPE_INDEX_SIG_TOG10] >> UL_MOD(i)) & (ulong)0x1) << UL_MOD(index);
00712           }
00713         break;
00714         default :  assert( 0 );  break;
00715       }
00716     }
00717 
00718   }
00719 
00720   /* Populate memory coverage information */
00721   if( (sig->suppl.part.type == SSUPPL_TYPE_MEM) && (sig->udim_num > 0) ) {
00722 
00723     unsigned int i;
00724     unsigned int pwidth = 1;
00725 
00726     for( i=(sig->udim_num); i<(sig->udim_num + sig->pdim_num); i++ ) {
00727       if( sig->dim[i].msb > sig->dim[i].lsb ) {
00728         pwidth *= (sig->dim[i].msb - sig->dim[i].lsb) + 1;
00729       } else {
00730         pwidth *= (sig->dim[i].lsb - sig->dim[i].msb) + 1;
00731       }
00732     }
00733 
00734     /* Calculate total number of addressable elements and their write/read information */
00735     for( i=0; i<sig->value->width; i+=pwidth ) {
00736       if( sig->suppl.part.excluded == 1 ) {
00737         uint64 index = comp_cov->cps_index[CP_TYPE_MEM]++;
00738         rank_check_index( CP_TYPE_MEM, index, __LINE__ );
00739         comp_cov->cps[CP_TYPE_MEM][UL_DIV(index)] |= (ulong)0x1 << UL_MOD(index);
00740         index = comp_cov->cps_index[CP_TYPE_MEM]++;
00741         rank_check_index( CP_TYPE_MEM, index, __LINE__ );
00742         comp_cov->cps[CP_TYPE_MEM][UL_DIV(index)] |= (ulong)0x1 << UL_MOD(index);
00743       } else {
00744         unsigned int wr = 0;
00745         unsigned int rd = 0;
00746         uint64       index;
00747         vector_mem_rw_count( sig->value, (int)i, (int)((i + pwidth) - 1), &wr, &rd );
00748         index = comp_cov->cps_index[CP_TYPE_MEM]++;
00749         rank_check_index( CP_TYPE_MEM, index, __LINE__ );
00750         comp_cov->cps[CP_TYPE_MEM][UL_DIV(index)] |= (ulong)((wr > 0) ? 1 : 0) << UL_MOD(index);
00751         index = comp_cov->cps_index[CP_TYPE_MEM]++;
00752         rank_check_index( CP_TYPE_MEM, index, __LINE__ );
00753         comp_cov->cps[CP_TYPE_MEM][UL_DIV(index)] |= (ulong)((rd > 0) ? 1 : 0) << UL_MOD(index);
00754       }
00755     }
00756 
00757     /* Calculate toggle coverage information for the memory */
00758     if( sig->suppl.part.excluded == 1 ) {
00759       for( i=0; i<sig->value->width; i++ ) {
00760         uint64 index = comp_cov->cps_index[CP_TYPE_MEM]++;
00761         rank_check_index( CP_TYPE_MEM, index, __LINE__ );
00762         comp_cov->cps[CP_TYPE_MEM][UL_DIV(index)] |= (ulong)0x1 << UL_MOD(index);
00763         index = comp_cov->cps_index[CP_TYPE_MEM]++;
00764         rank_check_index( CP_TYPE_MEM, index, __LINE__ );
00765         comp_cov->cps[CP_TYPE_MEM][UL_DIV(index)] |= (ulong)0x1 << UL_MOD(index);
00766       }
00767     } else {
00768       switch( sig->value->suppl.part.data_type ) {
00769         case VDATA_UL :
00770           for( i=0; i<sig->value->width; i++ ) {  
00771             uint64 index = comp_cov->cps_index[CP_TYPE_MEM]++;
00772             rank_check_index( CP_TYPE_MEM, index, __LINE__ );
00773             comp_cov->cps[CP_TYPE_MEM][UL_DIV(index)] |= ((sig->value->value.ul[UL_DIV(i)][VTYPE_INDEX_MEM_TOG01] >> UL_MOD(i)) & (ulong)0x1) << UL_MOD(index);
00774             index = comp_cov->cps_index[CP_TYPE_MEM]++;
00775             rank_check_index( CP_TYPE_MEM, index, __LINE__ );
00776             comp_cov->cps[CP_TYPE_MEM][UL_DIV(index)] |= ((sig->value->value.ul[UL_DIV(i)][VTYPE_INDEX_MEM_TOG10] >> UL_MOD(i)) & (ulong)0x1) << UL_MOD(index);
00777           }
00778           break;
00779         default :  assert( 0 );  break;
00780       } 
00781     }   
00782         
00783   }   
00784 
00785   PROFILE_END;
00786 
00787 }

void rank_output comp_cdd_cov **  comp_cdds,
unsigned int  comp_cdd_num
[static]
 

Outputs the ranking of the CDD files to the output file specified from the rank command line.

Parameters:
comp_cdds  Pointer to array of ranked CDD coverage structures
comp_cdd_num  Number of allocated structures in comp_cdds array

01562   { PROFILE(RANK_OUTPUT);
01563 
01564   FILE*        ofile;
01565   unsigned int rv;
01566 
01567   if( rank_file == NULL ) {
01568     print_output( "\nGenerating report output to standard output...", NORMAL, __FILE__, __LINE__ );
01569   } else {
01570     rv = snprintf( user_msg, USER_MSG_LENGTH, "\nGenerating report file \"%s\"...", rank_file );
01571     assert( rv < USER_MSG_LENGTH );
01572     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01573   }
01574 
01575   if( (ofile = ((rank_file == NULL) ? stdout : fopen( rank_file, "w" ))) != NULL ) {
01576 
01577     unsigned int rv;
01578     unsigned int i;
01579     uint64       acc_timesteps  = 0;
01580     uint64       acc_unique_cps = 0;
01581     bool         unique_found   = TRUE;
01582     uint64       total_cps      = 0;
01583 
01584     /* Calculate the total number of coverage points */
01585     for( i=0; i<CP_TYPE_NUM; i++ ) {
01586       total_cps += num_cps[i];
01587     }
01588 
01589     /* If we are outputting to standard output, make sure we have a few newlines for readability purposes */
01590     if( ofile == stdout ) {
01591       fprintf( ofile, "\n\n\n" );
01592     }
01593 
01594     if( flag_names_only ) {
01595 
01596       for( i=0; i<comp_cdd_num; i++ ) {
01597         if( comp_cdds[i]->unique_cps > 0 ) {
01598           fprintf( ofile, "%s\n", comp_cdds[i]->cdd_name );
01599         }
01600       }
01601 
01602     } else {
01603 
01604       char* str;
01605       char  format[100];
01606 
01607       /* Allocate memory for a spacing string */
01608       str = (char*)malloc_safe( longest_name_len + 1 );
01609 
01610       /* Header information output */
01611       fprintf( ofile, "                                           ::::::::::::::::::::::::::::::::::::::::::::::::::::\n" );
01612       fprintf( ofile, "                                           ::                                                ::\n" );
01613       fprintf( ofile, "                                           ::     Covered -- Simulation Ranked Run Order     ::\n" );
01614       fprintf( ofile, "                                           ::                                                ::\n" );
01615       fprintf( ofile, "                                           ::::::::::::::::::::::::::::::::::::::::::::::::::::\n\n\n" );
01616       fprintf( ofile, "\n" );
01617 
01618       /* Calculate and display reduction status */
01619       i = 0;
01620       while( (i<comp_cdd_num) && ((comp_cdds[i]->unique_cps > 0) || comp_cdds[i]->required) ) i++;
01621       if( i == comp_cdd_num ) {
01622         fprintf( ofile, "No reduction occurred\n" );
01623       } else {
01624         uint64       total_timesteps  = 0;
01625         uint64       ranked_timesteps = 0;
01626         unsigned int col1, col2, j;
01627         char         str[30];
01628         char         fmt[4096];
01629 
01630         /* Calculated total_timesteps and ranked_timesteps */
01631         for( j=0; j<comp_cdd_num; j++ ) {
01632           total_timesteps += comp_cdds[j]->timesteps;
01633           if( (comp_cdds[j]->unique_cps > 0) || comp_cdds[j]->required ) {
01634             ranked_timesteps = total_timesteps;
01635           }
01636         }
01637 
01638         /* Figure out the largest number for the first column */
01639         /*@-duplicatequals -formattype@*/
01640         rv = snprintf( str, 30, "%llu", total_timesteps );   col1 = strlen( str );
01641         assert( rv < 30 );
01642         rv = snprintf( str, 30, "%llu", ranked_timesteps );  col2 = strlen( str );
01643         /*@=duplicatequals =formattype@*/
01644         assert( rv < 30 );
01645 
01646         /* Create line for CDD files */
01647         rv = snprintf( fmt, 4096, "* Reduced %%%uu CDD files down to %%%uu needed to maintain coverage (%%3.0f%%%% reduction, %%5.1fx improvement)\n", col1, col2 );
01648         assert( rv < 4096 );
01649         fprintf( ofile, fmt, comp_cdd_num, i, (((comp_cdd_num - i) / (float)comp_cdd_num) * 100), (comp_cdd_num / (float)i) );
01650 
01651         /* Create line for timesteps */
01652         rv = snprintf( fmt, 4096, "* Reduced %%%ullu timesteps down to %%%ullu needed to maintain coverage (%%3.0f%%%% reduction, %%5.1fx improvement)\n", col1, col2 );
01653         assert( rv < 4096 );
01654         fprintf( ofile, fmt, total_timesteps, ranked_timesteps, (((total_timesteps - ranked_timesteps) / (double)total_timesteps) * 100), (total_timesteps / (double)ranked_timesteps) );
01655       }
01656       fprintf( ofile, "\n" );
01657       gen_char_string( str, '-', (longest_name_len - 3) );
01658       fprintf( ofile, "-----------+-------------------------------------------+---------%s------------------------------------------\n", str );
01659       gen_char_string( str, ' ', (longest_name_len >> 1) );
01660       fprintf( ofile, "           |                ACCUMULATIVE               |         %s               CDD\n", str );
01661       gen_char_string( str, '-', (longest_name_len - 3) );
01662       fprintf( ofile, "Simulation |-------------------------------------------+---------%s------------------------------------------\n", str );
01663       gen_char_string( str, ' ', (longest_name_len - 3) );
01664       fprintf( ofile, "Order      |        Hit /      Total     %%   Timesteps |  R  Name%s        Hit /      Total     %%   Timesteps\n", str );
01665       gen_char_string( str, '-', (longest_name_len - 3) );
01666       fprintf( ofile, "-----------+-------------------------------------------+---------%s------------------------------------------\n", str );
01667       fprintf( ofile, "\n" );
01668 
01669       /* Calculate a string format */
01670       rv = snprintf( format, 100, "%%10u   %%10llu   %%10llu  %%3.0f%%%%  %%10llu    %%c  %%-%us  %%10llu   %%10llu  %%3.0f%%%%  %%10llu\n", longest_name_len );
01671       assert( rv < 100 );
01672 
01673       for( i=0; i<comp_cdd_num; i++ ) {
01674         acc_timesteps  += comp_cdds[i]->timesteps; 
01675         acc_unique_cps += comp_cdds[i]->unique_cps;
01676         if( (comp_cdds[i]->unique_cps == 0) && unique_found && !comp_cdds[i]->required ) {
01677           fprintf( ofile, "\n---------------------------------------  The following CDD files add no additional coverage  ----------------------------------------------\n\n" );
01678           unique_found = FALSE;
01679         }
01680         fprintf( ofile, format,
01681                 (i + 1),
01682                 acc_unique_cps,
01683                 total_cps,
01684                 ((acc_unique_cps / (float)total_cps) * 100),
01685                 acc_timesteps,
01686                 (comp_cdds[i]->required ? '*' : ' '),
01687                 comp_cdds[i]->cdd_name,
01688                 comp_cdds[i]->total_cps,
01689                 total_cps,
01690                 ((comp_cdds[i]->total_cps / (float)total_cps) * 100),
01691                 comp_cdds[i]->timesteps );
01692       }
01693       fprintf( ofile, "\n\n" );
01694 
01695       /* Deallocate the spacing string */
01696       free_safe( str, (longest_name_len + 1) );
01697 
01698     }
01699 
01700     /* Close the file if it was opened via fopen */
01701     if( rank_file != NULL ) {
01702       rv = fclose( ofile );
01703       assert( rv == 0 );
01704     }
01705 
01706   } else {
01707 
01708     rv = snprintf( user_msg, USER_MSG_LENGTH, "Unable to open ranking file \"%s\" for writing", rank_file );
01709     assert( rv < USER_MSG_LENGTH );
01710     print_output( user_msg, FATAL, __FILE__, __LINE__ );
01711     Throw 0;
01712 
01713   }
01714 
01715   PROFILE_END;
01716 
01717 }

bool rank_parse_args int  argc,
int  last_arg,
const char **  argv
[static]
 

Returns:
Returns TRUE if help option was found.
Exceptions:
anonymous Throw Throw Throw
Parses the score argument list, placing all parsed values into global variables. If an argument is found that is not valid for the rank operation, an error message is displayed to the user.
Parameters:
argc  Number of arguments in argument list argv
last_arg  Index of last parsed argument from list
argv  Argument list passed to this program

00294   {
00295 
00296   int       i;
00297   unsigned  rank_in_num = 0;
00298   str_link* strl;
00299   str_link* ext_head    = NULL;
00300   str_link* ext_tail    = NULL;
00301   str_link* dir_head    = NULL;
00302   str_link* dir_tail    = NULL;
00303   bool      help_found  = FALSE;
00304 
00305   i = last_arg + 1;
00306 
00307   while( (i < argc) && !help_found ) {
00308 
00309     if( strncmp( "-h", argv[i], 2 ) == 0 ) {
00310 
00311       rank_usage();
00312       help_found = TRUE;
00313 
00314     } else if( strncmp( "-o", argv[i], 2 ) == 0 ) {
00315 
00316       if( check_option_value( argc, argv, i ) ) {
00317         i++;
00318         if( rank_file != NULL ) {
00319           print_output( "Only one -o option is allowed on the rank command-line.  Using first value...", WARNING, __FILE__, __LINE__ );
00320         } else {
00321           if( is_legal_filename( argv[i] ) ) {
00322             rank_file = strdup_safe( argv[i] );
00323           } else {
00324             unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Output file \"%s\" is unwritable", argv[i] );
00325             assert( rv < USER_MSG_LENGTH );
00326             print_output( user_msg, FATAL, __FILE__, __LINE__ );
00327             Throw 0;
00328           }
00329         }
00330       } else {
00331         Throw 0;
00332       } 
00333 
00334     } else if( strncmp( "-f", argv[i], 2 ) == 0 ) {
00335 
00336       if( check_option_value( argc, argv, i ) ) {
00337         char**       arg_list = NULL;
00338         int          arg_num  = 0;
00339         unsigned int j;
00340         i++;
00341         Try {
00342           read_command_file( argv[i], &arg_list, &arg_num );
00343           help_found = rank_parse_args( arg_num, -1, (const char**)arg_list );
00344         } Catch_anonymous {
00345           for( j=0; j<arg_num; j++ ) {
00346             free_safe( arg_list[j], (strlen( arg_list[j] ) + 1) );
00347           }
00348           free_safe( arg_list, (sizeof( char* ) * arg_num) );
00349           Throw 0;
00350         }
00351         for( j=0; j<arg_num; j++ ) {
00352           free_safe( arg_list[j], (strlen( arg_list[j] ) + 1) );
00353         }
00354         free_safe( arg_list, (sizeof( char* ) * arg_num) );
00355       } else {
00356         Throw 0;
00357       }
00358 
00359     } else if( strncmp( "-required-list", argv[i], 14 ) == 0 ) {
00360 
00361       if( check_option_value( argc, argv, i ) ) {
00362         i++;
00363         if( file_exists( argv[i] ) ) {
00364           FILE* file;
00365           if( (file = fopen( argv[i], "r" )) != NULL ) {
00366             char         fname[4096];
00367             unsigned int rv;
00368             while( fscanf( file, "%s", fname ) == 1 ) {
00369               if( file_exists( fname ) ) {
00370                 str_link* strl;
00371                 if( (strl = str_link_find( fname, rank_in_head )) == NULL ) {
00372                   strl = str_link_add( strdup_safe( fname ), &rank_in_head, &rank_in_tail );
00373                 }
00374                 strl->suppl = 1;
00375               } else {
00376                 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Filename (%s) specified in -required file (%s) does not exist", fname, argv[i] );
00377                 assert( rv < USER_MSG_LENGTH );
00378                 print_output( user_msg, FATAL, __FILE__, __LINE__ );
00379                 Throw 0;
00380               }
00381             }
00382             rv = fclose( file );
00383             assert( rv == 0 );
00384           } else {
00385             unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Unable to read -required-list file (%s)", argv[i] );
00386             assert( rv < USER_MSG_LENGTH );
00387             print_output( user_msg, FATAL, __FILE__, __LINE__ );
00388             Throw 0;
00389           }
00390         } else {
00391           unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Filename specified for -required-list option (%s) does not exist", argv[i] );
00392           assert( rv < USER_MSG_LENGTH );
00393           print_output( user_msg, FATAL, __FILE__, __LINE__ );
00394           Throw 0;
00395         }
00396       
00397       } else {
00398         Throw 0;
00399       }
00400 
00401     } else if( strncmp( "-required-cdd", argv[i], 13 ) == 0 ) {
00402 
00403       if( check_option_value( argc, argv, i ) ) {
00404         i++;
00405         if( file_exists( argv[i] ) ) {
00406           str_link* strl;
00407           if( (strl = str_link_find( argv[i], rank_in_head )) == NULL ) {
00408             strl = str_link_add( strdup_safe( argv[i] ), &rank_in_head, &rank_in_tail );
00409           }
00410           strl->suppl = 1;
00411         } else {
00412           unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Unable to read -required-cdd file (%s)", argv[i] );
00413           assert( rv < USER_MSG_LENGTH );
00414           print_output( user_msg, FATAL, __FILE__, __LINE__ );
00415           Throw 0;
00416         }
00417       } else {
00418         Throw 0;
00419       }
00420 
00421     } else if( strncmp( "-ext", argv[i], 4 ) == 0 ) {
00422 
00423       if( check_option_value( argc, argv, i ) ) {
00424         i++;
00425         (void)str_link_add( strdup_safe( argv[i] ), &ext_head, &ext_tail );
00426       } else {
00427         Throw 0;
00428       }
00429 
00430     } else if( strncmp( "-weight-line", argv[i], 12 ) == 0 ) {
00431 
00432       if( check_option_value( argc, argv, i ) ) {
00433         i++;
00434         if( cdd_type_set[CP_TYPE_LINE] ) {
00435           print_output( "Only one -weight-line option is allowed on the rank command-line.  Using first value...", WARNING, __FILE__, __LINE__ );
00436         } else {
00437           if( sscanf( argv[i], "%u", &cdd_type_weight[CP_TYPE_LINE] ) != 1 ) {
00438             print_output( "Value specified after -weight-line must be a number", FATAL, __FILE__, __LINE__ );
00439             Throw 0;
00440           } else {
00441             cdd_type_set[CP_TYPE_LINE] = TRUE;
00442           }
00443         }
00444       } else {
00445         Throw 0;
00446       }
00447 
00448     } else if( strncmp( "-weight-toggle", argv[i], 14 ) == 0 ) {
00449   
00450       if( check_option_value( argc, argv, i ) ) {
00451         i++;
00452         if( cdd_type_set[CP_TYPE_TOGGLE] ) {
00453           print_output( "Only one -weight-toggle option is allowed on the rank command-line.  Using first value...", WARNING, __FILE__, __LINE__ );
00454         } else {
00455           if( sscanf( argv[i], "%u", &cdd_type_weight[CP_TYPE_TOGGLE] ) != 1 ) {
00456             print_output( "Value specified after -weight-toggle must be a number", FATAL, __FILE__, __LINE__ );
00457             Throw 0;
00458           } else {
00459             cdd_type_set[CP_TYPE_TOGGLE] = TRUE;
00460           }
00461         }
00462       } else {
00463         Throw 0;
00464       }
00465 
00466     } else if( strncmp( "-weight-memory", argv[i], 14 ) == 0 ) {
00467 
00468       if( check_option_value( argc, argv, i ) ) {
00469         i++;
00470         if( cdd_type_set[CP_TYPE_MEM] ) {
00471           print_output( "Only one -weight-memory option is allowed on the rank command-line.  Using first value...", WARNING, __FILE__, __LINE__ );
00472         } else {
00473           if( sscanf( argv[i], "%u", &cdd_type_weight[CP_TYPE_MEM] ) != 1 ) {
00474             print_output( "Value specified after -weight-memory must be a number", FATAL, __FILE__, __LINE__ );
00475             Throw 0;
00476           } else {
00477             cdd_type_set[CP_TYPE_MEM] = TRUE;
00478           }
00479         }
00480       } else {
00481         Throw 0;
00482       }
00483 
00484     } else if( strncmp( "-weight-comb", argv[i], 12 ) == 0 ) {
00485 
00486       if( check_option_value( argc, argv, i ) ) {
00487         i++; 
00488         if( cdd_type_set[CP_TYPE_LOGIC] ) {
00489           print_output( "Only one -weight-comb option is allowed on the rank command-line.  Using first value...", WARNING, __FILE__, __LINE__ );
00490         } else {
00491           if( sscanf( argv[i], "%u", &cdd_type_weight[CP_TYPE_LOGIC] ) != 1 ) {
00492             print_output( "Value specified after -weight-comb must be a number", FATAL, __FILE__, __LINE__ );
00493             Throw 0;
00494           } else {
00495             cdd_type_set[CP_TYPE_LOGIC] = TRUE;
00496           }
00497         }
00498       } else {
00499         Throw 0;
00500       }
00501 
00502     } else if( strncmp( "-weight-fsm", argv[i], 11 ) == 0 ) {
00503 
00504       if( check_option_value( argc, argv, i ) ) {
00505         i++;
00506         if( cdd_type_set[CP_TYPE_FSM] ) {
00507           print_output( "Only one -weight-fsm option is allowed on the rank command-line.  Using first value...", WARNING, __FILE__, __LINE__ );
00508         } else {
00509           if( sscanf( argv[i], "%u", &cdd_type_weight[CP_TYPE_FSM] ) != 1 ) {
00510             print_output( "Value specified after -weight-fsm must be a number", FATAL, __FILE__, __LINE__ );
00511             Throw 0;
00512           } else {
00513             cdd_type_set[CP_TYPE_FSM] = TRUE;
00514           }
00515         }
00516       } else {
00517         Throw 0;
00518       }
00519 
00520     } else if( strncmp( "-weight-assert", argv[i], 14 ) == 0 ) {
00521 
00522       if( check_option_value( argc, argv, i ) ) {
00523         i++;
00524         if( cdd_type_set[CP_TYPE_ASSERT] ) {
00525           print_output( "Only one -weight-assert option is allowed on the rank command-line.  Using first value...", WARNING, __FILE__, __LINE__ );
00526         } else {
00527           if( sscanf( argv[i], "%u", &cdd_type_weight[CP_TYPE_ASSERT] ) != 1 ) {
00528             print_output( "Value specified after -weight-assert must be a number", FATAL, __FILE__, __LINE__ );
00529             Throw 0;
00530           } else {
00531             cdd_type_set[CP_TYPE_ASSERT] = TRUE;
00532           }
00533         }
00534       } else {
00535         Throw 0;
00536       }
00537 
00538     } else if( strncmp( "-names-only", argv[i], 11 ) == 0 ) {
00539 
00540       flag_names_only = TRUE;
00541 
00542     } else if( strncmp( "-depth", argv[i], 6 ) == 0 ) {
00543 
00544       if( check_option_value( argc, argv, i ) ) {
00545         i++;
00546         if( cp_depth != 0 ) {
00547           print_output( "Only one -depth option is allowed on the rank command-line.  Using first value...", WARNING, __FILE__, __LINE__ );
00548         } else {
00549           if( (sscanf( argv[i], "%u", &cp_depth ) != 1) || (cp_depth == 0) ) {
00550             print_output( "Value specified after -depth must be a positive, non-zero number", FATAL, __FILE__, __LINE__ );
00551             Throw 0;
00552           }
00553         }
00554       } else {
00555         Throw 0;
00556       }
00557 
00558     } else if( strncmp( "-d", argv[i], 2 ) == 0 ) {
00559 
00560       if( check_option_value( argc, argv, i ) ) {
00561         i++;
00562         if( directory_exists( argv[i] ) ) {
00563           (void)str_link_add( strdup_safe( argv[i] ), &dir_head, &dir_tail );
00564         } else {
00565           unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Specified -d directory (%s) does not exist", argv[i] );
00566           assert( rv < USER_MSG_LENGTH );
00567           print_output( user_msg, FATAL, __FILE__, __LINE__ );
00568           Throw 0;
00569         }
00570       } else {
00571         Throw 0;
00572       }
00573 
00574     } else if( strncmp( "-v", argv[i], 2 ) == 0 ) {
00575 
00576       rank_verbose = TRUE;
00577 
00578     } else if( strncmp( "-", argv[i], 1 ) == 0 ) {
00579 
00580       unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Unknown rank option (%s) specified.", argv[i] );
00581       assert( rv < USER_MSG_LENGTH );
00582       print_output( user_msg, FATAL, __FILE__, __LINE__ );
00583       Throw 0;
00584 
00585     } else {
00586 
00587       /* The name of a file to rank */
00588       if( file_exists( argv[i] ) ) {
00589 
00590         if( str_link_find( argv[i], rank_in_head ) == NULL ) {
00591 
00592           /* Add the specified rank file to the list */
00593           (void)str_link_add( strdup_safe( argv[i] ), &rank_in_head, &rank_in_tail );
00594 
00595         }
00596 
00597       } else {
00598 
00599         unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "CDD file (%s) does not exist", argv[i] );
00600         assert( rv < USER_MSG_LENGTH );
00601         print_output( user_msg, FATAL, __FILE__, __LINE__ );
00602         Throw 0;
00603 
00604       }
00605 
00606     }
00607 
00608     i++;
00609 
00610   }
00611 
00612   if( !help_found ) {
00613 
00614     Try {
00615 
00616       /* Load any ranking files found in specified directories */
00617       strl = dir_head;
00618       while( strl != NULL ) {
00619         directory_load( strl->str, ext_head, &rank_in_head, &rank_in_tail );
00620         strl = strl->next;
00621       }
00622 
00623     } Catch_anonymous {
00624       str_link_delete_list( ext_head );
00625       str_link_delete_list( dir_head );
00626       Throw 0;
00627     }
00628 
00629     /* Count the number of files being ranked */
00630     strl = rank_in_head;
00631     while( strl != NULL ) {
00632       rank_in_num++;
00633       strl = strl->next;
00634     }
00635 
00636     /* Check to make sure that the user specified at least two files to rank */
00637     if( rank_in_num < 2 ) {
00638       print_output( "Must specify at least two CDD files to rank", FATAL, __FILE__, __LINE__ );
00639       Throw 0;
00640     }
00641 
00642     /* If no -depth option was specified, set its value to 1 */
00643     if( cp_depth == 0 ) {
00644       cp_depth = 1;
00645     }
00646 
00647   }
00648 
00649   /* Deallocate the temporary lists */
00650   str_link_delete_list( ext_head );
00651   str_link_delete_list( dir_head );
00652 
00653   return( help_found );
00654 
00655 }

void rank_perform comp_cdd_cov **  comp_cdds,
unsigned int  comp_cdd_num
[static]
 

Performs the task of ranking the CDD files and rearranging them in the comp_cdds array such that the first CDD file is located at index 0.

Parameters:
comp_cdds  Pointer to array of compressed CDD coverage structures to rank
comp_cdd_num  Number of allocated structures in comp_cdds array

01353   { PROFILE(RANK_PERFORM);
01354 
01355   unsigned int i, j, k;
01356   uint16*      ranked_merged;
01357   uint16*      unranked_merged;
01358   uint16       merged_index = 0;
01359   uint64       total        = 0;
01360   uint64       total_hitable;
01361   unsigned int next_cdd     = 0;
01362   unsigned int most_unique;
01363   unsigned int count;
01364   unsigned int cdds_ranked  = 0;
01365   timer*       atimer       = NULL;
01366   unsigned int rv;
01367 
01368   if( (!output_suppressed || debug_mode) && !rank_verbose ) {
01369     printf( "Ranking CDD files " );
01370     rv = fflush( stdout );
01371     assert( rv == 0 );
01372   }
01373 
01374   /* Calculate the total number of needed merged entries to store accumulated information */
01375   for( i=0; i<CP_TYPE_NUM; i++ ) {
01376     total += num_cps[i];
01377   }
01378   assert( total > 0 );
01379 
01380   /* Allocate merged array */
01381   ranked_merged   = (uint16*)calloc_safe( total, sizeof( uint16 ) );
01382   unranked_merged = (uint16*)malloc_safe_nolimit( sizeof( uint16 ) * total );
01383 
01384   if( rank_verbose ) {
01385     /*@-duplicatequals -formattype@*/
01386     rv = snprintf( user_msg, USER_MSG_LENGTH, "\nRanking %u CDD files with %llu coverage points (%llu line, %llu toggle, %llu memory, %llu logic, %llu FSM, %llu assertion)",
01387               comp_cdd_num, total, num_cps[CP_TYPE_LINE], num_cps[CP_TYPE_TOGGLE], num_cps[CP_TYPE_MEM], num_cps[CP_TYPE_LOGIC], num_cps[CP_TYPE_FSM], num_cps[CP_TYPE_ASSERT] );
01388     /*@=duplicatequals =formattype@*/
01389     assert( rv < USER_MSG_LENGTH );
01390     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01391   }
01392 
01393   /* Step 1 - Initialize merged results array, calculate uniqueness and total values of each compressed CDD coverage structure */
01394   for( i=0; i<CP_TYPE_NUM; i++ ) {
01395     for( j=0; j<num_cps[i]; j++ ) {
01396       uint16       bit_total = 0;
01397       unsigned int set_cdd;
01398       for( k=0; k<comp_cdd_num; k++ ) {
01399         if( (comp_cdds[k]->cps[i][UL_DIV(j)] & ((ulong)0x1 << UL_MOD(j))) != 0 ) {
01400           comp_cdds[k]->total_cps++;
01401           set_cdd = k;
01402           bit_total++;
01403         }
01404       }
01405       unranked_merged[merged_index++] = bit_total;
01406 
01407       /* If we found exactly one CDD file that hit this coverage point, mark it in the corresponding CDD file */
01408       if( bit_total == 1 ) {
01409         comp_cdds[set_cdd]->unique_cps++;
01410       }
01411     }
01412   }
01413 
01414   if( rank_verbose ) {
01415     total_hitable = rank_count_cps( unranked_merged, total ); 
01416     /*@-duplicatequals +ignorequals@*/
01417     rv = snprintf( user_msg, USER_MSG_LENGTH, "Ignoring %llu coverage points that were not hit by any CDD file", (total - total_hitable) );
01418     /*@=duplicatequals =ignorequals@*/
01419     assert( rv < USER_MSG_LENGTH );
01420     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01421 
01422     print_output( "\nPhase 1:  Adding user-required files", NORMAL, __FILE__, __LINE__ );
01423     rv = fflush( stdout );
01424     assert( rv == 0 );
01425     timer_clear( &atimer );
01426     timer_start( &atimer );
01427   }
01428 
01429   /* Step 2 - Immediately rank all of the required CDDs */
01430   for( i=0; i<comp_cdd_num; i++ ) {
01431     if( comp_cdds[i]->required ) {
01432       rank_selected_cdd_cov( comp_cdds, comp_cdd_num, ranked_merged, unranked_merged, next_cdd, i );
01433       next_cdd++;
01434     }
01435   }
01436 
01437   if( rank_verbose ) {
01438     uint64 ranked_cps = rank_count_cps( ranked_merged, total );
01439     timer_stop( &atimer );
01440     rv = snprintf( user_msg, USER_MSG_LENGTH, "  Ranked %u CDD files (Total ranked: %u, Remaining: %u)", next_cdd, next_cdd, (comp_cdd_num - next_cdd) );
01441     assert( rv < USER_MSG_LENGTH );
01442     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01443     /*@-duplicatequals -formattype@*/
01444     rv = snprintf( user_msg, USER_MSG_LENGTH, "  %llu points covered, %llu points remaining", ranked_cps, (total_hitable - ranked_cps) );
01445     /*@=duplicatequals =formattype@*/
01446     assert( rv < USER_MSG_LENGTH );
01447     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01448     rv = snprintf( user_msg, USER_MSG_LENGTH, "Completed phase 1 in %s", timer_to_string( atimer ) );
01449     assert( rv < USER_MSG_LENGTH );
01450     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01451   
01452     count = next_cdd;
01453     print_output( "\nPhase 2:  Adding files that hit unique coverage points", NORMAL, __FILE__, __LINE__ );
01454     rv = fflush( stdout );
01455     assert( rv == 0 );
01456     timer_clear( &atimer );
01457     timer_start( &atimer );
01458   }
01459 
01460   /* Step 3 - Start with the most unique CDDs */
01461   do {
01462     most_unique = next_cdd;
01463     for( i=(next_cdd+1); i<comp_cdd_num; i++ ) {
01464       if( comp_cdds[i]->unique_cps > comp_cdds[most_unique]->unique_cps ) {
01465         most_unique = i;
01466       }
01467     }
01468     if( comp_cdds[most_unique]->unique_cps > 0 ) {
01469       rank_selected_cdd_cov( comp_cdds, comp_cdd_num, ranked_merged, unranked_merged, next_cdd, most_unique );
01470       next_cdd++;
01471     }
01472   } while( (next_cdd < comp_cdd_num) && (comp_cdds[most_unique]->unique_cps > 0) );
01473 
01474   if( rank_verbose ) {
01475     uint64 ranked_cps = rank_count_cps( ranked_merged, total );
01476     timer_stop( &atimer );
01477     rv = snprintf( user_msg, USER_MSG_LENGTH, "  Ranked %u CDD files (Total ranked: %u, Remaining: %u)", (next_cdd - count), next_cdd, (comp_cdd_num - next_cdd) );
01478     assert( rv < USER_MSG_LENGTH );
01479     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01480     /*@-duplicatequals -formattype@*/
01481     rv = snprintf( user_msg, USER_MSG_LENGTH, "  %llu points covered, %llu points remaining", ranked_cps, (total_hitable - ranked_cps) );
01482     /*@=duplicatequals =formattype@*/
01483     assert( rv < USER_MSG_LENGTH );
01484     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01485     rv = snprintf( user_msg, USER_MSG_LENGTH, "Completed phase 2 in %s", timer_to_string( atimer ) );
01486     assert( rv < USER_MSG_LENGTH );
01487     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01488    
01489     count = next_cdd;
01490     print_output( "\nPhase 3:  Adding files that hit remaining coverage points and eliminating redundant files", NORMAL, __FILE__, __LINE__ );
01491     rv = fflush( stdout );
01492     assert( rv == 0 );
01493     timer_clear( &atimer );
01494     timer_start( &atimer );
01495   }
01496 
01497   /* Step 4 - Select coverage based on user-specified factors */
01498   if( next_cdd < comp_cdd_num ) {
01499     rank_perform_weighted_selection( comp_cdds, comp_cdd_num, ranked_merged, unranked_merged, next_cdd, &cdds_ranked );
01500   }
01501 
01502   if( rank_verbose ) {
01503     uint64 ranked_cps = rank_count_cps( ranked_merged, total );
01504     timer_stop( &atimer );
01505     rv = snprintf( user_msg, USER_MSG_LENGTH, "  Ranked %u CDD files (Total ranked: %u, Eliminated: %u)", cdds_ranked, (count + cdds_ranked), (comp_cdd_num - (count + cdds_ranked)) );
01506     assert( rv < USER_MSG_LENGTH );
01507     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01508     /*@-duplicatequals -formattype@*/
01509     rv = snprintf( user_msg, USER_MSG_LENGTH, "  %llu points covered, %llu points remaining", ranked_cps, (total_hitable - ranked_cps) );
01510     /*@=duplicatequals =formattype@*/
01511     assert( rv < USER_MSG_LENGTH );
01512     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01513     rv = snprintf( user_msg, USER_MSG_LENGTH, "Completed phase 3 in %s", timer_to_string( atimer ) );
01514     assert( rv < USER_MSG_LENGTH );
01515     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01516 
01517     print_output( "\nPhase 4:  Sorting CDD files selected for ranking (no reductions)", NORMAL, __FILE__, __LINE__ );
01518     rv = fflush( stdout );
01519     assert( rv == 0 );
01520     timer_clear( &atimer );
01521     timer_start( &atimer );
01522   }
01523 
01524   /* Step 5 - Re-sort the list using a greedy algorithm */
01525   rank_perform_greedy_sort( comp_cdds, comp_cdd_num, ranked_merged, total );
01526 
01527   if( rank_verbose ) {
01528     timer_stop( &atimer );
01529     rv = snprintf( user_msg, USER_MSG_LENGTH, "Completed phase 4 in %s", timer_to_string( atimer ) );
01530     assert( rv < USER_MSG_LENGTH );
01531     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01532     rv = fflush( stdout );
01533     assert( rv == 0 );
01534     free_safe( atimer, sizeof( timer ) );
01535 
01536     if( comp_cdd_num == (count + cdds_ranked) ) {
01537       rv = snprintf( user_msg, USER_MSG_LENGTH, "\nSUMMARY:  No reduction occurred.  %u needed/required", (count + cdds_ranked) );
01538       assert( rv < USER_MSG_LENGTH );
01539     } else {
01540       rv = snprintf( user_msg, USER_MSG_LENGTH, "\nSUMMARY:  Reduced %u CDD files down to %u needed/required", comp_cdd_num, (count + cdds_ranked) );
01541       assert( rv < USER_MSG_LENGTH );
01542     }
01543     print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01544   }
01545 
01546   /* Deallocate merged CDD coverage structure */
01547   free_safe( ranked_merged,   (sizeof( uint16 ) * total ) );
01548   free_safe( unranked_merged, (sizeof( uint16 ) * total ) );
01549 
01550   PROFILE_END;
01551 
01552 }

void rank_perform_greedy_sort comp_cdd_cov **  comp_cdds,
unsigned int  comp_cdd_num,
uint16 ranked_merged,
uint64  num_ranked
[static]
 

Re-sorts the compressed CDD coverage array to order them based on a "most coverage points per timestep" basis.

Parameters:
comp_cdds  Pointer to compressed CDD coverage structure array to re-sort
comp_cdd_num  Number of elements in comp-cdds array
ranked_merged  Array for recalculating uniqueness of sorted elements
num_ranked  Number of elements in ranked_merged array

01273   { PROFILE(RANK_PERFORM_GREEDY_SORT);
01274 
01275   unsigned int  i, j, k, l;
01276   unsigned int  best;
01277   uint64        x;
01278   comp_cdd_cov* tmp;
01279 
01280   /* First, reset the ranked_merged array */
01281   for( x=0; x<num_ranked; x++ ) {
01282     ranked_merged[x] = 0;
01283   }
01284 
01285   /* Rank based on most unique from previously ranked CDDs */
01286   for( i=0; i<comp_cdd_num; i++ ) {
01287     best = i;
01288     for( j=i; j<comp_cdd_num; j++ ) {
01289       x = 0;
01290       comp_cdds[j]->unique_cps = 0;
01291       for( k=0; k<CP_TYPE_NUM; k++ ) {
01292         for( l=0; l<num_cps[k]; l++ ) {
01293           if( comp_cdds[j]->cps[k][UL_DIV(l)] & ((ulong)0x1 << UL_MOD(l)) ) {
01294             if( ranked_merged[x] < cp_depth ) {
01295               comp_cdds[j]->unique_cps++;
01296             }
01297           }
01298           x++;
01299         }
01300       }
01301       if( (comp_cdds[best]->unique_cps < comp_cdds[j]->unique_cps) ||
01302           ((comp_cdds[best]->unique_cps == comp_cdds[j]->unique_cps) && (comp_cdds[best]->timesteps < comp_cdds[j]->timesteps)) ||
01303           ((comp_cdds[best]->unique_cps == 0) && !comp_cdds[best]->required && !comp_cdds[i]->required) ) {
01304         best = j;
01305       }
01306     }
01307     tmp             = comp_cdds[i];
01308     comp_cdds[i]    = comp_cdds[best];
01309     comp_cdds[best] = tmp;
01310     x = 0;
01311     for( j=0; j<CP_TYPE_NUM; j++ ) {
01312       for( k=0; k<num_cps[j]; k++ ) {
01313         if( comp_cdds[i]->cps[j][UL_DIV(k)] & ((ulong)0x1 << UL_MOD(k)) ) {
01314           ranked_merged[x]++;
01315         }
01316         x++;
01317       }
01318     }
01319   }
01320 
01321   PROFILE_END;
01322 
01323 }

void rank_perform_weighted_selection comp_cdd_cov **  comp_cdds,
unsigned int  comp_cdd_num,
uint16 ranked_merged,
uint16 unranked_merged,
unsigned int  next_cdd,
unsigned int *  cdds_ranked
[static]
 

Performs ranking according to scores that are calculated from the user-specified weights and the amount of coverage points left to be hit. Ranks all compressed CDD coverage structures between next_cdd and the end of the array (comp_cdd_num - 1), inclusive.

Parameters:
comp_cdds  Reference to partially sorted list of compressed CDD coverage structures to sort
comp_cdd_num  Number of compressed CDD coverage structures in the comp_cdds array
ranked_merged  Array of ranked merged information from all of the compressed CDD coverage structures
unranked_merged  Array of unranked merged information from all of the compressed CDD coverage structures
next_cdd  Next index in comp_cdds array to set
cdds_ranked  Number of CDDs that were ranked with unique coverage in this function

01218   { PROFILE(RANK_PERFORM_WEIGHTED_SELECTION);
01219 
01220   /* Perform this loop for each remaining coverage file */
01221   for( ; next_cdd<comp_cdd_num; next_cdd++ ) {
01222 
01223     unsigned int i, j, k;
01224     unsigned int highest_score = next_cdd;
01225 
01226     /* Calculate current scores */
01227     for( i=next_cdd; i<comp_cdd_num; i++ ) {
01228       bool   unique_found = FALSE;
01229       uint64 x            = 0;
01230       comp_cdds[i]->score = 0;
01231       for( j=0; j<CP_TYPE_NUM; j++ ) {
01232         unsigned int total = 0;
01233         for( k=0; k<num_cps[j]; k++ ) {
01234           if( unranked_merged[x] > 0 ) {
01235             if( comp_cdds[i]->cps[j][UL_DIV(k)] & ((ulong)0x1 << UL_MOD(k)) ) {
01236               total++;
01237               if( ranked_merged[x] < cp_depth ) {
01238                 unique_found = TRUE;
01239               }
01240             }
01241           }
01242           x++;
01243         }
01244         comp_cdds[i]->score += ((total / (float)comp_cdds[i]->timesteps) * 100) * cdd_type_weight[j];
01245       }
01246       if( (comp_cdds[i]->score > comp_cdds[highest_score]->score) && unique_found ) {
01247         highest_score = i;
01248       }
01249     } 
01250 
01251     /* Store the selected CDD into the next slot of the comp_cdds array */
01252     rank_selected_cdd_cov( comp_cdds, comp_cdd_num, ranked_merged, unranked_merged, next_cdd, highest_score );
01253 
01254     /* Increment the number of unique_cps ranked */
01255     if( comp_cdds[next_cdd]->unique_cps > 0 ) {
01256       (*cdds_ranked)++;
01257     }
01258 
01259   }
01260 
01261   PROFILE_END;
01262 
01263 }

void rank_read_cdd const char *  cdd_name,
bool  required,
bool  first,
comp_cdd_cov ***  comp_cdds,
unsigned int *  comp_cdd_num
[static]
 

Parses the given CDD name and stores its coverage point information in a compressed format.

Parameters:
cdd_name  Filename of CDD file to read in
required  Specifies if CDD file is required to be ranked
first  Set to TRUE if this if the first CDD being read
comp_cdds  Pointer to compressed CDD array
comp_cdd_num  Number of compressed CDD structures in comp_cdds array

01066   { PROFILE(RANK_READ_CDD);
01067 
01068   comp_cdd_cov* comp_cov;
01069 
01070   Try {
01071 
01072     inst_link* instl;
01073     uint64     tmp_nums[CP_TYPE_NUM] = {0};
01074 
01075     /* Read in database */
01076     db_read( cdd_name, READ_MODE_REPORT_NO_MERGE );
01077     bind_perform( TRUE, 0 );
01078 
01079     /* Calculate the num_cps array if we are the first or check our coverage points to verify that they match */
01080     instl = db_list[0]->inst_head;
01081     while( instl != NULL ) {
01082       report_gather_instance_stats( instl->inst );
01083       if( first ) {
01084         rank_calc_num_cps( instl->inst, num_cps );
01085       } else {
01086         rank_calc_num_cps( instl->inst, tmp_nums );
01087       }
01088       instl = instl->next;
01089     }
01090 
01091     /* If we are not the first CDD file being read in, verify that our values match */
01092     if( !first ) {
01093       unsigned int i;
01094       for( i=0; i<CP_TYPE_NUM; i++ ) {
01095         if( num_cps[i] != tmp_nums[i] ) {
01096           unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "CDD file \"%s\" does not match previously read CDD files", cdd_name );
01097           assert( rv < USER_MSG_LENGTH );
01098           print_output( user_msg, FATAL, __FILE__, __LINE__ );
01099           Throw 0;
01100         }
01101       }
01102     }
01103 
01104     /* Allocate the memory needed for the compressed CDD coverage structure */
01105     comp_cov = rank_create_comp_cdd_cov( cdd_name, required, num_timesteps );
01106 
01107     /* Finally, populate compressed CDD coverage structure with coverage information from database signals */
01108     instl = db_list[0]->inst_head;
01109     while( instl != NULL ) {
01110       rank_gather_comp_cdd_cov( instl->inst, comp_cov );
01111       instl = instl->next;
01112     }
01113 
01114     /* Add compressed CDD coverage structure to array */
01115     *comp_cdds = (comp_cdd_cov**)realloc_safe( *comp_cdds, (sizeof( comp_cdd_cov* ) * (*comp_cdd_num)), (sizeof( comp_cdd_cov* ) * (*comp_cdd_num + 1)) );
01116     (*comp_cdds)[*comp_cdd_num] = comp_cov;
01117     (*comp_cdd_num)++;
01118 
01119   } Catch_anonymous {
01120     db_close();
01121     rank_dealloc_comp_cdd_cov( comp_cov );
01122     Throw 0;
01123   }
01124 
01125   /* Close the database */
01126   db_close();
01127 
01128   PROFILE_END;
01129 
01130 }

void rank_selected_cdd_cov comp_cdd_cov **  comp_cdds,
unsigned int  comp_cdd_num,
uint16 ranked_merged,
uint16 unranked_merged,
unsigned int  next_cdd,
unsigned int  selected_cdd
[static]
 

Sorts the selected CDD coverage structure into the comp_cdds list and performs post-placement calculations.

Parameters:
comp_cdds  Pointer to array of compressed CDD coverage structures being sorted
comp_cdd_num  Total number of elements in comp_cdds array
ranked_merged  Array of merged information for ranked CDDs
unranked_merged  Array of merged information for unranked CDDs
next_cdd  Index into comp_cdds array that the selected CDD should be stored at
selected_cdd  Index into comp_cdds array of the selected CDD for ranking

01144   { PROFILE(RANK_SELECTED_CDD_COV);
01145 
01146   unsigned int        i, j;
01147   uint64              merged_index = 0;
01148   static unsigned int dots_output  = 0;
01149   comp_cdd_cov*       tmp;
01150 
01151   /* Output status indicator, if necessary */
01152   if( (!output_suppressed || debug_mode) && !rank_verbose ) {
01153     while( ((unsigned int)(((next_cdd + 1) / (float)comp_cdd_num) * 100) - (dots_output * 10)) >= 10 ) { 
01154       unsigned int rv;
01155       printf( "." );
01156       rv = fflush( stdout );
01157       assert( rv == 0 );
01158       dots_output++;
01159     }
01160   }
01161 
01162   /* Move the most unique CDD to the next position */
01163   tmp                     = comp_cdds[next_cdd];
01164   comp_cdds[next_cdd]     = comp_cdds[selected_cdd];
01165   comp_cdds[selected_cdd] = tmp;
01166 
01167   /* Zero out uniqueness value */
01168   comp_cdds[next_cdd]->unique_cps = 0;
01169 
01170   /* Subtract all of the set coverage points from the merged value */
01171   for( i=0; i<CP_TYPE_NUM; i++ ) {
01172     for( j=0; j<num_cps[i]; j++ ) {
01173       if( unranked_merged[merged_index] > 0 ) {
01174         if( comp_cdds[next_cdd]->cps[i][UL_DIV(j)] & ((ulong)0x1 << UL_MOD(j)) ) {
01175           /*
01176            If we have not seen this coverage point get hit the needed "depth" amount in the ranked
01177            list, increment the unique_cps value for the selected compressed CDD coverage structure.
01178           */
01179           if( ranked_merged[merged_index] < cp_depth ) {
01180             comp_cdds[next_cdd]->unique_cps++;
01181           }
01182           unranked_merged[merged_index]--;
01183           ranked_merged[merged_index]++;
01184         }
01185       }
01186       merged_index++;
01187     }
01188   }
01189 
01190   if( (!output_suppressed || debug_mode) && !rank_verbose ) {
01191     if( (next_cdd + 1) == comp_cdd_num ) {
01192       unsigned int rv;
01193       if( dots_output < 10 ) {
01194         printf( "." );
01195       }
01196       printf( "\n" );
01197       rv = fflush( stdout );
01198       assert( rv == 0 );
01199     }
01200   }
01201 
01202   PROFILE_END;
01203 
01204 }

void rank_usage  )  [static]
 

Outputs usage information to standard output for rank command.

00231                          {
00232 
00233   printf( "\n" );
00234   printf( "Usage:  covered rank (-h | ([<options>] <database_to_rank> <database_to_rank>+)\n" );
00235   printf( "\n" );
00236   printf( "   -h                           Displays this help information.\n" );
00237   printf( "\n" );
00238   printf( "   Options:\n" );
00239   printf( "      -depth <number>           Specifies the minimum number of CDD files to hit each coverage point.\n" );
00240   printf( "                                  The value of <number> should be a value of 1 or more.  Default is 1.\n" );
00241   printf( "      -names-only               If specified, outputs only the needed CDD filenames that need to be\n" );
00242   printf( "                                  run in the order they need to be run.  If this option is not set, a\n" );
00243   printf( "                                  report-style output is provided with additional information.\n" );
00244   printf( "      -f <filename>             Name of file containing additional arguments to parse.\n" );
00245   printf( "      -required-list <filename> Name of file containing list of CDD files which are required to be in the\n" );
00246   printf( "                                  list of ranked CDDs to be run.\n" );
00247   printf( "      -required-cdd <filename>  Name of CDD file that is required to be in the list of ranked CDDs to be run.\n" );
00248   printf( "      -d <directory>            Directory to search for CDD files to include.  This option is used in\n" );
00249   printf( "                                  conjunction with the -ext option which specifies the file extension\n" );
00250   printf( "                                  to use for determining which files in the directory are CDD files.\n" );
00251   printf( "      -ext <extension>          Used in conjunction with the -d option.  If no -ext options are specified\n" );
00252   printf( "                                  on the command-line, the default value of '.cdd' is used.  Note that\n" );
00253   printf( "                                  a period (.) should be specified.\n" );
00254   printf( "      -o <filename>             Name of file to output ranking information to.  Default is stdout.\n" );
00255   printf( "      -weight-line <number>     Specifies a relative weighting for line coverage used to rank\n" );
00256   printf( "                                  non-unique coverage points.  A value of 0 removes line coverage\n" );
00257   printf( "                                  from ranking consideration.  Default value is 1.\n" );
00258   printf( "      -weight-toggle <number>   Specifies a relative weighting for toggle coverage used to rank\n" );
00259   printf( "                                  non-unique coverage points.  A value of 0 removes toggle coverage\n" );
00260   printf( "                                  from ranking consideration.  Default value is 1.\n" );
00261   printf( "      -weight-memory <number>   Specifies a relative weighting for memory coverage used to rank\n" );
00262   printf( "                                  non-unique coverage points.  A value of 0 removes memory coverage\n" );
00263   printf( "                                  from ranking consideration.  Default value is 1.\n" );
00264   printf( "      -weight-comb <number>     Specifies a relative weighting for combinational logic coverage used\n" );
00265   printf( "                                  to rank non-unique coverage points.  A value of 0 removes combinational\n" );
00266   printf( "                                  logic coverage from ranking consideration.  Default value is 1.\n" );
00267   printf( "      -weight-fsm <number>      Specifies a relative weighting for FSM state/state transition coverage\n" );
00268   printf( "                                  used to rank non-unique coverage points.  A value of 0 removes FSM\n" );
00269   printf( "                                  coverage from ranking consideration.  Default value is 1.\n" );
00270   printf( "      -weight-assert <number>   Specifies a relative weighting for assertion coverage used to rank\n" );
00271   printf( "                                  non-unique coverage points.  A value of 0 removes assertion coverage\n" );
00272   printf( "                                  from ranking consideration.  Default value is 0.\n" );
00273   printf( "      -v                        Outputs verbose information during the rank selection process.  This output\n" );
00274   printf( "                                  is not for debugging purposes, but rather gives the user insight into\n" );
00275   printf( "                                  what's going on \"behind the scenes\" during the ranking process.\n" );
00276   printf( "\n" );
00277 
00278 }


Variable Documentation

bool allow_multi_expr
 

Controls whether multi-expressions are used or not.

bool cdd_type_set[CP_TYPE_NUM] = {0} [static]
 

Set to TRUE when the user has specified the corresponding weight value on the command-line. Allows us to display a warning message to the user when multiple values are specified.

unsigned int cdd_type_weight[CP_TYPE_NUM] = {1,1,1,1,1,0} [static]
 

Array containing the weights to be used for each of the CDD metric types.

unsigned int cp_depth = 0 [static]
 

Specifies the number of CDDs that must hit each coverage point before a CDD will be considered unneeded.

db** db_list
 

Array of database pointers storing all currently loaded databases.

bool debug_mode
 

If set to TRUE, causes debug information to be spewed to screen.

const exp_info exp_op_info[EXP_OP_NUM]
 

Array containing static information about expression operation types. NOTE: This structure MUST be updated if a new expression is added! The third argument is an initialization to the exp_info_s structure.

bool flag_names_only = FALSE [static]
 

If set to TRUE, outputs only the names of the CDD files in the order that they should be run. This value is set to TRUE when the -names_only option is specified.

int64 largest_malloc_size
 

Holds the largest number of bytes in allocation at one period of time.

unsigned int longest_name_len = 0 [static]
 

Specifies the string length of the longest CDD name

uint64 num_cps[CP_TYPE_NUM] = {0} [static]
 

Array containing the number of coverage points for each metric for all compressed CDD coverage structures.

uint64 num_timesteps
 

Specifies the number of timesteps that have transpired during this simulation.

bool output_suppressed
 

If set to TRUE, suppresses all non-fatal error messages from being displayed.

char* rank_file = NULL [static]
 

File to be used for outputting rank information.

str_link* rank_in_head = NULL [static]
 

Pointer to head of list of CDD filenames that need to be read in.

str_link* rank_in_tail = NULL [static]
 

Pointer to tail of list of CDD filenames that need to be read in.

bool rank_verbose = FALSE [static]
 

If set to TRUE, outputs behind the scenes output during the rank selection process.

bool report_assertion
 

If set to a boolean value of TRUE, reports the assertion coverage for the specified database file; otherwise, omits assertion coverage from the report output.

bool report_combination
 

If set to a boolean value of TRUE, reports the combinational logic coverage for the specified database file; otherwise, omits combinational logic coverage from the report output.

bool report_fsm
 

If set to a boolean value of TRUE, reports the finite state machine coverage for the specified database file; otherwise, omits finite state machine coverage from the report output.

bool report_line
 

If set to a boolean value of TRUE, reports the line coverage for the specified database file; otherwise, omits line coverage from the report output.

bool report_memory
 

If set to a boolean value of TRUE, reports the memory coverage for the specified database file; otherwise, omits memory coverage from the report output.

bool report_toggle
 

If set to a boolean value of TRUE, reports the toggle coverage for the specified database file; otherwise, omits toggle coverage from the report output.

char user_msg[USER_MSG_LENGTH]
 

Holds some output that will be displayed via the print_output command. This is created globally so that memory does not need to be reallocated for each function that wishes to use it.


Generated on Wed Jun 17 22:19:23 2009 for Covered by doxygen 1.3.4