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

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


Detailed Description

Author:
Trevor Williams (phase1geo@gmail.com)
Date:
3/31/2002
What is an FSM?
An Finite State Machine (FSM) consists of basically three elements:
  1. Pointer to an input state expression
  2. Pointer to an output state expression
  3. Pointer to an FSM arc (please see arc.c for more information)

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "arc.h"
#include "binding.h"
#include "codegen.h"
#include "db.h"
#include "defines.h"
#include "exclude.h"
#include "expr.h"
#include "func_unit.h"
#include "fsm.h"
#include "link.h"
#include "obfuscate.h"
#include "ovl.h"
#include "report.h"
#include "sim.h"
#include "util.h"
#include "vector.h"

Functions

fsmfsm_create (expression *from_state, expression *to_state, bool exclude)
 Creates and initializes new FSM structure.

void fsm_add_arc (fsm *table, expression *from_state, expression *to_state)
 Adds new FSM arc structure to specified FSMs arc list.

void fsm_create_tables (fsm *table)
 Sets sizes of tables in specified FSM structure.

void fsm_db_write (fsm *table, FILE *file, bool ids_issued)
 Outputs contents of specified FSM to CDD file.

void fsm_db_read (char **line, func_unit *funit)
 Reads in contents of specified FSM.

void fsm_db_merge (fsm *base, char **line)
 Reads and merges two FSMs, placing result into base FSM.

void fsm_merge (fsm *base, fsm *other)
 Merges two FSMs, placing the result into the base FSM.

void fsm_table_set (expression *expr, const sim_time *time)
 Sets the bit in set table based on the values of last and curr.

void fsm_get_stats (fsm_link *table, int *state_hit, int *state_total, int *arc_hit, int *arc_total, int *arc_excluded)
 Gathers statistics about the current FSM.

void fsm_get_funit_summary (func_unit *funit, int *hit, int *excluded, int *total)
 Retrieves the FSM summary information for the specified functional unit.

void fsm_get_inst_summary (funit_inst *inst, int *hit, int *excluded, int *total)
 Retrieves the FSM summary information for the specified functional unit.

void fsm_gather_signals (expression *expr, sig_link **head, sig_link **tail, int expr_id, int **expr_ids, int *expr_id_size)
void fsm_collect (func_unit *funit, int cov, sig_link **sig_head, sig_link **sig_tail, int **expr_ids, int **excludes)
 Retrieves covered or uncovered FSMs from the specified functional unit.

void fsm_get_coverage (func_unit *funit, int expr_id, char ***total_fr_states, unsigned int *total_fr_state_num, char ***total_to_states, unsigned int *total_to_state_num, char ***hit_fr_states, unsigned int *hit_fr_state_num, char ***hit_to_states, unsigned int *hit_to_state_num, char ***total_from_arcs, char ***total_to_arcs, int **total_ids, int **excludes, char ***reasons, int *total_arc_num, char ***hit_from_arcs, char ***hit_to_arcs, int *hit_arc_num, char ***input_state, unsigned int *input_size, char ***output_state, unsigned int *output_size)
 Collects all coverage information for the specified FSM.

bool fsm_display_instance_summary (FILE *ofile, const char *name, int state_hit, int state_total, int arc_hit, int arc_total)
bool fsm_instance_summary (FILE *ofile, funit_inst *root, char *parent_inst, int *state_hits, int *state_total, int *arc_hits, int *arc_total)
bool fsm_display_funit_summary (FILE *ofile, const char *name, const char *fname, int state_hits, int state_total, int arc_hits, int arc_total)
bool fsm_funit_summary (FILE *ofile, funit_link *head, int *state_hits, int *state_total, int *arc_hits, int *arc_total)
void fsm_display_state_verbose (FILE *ofile, fsm *table)
bool fsm_display_arc_verbose (FILE *ofile, fsm *table, func_unit *funit, rpt_type rtype)
void fsm_display_verbose (FILE *ofile, func_unit *funit)
void fsm_instance_verbose (FILE *ofile, funit_inst *root, char *parent_inst)
void fsm_funit_verbose (FILE *ofile, funit_link *head)
void fsm_report (FILE *ofile, bool verbose)
 Generates report output for FSM coverage.

void fsm_dealloc (fsm *table)
 Deallocates specified FSM structure.


Variables

db ** db_list
unsigned int curr_db
bool report_covered
unsigned int report_comb_depth
bool report_instance
char user_msg [USER_MSG_LENGTH]
isuppl info_suppl
bool report_exclusions
bool flag_output_exclusion_ids


Function Documentation

void fsm_add_arc fsm table,
expression from_state,
expression to_state
 

Adds new FSM arc structure to specified FSMs arc list.

Adds new FSM arc structure to specified FSMs arc list.

Parameters:
table  Pointer to FSM structure to add new arc to
from_state  Pointer to from_state expression to add
to_state  Pointer to to_state expression to add

00101   { PROFILE(FSM_ADD_ARC);
00102 
00103   fsm_arc* arc;  /* Pointer to newly created FSM arc structure */
00104 
00105   /* Create an initialize specified arc */
00106   arc             = (fsm_arc*)malloc_safe( sizeof( fsm_arc ) );
00107   arc->from_state = from_state;
00108   arc->to_state   = to_state;
00109   arc->next       = NULL;
00110 
00111   /* Add new arc to specified FSM structure */
00112   if( table->arc_head == NULL ) {
00113     table->arc_head = table->arc_tail = arc;
00114   } else {
00115     table->arc_tail->next = arc;
00116     table->arc_tail       = arc;
00117   }
00118 
00119   PROFILE_END;
00120 
00121 }

void fsm_collect func_unit funit,
int  cov,
sig_link **  sig_head,
sig_link **  sig_tail,
int **  expr_ids,
int **  excludes
 

Retrieves covered or uncovered FSMs from the specified functional unit.

Gathers the covered or uncovered FSM information, storing their expressions in the sig_head/sig_tail signal list. Used by the GUI for verbose FSM output.

Parameters:
funit  Pointer to functional unit
cov  Specifies if we are attempting to get uncovered (0) or covered (1) FSMs
sig_head  Pointer to the head of the signal list of covered FSM output states
sig_tail  Pointer to the tail of the signal list of covered FSM output states
expr_ids  Pointer to array of expression IDs for each uncovered signal
excludes  Pointer to array of exclude values for each uncovered signal

00514   { PROFILE(FSM_COLLECT);
00515 
00516   fsm_link* curr_fsm;  /* Pointer to current FSM link being evaluated */
00517   int       size = 0;  /* Number of expressions IDs stored in expr_ids array */
00518 
00519   /* Initialize list pointers */
00520   *sig_tail = *sig_head = NULL;
00521   *expr_ids = *excludes = NULL;
00522 
00523   curr_fsm = funit->fsm_head;
00524   while( curr_fsm != NULL ) {
00525 
00526     /* Get the state and arc statistics */
00527     int state_hit    = 0;
00528     int state_total  = 0;
00529     int arc_hit      = 0;
00530     int arc_total    = 0;
00531     int arc_excluded = 0;
00532     arc_get_stats( curr_fsm->table->table, &state_hit, &state_total, &arc_hit, &arc_total, &arc_excluded );
00533 
00534     /* Allocate some more memory for the excluded array */
00535     *excludes = (int*)realloc_safe( *excludes, (sizeof( int ) * size), (sizeof( int ) * (size + 1)) );
00536 
00537     /* If the total number of arcs is not known, consider this FSM as uncovered */
00538     if( (cov == 0) && ((arc_total == -1) || (arc_total != arc_hit)) ) {
00539       (*excludes)[size] = 0;
00540       fsm_gather_signals( curr_fsm->table->to_state, sig_head, sig_tail, curr_fsm->table->to_state->id, expr_ids, &size );
00541     } else {
00542       if( (cov == 0) && arc_are_any_excluded( curr_fsm->table->table ) ) {
00543         fsm_gather_signals( curr_fsm->table->to_state, sig_head, sig_tail, curr_fsm->table->to_state->id, expr_ids, &size );
00544         (*excludes)[size] = 1;
00545       } else if( cov == 1 ) {
00546         fsm_gather_signals( curr_fsm->table->to_state, sig_head, sig_tail, -1, expr_ids, &size );
00547       }
00548     }
00549 
00550     curr_fsm = curr_fsm->next;
00551 
00552   }
00553 
00554   PROFILE_END;
00555 
00556 }

fsm* fsm_create expression from_state,
expression to_state,
bool  exclude
 

Creates and initializes new FSM structure.

Returns:
Returns a pointer to the newly allocated FSM structure.
Allocates and initializes an FSM structure.
Parameters:
from_state  Pointer to expression that is input state variable for this FSM
to_state  Pointer to expression that is output state variable for this FSM
exclude  Value to set the exclude bit to

00077   { PROFILE(FSM_CREATE);
00078 
00079   fsm* table;  /* Pointer to newly created FSM */
00080 
00081   table             = (fsm*)malloc_safe( sizeof( fsm ) );
00082   table->name       = NULL;
00083   table->from_state = from_state;
00084   table->to_state   = to_state;
00085   table->arc_head   = NULL;
00086   table->arc_tail   = NULL;
00087   table->table      = NULL;
00088   table->exclude    = exclude;
00089 
00090   return( table );
00091 
00092 }

void fsm_create_tables fsm table  ) 
 

Sets sizes of tables in specified FSM structure.

After the FSM signals are sized, this function is called to size an FSM structure (allocate memory for its tables) and the associated FSM arc list is parsed, setting the appropriate bit in the valid table.

Parameters:
table  Pointer to FSM structure to set table sizes to

00130   { PROFILE(FSM_CREATE_TABLES);
00131 
00132   fsm_arc* curr_arc;    /* Pointer to current FSM arc structure */
00133   bool     set = TRUE;  /* Specifies if specified bit was set */
00134   sim_time time;        /* Current simulation time */
00135 
00136   /* Create the FSM arc transition table */
00137   assert( table != NULL );
00138   assert( table->to_state != NULL );
00139   assert( table->to_state->value != NULL );
00140   assert( table->table == NULL );
00141   table->table = arc_create( table->to_state->value->width );
00142 
00143   /* Initialize the current time */
00144   time.lo    = 0;
00145   time.hi    = 0;
00146   time.full  = 0;
00147   time.final = FALSE;
00148 
00149   /* Set valid table */
00150   curr_arc = table->arc_head;
00151   while( (curr_arc != NULL) && set ) {
00152 
00153     /* Evaluate from and to state expressions */
00154     (void)expression_operate( curr_arc->from_state, NULL, &time );
00155     (void)expression_operate( curr_arc->to_state, NULL, &time );
00156 
00157     /* Set table entry in table, if possible */
00158     arc_add( table->table, curr_arc->from_state->value, curr_arc->to_state->value, 0, table->exclude );
00159 
00160     curr_arc = curr_arc->next;
00161 
00162   } 
00163 
00164   PROFILE_END;
00165 
00166 }

void fsm_db_merge fsm base,
char **  line
 

Reads and merges two FSMs, placing result into base FSM.

Parameters:
base Pointer to FSM structure to merge data into.
line Pointer to read in line from CDD file to merge.
Exceptions:
anonymous arc_db_merge Throw
Parses specified line for FSM information and performs merge of the base and in FSMs, placing the resulting merged FSM into the base signal. If the FSMs are found to be unalike (names are different), an error message is displayed to the user. If both FSMs are the same, perform the merge on the FSM's tables.

00312   { PROFILE(FSM_DB_MERGE);
00313 
00314   int iid;         /* Input state variable expression ID */
00315   int oid;         /* Output state variable expression ID */
00316   int chars_read;  /* Number of characters read from line */
00317   int is_table;    /* Holds value of is_table signifier */
00318 
00319   assert( base != NULL );
00320   assert( base->from_state != NULL );
00321   assert( base->to_state != NULL );
00322 
00323   if( sscanf( *line, "%d %d %d%n", &iid, &oid, &is_table, &chars_read ) == 3 ) {
00324 
00325     *line = *line + chars_read + 1;
00326 
00327     if( is_table == 1 ) {
00328 
00329       arc_db_merge( base->table, line );
00330           
00331     }
00332 
00333   } else {
00334 
00335     print_output( "Database being merged is not compatible with the original database.", FATAL, __FILE__, __LINE__ );
00336     Throw 0;
00337 
00338   }
00339 
00340   PROFILE_END;
00341 
00342 }

void fsm_db_read char **  line,
func_unit funit
 

Reads in contents of specified FSM.

Parameters:
line Pointer to current line being read from the CDD file.
funit Pointer to current functional unit.
Exceptions:
anonymous expression_create Throw Throw Throw Throw arc_db_read
Reads in contents of FSM line from CDD file and stores newly created FSM into the specified functional unit.

00212                                                   { PROFILE(FSM_DB_READ);
00213 
00214   int        iexp_id;        /* Input expression ID */
00215   int        oexp_id;        /* Output expression ID */
00216   exp_link*  iexpl;          /* Pointer to found state variable */
00217   exp_link*  oexpl;          /* Pointer to found state variable */
00218   int        chars_read;     /* Number of characters read from sscanf */
00219   fsm*       table;          /* Pointer to newly created FSM structure from CDD */
00220   int        is_table;       /* Holds value of is_table entry of FSM output */
00221  
00222   if( sscanf( *line, "%d %d %d%n", &iexp_id, &oexp_id, &is_table, &chars_read ) == 3 ) {
00223 
00224     *line = *line + chars_read + 1;
00225 
00226     if( funit == NULL ) {
00227 
00228       print_output( "Internal error:  FSM in database written before its functional unit", FATAL, __FILE__, __LINE__ );
00229       Throw 0;
00230 
00231     } else {
00232 
00233       /* Find specified signal */
00234       if( ((iexpl = exp_link_find( iexp_id, funit->exp_head )) != NULL) &&
00235           ((oexpl = exp_link_find( oexp_id, funit->exp_head )) != NULL) ) {
00236 
00237         /* Create new FSM */
00238         table = fsm_create( iexpl->exp, oexpl->exp, FALSE );
00239 
00240         /*
00241          If the input state variable is the same as the output state variable, create the new expression now.
00242         */
00243         if( iexp_id == oexp_id ) {
00244           Try {
00245             table->from_state = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, iexp_id, 0, 0, 0, FALSE );
00246           } Catch_anonymous {
00247             fsm_dealloc( table );
00248             Throw 0;
00249           }
00250           vector_dealloc( table->from_state->value );
00251           bind_append_fsm_expr( table->from_state, iexpl->exp, funit );
00252         } else {
00253           table->from_state = iexpl->exp;
00254         }
00255 
00256         /* Set input/output expression tables to point to this FSM */
00257         table->from_state->table = table;
00258         table->to_state->table   = table;
00259   
00260         /* Now read in set table */
00261         if( is_table == 1 ) {
00262 
00263           Try {
00264             arc_db_read( &(table->table), line );
00265           } Catch_anonymous {
00266             fsm_dealloc( table );
00267             Throw 0;
00268           }
00269 
00270         }
00271 
00272         /* Add fsm to current functional unit */
00273         fsm_link_add( table, &(funit->fsm_head), &(funit->fsm_tail) );
00274  
00275       } else {
00276 
00277         unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Unable to find state variable expressions (%d, %d) for current FSM", iexp_id, oexp_id );
00278         assert( rv < USER_MSG_LENGTH );
00279         print_output( user_msg, FATAL, __FILE__, __LINE__ );
00280         Throw 0;
00281 
00282       }
00283 
00284     }
00285 
00286   } else {
00287 
00288     print_output( "Unable to parse FSM line in database file.  Unable to read.", FATAL, __FILE__, __LINE__ );
00289     Throw 0;
00290 
00291   }
00292 
00293   PROFILE_END;
00294 
00295 }

void fsm_db_write fsm table,
FILE *  file,
bool  ids_issued
 

Outputs contents of specified FSM to CDD file.

Outputs the contents of the specified FSM to the specified CDD file.

Parameters:
table  Pointer to FSM structure to output
file  Pointer to file output stream to write to
ids_issued  Set to TRUE if expression IDs were just issued

00175   { PROFILE(FSM_DB_WRITE);
00176 
00177   fprintf( file, "%d %d %d ",
00178     DB_TYPE_FSM,
00179     expression_get_id( table->from_state, ids_issued ),
00180     expression_get_id( table->to_state, ids_issued )
00181   );
00182 
00183   /* Print set table */
00184   if( table->table != NULL ) {
00185     fprintf( file, "1 " );
00186     arc_db_write( table->table, file );
00187 
00188     /* Deallocate the given table after writing it */
00189     if( table->table != NULL ) {
00190       arc_dealloc( table->table );
00191       table->table = NULL;
00192     }
00193   } else {
00194     fprintf( file, "0" );
00195   }
00196 
00197   fprintf( file, "\n" );
00198 
00199   PROFILE_END;
00200 
00201 } 

void fsm_dealloc fsm table  ) 
 

Deallocates specified FSM structure.

Deallocates all allocated memory for the specified FSM structure.

Parameters:
table  Pointer to FSM structure to deallocate

01269   { PROFILE(FSM_DEALLOC);
01270 
01271   fsm_arc* tmp;  /* Temporary pointer to current FSM arc structure to deallocate */
01272 
01273   if( table != NULL ) {
01274 
01275     /* Free name if one was specified */
01276     if( table->name != NULL ) {
01277       free_safe( table->name, (strlen( table->name ) + 1) );
01278     }
01279 
01280     /* Deallocate tables */
01281     arc_dealloc( table->table );
01282 
01283     /* Deallocate FSM arc structure */
01284     while( table->arc_head != NULL ) {
01285       tmp = table->arc_head;
01286       table->arc_head = table->arc_head->next;
01287       expression_dealloc( tmp->to_state, FALSE );
01288       expression_dealloc( tmp->from_state, FALSE );
01289       free_safe( tmp, sizeof( fsm_arc ) );
01290     }
01291 
01292     /*
01293      Deallocate from_state if it is the same expression ID as the to_state expression and is
01294      not the same expression structure
01295     */
01296     if( (table->from_state != NULL)             &&
01297         (table->to_state != NULL)               &&
01298         (table->from_state != table->to_state ) &&
01299         (table->from_state->id == table->to_state->id) ) {
01300       expression_dealloc( table->from_state, FALSE );
01301     }
01302 
01303     /* Deallocate this structure */
01304     free_safe( table, sizeof( fsm ) );
01305       
01306   }
01307 
01308   PROFILE_END;
01309 
01310 }

bool fsm_display_arc_verbose FILE *  ofile,
fsm table,
func_unit funit,
rpt_type  rtype
[static]
 

Returns:
Returns TRUE if at least one arc transition was excluded.
Displays verbose information for hit/missed state transitions to the specified output file.
Parameters:
ofile  File handle of output file to send report output to
table  Pointer to FSM structure to output
funit  Pointer to functional unit containing this FSM
rtype  Specifies the type of report to generate

00902   { PROFILE(FSM_DISPLAY_ARC_VERBOSE);
00903 
00904   bool         retval = FALSE;  /* Return value for this function */
00905   bool         trans_unknown;   /* Set to TRUE if the number of state transitions is known */
00906   char         fstr[100];       /* Format string */
00907   char         tmp[20];         /* Temporary string */
00908   int          width;           /* Width (in characters) of the entire output value */
00909   int          val_width;       /* Number of bits in output state expression */
00910   int          len_width;       /* Number of characters needed to store the width of the output state expression */
00911   char**       from_states;     /* String array containing from_state information */
00912   char**       to_states;       /* String array containing to_state information */
00913   int*         ids;             /* List of exclusion IDs per from/to state transition */
00914   int*         excludes;        /* List of excluded arcs */
00915   char**       reasons;         /* Exclusion reasons */
00916   int          arc_size;        /* Number of elements in the from_states and to_states arrays */
00917   int          i;               /* Loop iterator */
00918   char         tmpfst[4096];    /* Temporary string holder for from_state value */
00919   char         tmptst[4096];    /* Temporary string holder for to_state value */
00920   unsigned int rv;              /* Return value from snprintf calls */
00921   char         spaces[30];      /* Placeholder for spaces */
00922   unsigned int eid_size;
00923   char*        eid;
00924 
00925   /* Figure out if transactions were known */
00926   trans_unknown = (table->table->suppl.part.known == 0);
00927 
00928   spaces[0] = '\0';
00929 
00930   if( (rtype == RPT_TYPE_HIT) || trans_unknown ) {
00931     fprintf( ofile, "        Hit State Transitions\n\n" );
00932   } else if( rtype == RPT_TYPE_MISS ) {
00933     fprintf( ofile, "        Missed State Transitions\n\n" );
00934   } else if( rtype == RPT_TYPE_EXCL ) {
00935     fprintf( ofile, "        Excluded State Transitions\n\n" );
00936   }
00937 
00938   val_width = table->to_state->value->width;
00939 
00940   /* Calculate width of length string */
00941   rv = snprintf( tmp, 20, "%d", val_width );
00942   assert( rv < 20 );
00943   len_width = strlen( tmp );
00944 
00945   /* Create format string to hold largest output value */
00946   width = ((val_width % 4) == 0) ? (val_width / 4) : ((val_width / 4) + 1);
00947   width = width + len_width + 2;
00948   width = (width > 10) ? width : 10;
00949 
00950   /* Generate format string */
00951   rv = snprintf( fstr, 100, "          %%s%%-%d.%ds %%s %%-%d.%ds\n", width, width, width, width );
00952   assert( rv < 100 );
00953 
00954   if( flag_output_exclusion_ids && (rtype != RPT_TYPE_HIT) && !trans_unknown ) {
00955     gen_char_string( spaces, ' ', ((db_get_exclusion_id_size() - 1) + 4) );
00956     eid_size = db_get_exclusion_id_size() + 4;
00957     eid      = (char*)malloc_safe( eid_size );
00958   } else {
00959     eid_size = 1;
00960     eid      = (char*)malloc_safe( eid_size );
00961     eid[0]   = '\0';
00962   }
00963 
00964   fprintf( ofile, fstr, spaces, "From State", "  ", "To State" );
00965   fprintf( ofile, fstr, spaces, "==========", "  ", "==========" );
00966 
00967   /* Get the state transition information */
00968   arc_get_transitions( &from_states, &to_states, &ids, &excludes, &reasons, &arc_size, table->table, funit, ((rtype == RPT_TYPE_HIT) || trans_unknown), FALSE );
00969 
00970   /* Output the information to the specified output stream */
00971   for( i=0; i<arc_size; i++ ) {
00972     exclude_reason* er;
00973     retval |= excludes[i];
00974     if( ((rtype != RPT_TYPE_EXCL) && (excludes[i] == 0)) ||
00975         ((rtype == RPT_TYPE_EXCL) && (excludes[i] == 1)) ) {
00976       rv = snprintf( tmpfst, 4096, "%s", from_states[i] );
00977       assert( rv < 4096 );
00978       rv = snprintf( tmptst, 4096, "%s", to_states[i] );
00979       assert( rv < 4096 );
00980       if( flag_output_exclusion_ids && (rtype != RPT_TYPE_HIT) && !trans_unknown ) {
00981         rv = snprintf( eid, eid_size, "(%s)  ", db_gen_exclusion_id( 'F', ids[i] ) );
00982         assert( rv < eid_size );
00983       }
00984       fprintf( ofile, fstr, eid, tmpfst, "->", tmptst );
00985     }
00986     if( (rtype == RPT_TYPE_EXCL) && (reasons[i] != NULL) ) {
00987       if( flag_output_exclusion_ids ) {
00988         report_output_exclusion_reason( ofile, (16 + (db_get_exclusion_id_size() - 1)), reasons[i], TRUE );
00989       } else {
00990         report_output_exclusion_reason( ofile, 12, reasons[i], TRUE );
00991       }
00992     }
00993     free_safe( from_states[i], (strlen( from_states[i] ) + 1) );
00994     free_safe( to_states[i], (strlen( to_states[i] ) + 1) );
00995     free_safe( reasons[i], (strlen( reasons[i] ) + 1) );
00996   }
00997 
00998   fprintf( ofile, "\n" );
00999 
01000   /* Deallocate memory */
01001   if( arc_size > 0 ) {
01002     free_safe( from_states, (sizeof( char* ) * arc_size) );
01003     free_safe( to_states, (sizeof( char* ) * arc_size) );
01004     free_safe( ids, (sizeof( int ) * arc_size) );
01005     free_safe( excludes, (sizeof( int ) * arc_size) );
01006     free_safe( reasons, (sizeof( char* ) * arc_size) );
01007   }
01008   free_safe( eid, eid_size );
01009 
01010   PROFILE_END;
01011 
01012   return( retval );
01013 
01014 }

bool fsm_display_funit_summary FILE *  ofile,
const char *  name,
const char *  fname,
int  state_hits,
int  state_total,
int  arc_hits,
int  arc_total
[static]
 

Returns:
Returns TRUE if at least one FSM state or FSM arc was missed during simulation for this functional unit; otherwise, returns FALSE.
Outputs the summary FSM state/arc information for a given functional unit to the given output stream.
Parameters:
ofile  Pointer to file stream to output summary information to
name  Name of functional unit being reported
fname  Filename containing the functional unit being reported
state_hits  Number of FSM states that were hit in this functional unit during simulation
state_total  Number of total FSM states that exist in the given functional unit
arc_hits  Number of FSM arcs that were hit in this functional unit during simulation
arc_total  Number of total FSM arcs that exist in the given functional unit

00754   { PROFILE(FSM_DISPLAY_FUNIT_SUMMARY);
00755 
00756   float state_percent;  /* Percentage of states hit */
00757   float arc_percent;    /* Percentage of arcs hit */
00758   int   state_miss;     /* Number of states missed */
00759   int   arc_miss;       /* Number of arcs missed */
00760 
00761   if( (state_total == -1) || (arc_total == -1) ) {
00762     fprintf( ofile, "  %-20.20s    %-20.20s   %4d/  ? /  ?        ? %%         %4d/  ? /  ?        ? %%\n",
00763              name, fname, state_hits, arc_hits );
00764     state_miss = arc_miss = 1;
00765   } else {
00766     calc_miss_percent( state_hits, state_total, &state_miss, &state_percent );
00767     calc_miss_percent( arc_hits, arc_total, &arc_miss, &arc_percent );
00768     fprintf( ofile, "  %-20.20s    %-20.20s   %4d/%4d/%4d      %3.0f%%         %4d/%4d/%4d      %3.0f%%\n",
00769              name, fname, state_hits, state_miss, state_total, state_percent, arc_hits, arc_miss, arc_total, arc_percent );
00770   }
00771 
00772   PROFILE_END;
00773 
00774   return( (state_miss > 0) || (arc_miss > 0) );
00775 
00776 }

bool fsm_display_instance_summary FILE *  ofile,
const char *  name,
int  state_hit,
int  state_total,
int  arc_hit,
int  arc_total
[static]
 

Returns:
Returns TRUE if at least one FSM state or FSM state transition was found to be missed
Calculates and displays the FSM state and state transition instance summary information for the given instance.
Parameters:
ofile  Pointer to output file to write data to
name  Name of instance to display
state_hit  Number of FSM states hit in the given instance
state_total  Total number of FSM states in the given instance
arc_hit  Number of FSM state transitions in the given instance
arc_total  Total number of FSM state transitions in the given instance

00642   { PROFILE(FSM_DISPLAY_INSTANCE_SUMMARY);
00643 
00644   float state_percent;  /* Percentage of states hit */
00645   float arc_percent;    /* Percentage of arcs hit */
00646   int   state_miss;     /* Number of states missed */
00647   int   arc_miss;       /* Number of arcs missed */
00648 
00649   if( (state_total == -1) || (arc_total == -1) ) {
00650     fprintf( ofile, "  %-43.43s    %4d/  ? /  ?        ? %%         %4d/  ? /  ?        ? %%\n",
00651              name, state_hit, arc_hit );
00652     state_miss = arc_miss = 1;
00653   } else {
00654     calc_miss_percent( state_hit, state_total, &state_miss, &state_percent );
00655     calc_miss_percent( arc_hit, arc_total, &arc_miss, &arc_percent );
00656     fprintf( ofile, "  %-43.43s    %4d/%4d/%4d      %3.0f%%         %4d/%4d/%4d      %3.0f%%\n",
00657              name, state_hit, state_miss, state_total, state_percent, arc_hit, arc_miss, arc_total, arc_percent );
00658   }
00659 
00660   PROFILE_END;
00661 
00662   return( (state_miss > 0) || (arc_miss > 0) );
00663 
00664 }

void fsm_display_state_verbose FILE *  ofile,
fsm table
[static]
 

Displays verbose information for hit/missed states to the specified output file.

Parameters:
ofile  File handle of output file to send report output to
table  Pointer to FSM structure to output

00843   { PROFILE(FSM_DISPLAY_STATE_VERBOSE);
00844 
00845   bool         trans_unknown;  /* Set to TRUE if legal arc transitions are unknown */
00846   char**       fr_states;      /* String array of all from states */
00847   unsigned int fr_state_size;  /* Contains the number of elements in the fr_states array */
00848   char**       to_states;      /* String array of all to states */
00849   unsigned int to_state_size;  /* Contains the number of elements in the to_states array */
00850   unsigned int i;              /* Loop iterator */
00851 
00852   /* Figure out if transitions were unknown */
00853   trans_unknown = (table->table->suppl.part.known == 0);
00854 
00855   if( report_covered || trans_unknown ) {
00856     fprintf( ofile, "        Hit States\n\n" );
00857   } else {
00858     fprintf( ofile, "        Missed States\n\n" );
00859   }
00860 
00861   /* Create format string */
00862   fprintf( ofile, "          States\n" );
00863   fprintf( ofile, "          ======\n" );
00864 
00865   /* Get all of the states in string form */
00866   arc_get_states( &fr_states, &fr_state_size, &to_states, &to_state_size, table->table, (report_covered || trans_unknown), FALSE );
00867 
00868   /* Display all of the found states */
00869   for( i=0; i<fr_state_size; i++ ) {
00870     fprintf( ofile, "          %s\n", fr_states[i] );
00871     free_safe( fr_states[i], (strlen( fr_states[i] ) + 1) );
00872   }
00873 
00874   fprintf( ofile, "\n" );
00875 
00876   /* Deallocate the states array */
00877   if( fr_state_size > 0 ) {
00878     free_safe( fr_states, (sizeof( char* ) * fr_state_size) );
00879   }
00880   if( to_state_size > 0 ) {
00881     for( i=0; i<to_state_size; i++ ) {
00882       free_safe( to_states[i], (strlen( to_states[i] ) + 1) );
00883     }
00884     free_safe( to_states, (sizeof( char* ) * to_state_size) );
00885   }
00886 
00887   PROFILE_END;
00888 
00889 }

void fsm_display_verbose FILE *  ofile,
func_unit funit
[static]
 

Displays the verbose FSM state and state transition information to the specified output file.

Parameters:
ofile  File handle of output file to send report output to
funit  Pointer to functional unit containing the FSMs to display

01023   { PROFILE(FSM_DISPLAY_VERBOSE);
01024 
01025   fsm_link*    head;         /* Pointer to current FSM link */
01026   char**       icode;        /* Verilog output of input state variable expression */
01027   unsigned int icode_depth;  /* Number of valid entries in the icode array */
01028   char**       ocode;        /* Verilog output of output state variable expression */
01029   unsigned int ocode_depth;  /* Number of valid entries in the ocode array */
01030   unsigned int i;            /* Loop iterator */
01031 
01032   head = funit->fsm_head;
01033   while( head != NULL ) {
01034 
01035     bool found_exclusion;
01036 
01037     if( head->table->from_state->id == head->table->to_state->id ) {
01038       codegen_gen_expr( head->table->to_state, head->table->to_state->op, &ocode, &ocode_depth, NULL );
01039       fprintf( ofile, "      FSM input/output state (%s)\n\n", ocode[0] );
01040       for( i=0; i<ocode_depth; i++ ) {
01041         free_safe( ocode[i], (strlen( ocode[i] ) + 1) );
01042       }
01043       free_safe( ocode, (sizeof( char* ) * ocode_depth) );
01044     } else {
01045       codegen_gen_expr( head->table->from_state, head->table->from_state->op, &icode, &icode_depth, NULL );
01046       codegen_gen_expr( head->table->to_state,   head->table->to_state->op,   &ocode, &ocode_depth, NULL );
01047       fprintf( ofile, "      FSM input state (%s), output state (%s)\n\n", icode[0], ocode[0] );
01048       for( i=0; i<icode_depth; i++ ) {
01049         free_safe( icode[i], (strlen( icode[i] ) + 1) );
01050       }
01051       free_safe( icode, (sizeof( char* ) * icode_depth) );
01052       for( i=0; i<ocode_depth; i++ ) {
01053         free_safe( ocode[i], (strlen( ocode[i] ) + 1) );
01054       }
01055       free_safe( ocode, (sizeof( char* ) * ocode_depth) );
01056     }
01057 
01058     fsm_display_state_verbose( ofile, head->table );
01059     found_exclusion = fsm_display_arc_verbose( ofile, head->table, funit, (report_covered ? RPT_TYPE_HIT : RPT_TYPE_MISS) );
01060     if( report_exclusions && found_exclusion ) {
01061       (void)fsm_display_arc_verbose( ofile, head->table, funit, RPT_TYPE_EXCL );
01062     }
01063 
01064     if( head->next != NULL ) {
01065       fprintf( ofile, "      - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n" );
01066     }
01067 
01068     head = head->next;
01069 
01070   }
01071 
01072   PROFILE_END;
01073 
01074 }

bool fsm_funit_summary FILE *  ofile,
funit_link head,
int *  state_hits,
int *  state_total,
int *  arc_hits,
int *  arc_total
[static]
 

Returns:
Returns TRUE if any FSM states/arcs were found missing; otherwise, returns FALSE.
Generates a functional unit summary report of the current FSM states and arcs hit during simulation.
Parameters:
ofile  Pointer to output file to display report contents to
head  Pointer to functional unit list to traverse
state_hits  Pointer to number of states that were hit in all functional units
state_total  Pointer to total number of states found in all functional units
arc_hits  Pointer to number of state transitions found in all functional units
arc_total  Pointer to total number of state transitions found in all functional units

00790   { PROFILE(FSM_FUNIT_SUMMARY);
00791 
00792   bool  miss_found = FALSE;  /* Set to TRUE if state/arc was found to be missed */
00793   char* pname;               /* Printable version of functional unit name */
00794 
00795   while( head != NULL ) {
00796 
00797     /* If this is an assertion module, don't output any further */
00798     if( head->funit->stat->show && !funit_is_unnamed( head->funit ) &&
00799         ((info_suppl.part.assert_ovl == 0) || !ovl_is_assertion_module( head->funit )) ) {
00800 
00801       /* Get printable version of functional unit name */
00802       pname = scope_gen_printable( funit_flatten_name( head->funit ) );
00803 
00804       miss_found |= fsm_display_funit_summary( ofile, pname, get_basename( obf_file( head->funit->filename ) ),
00805                                                head->funit->stat->state_hit, head->funit->stat->state_total,
00806                                                head->funit->stat->arc_hit, head->funit->stat->arc_total );
00807 
00808       /* Update accumulated information */
00809       *state_hits += head->funit->stat->state_hit;
00810       if( (head->funit->stat->state_total == -1) || (*state_total == -1) ) {
00811         *state_total = -1;
00812       } else {
00813         *state_total += head->funit->stat->state_total;
00814       }
00815       *arc_hits += head->funit->stat->arc_hit;
00816       if( (head->funit->stat->arc_total == -1) || (*arc_total == -1) ) {
00817         *arc_total = -1;
00818       } else {
00819         *arc_total += head->funit->stat->arc_total;
00820       }
00821 
00822       free_safe( pname, (strlen( pname ) + 1) );
00823 
00824     }
00825 
00826     head = head->next;
00827 
00828   }
00829 
00830   PROFILE_END;
00831 
00832   return( miss_found );
00833 
00834 }

void fsm_funit_verbose FILE *  ofile,
funit_link head
[static]
 

Generates a functional unit verbose report of the current FSM states and arcs hit during simulation.

Parameters:
ofile  Pointer to output file to display report contents to
head  Pointer to head of functional unit list to traverse

01151   { PROFILE(FSM_FUNIT_VERBOSE);
01152 
01153   char* pname;  /* Printable version of functional unit name */
01154 
01155   while( head != NULL ) {
01156 
01157     if( !funit_is_unnamed( head->funit ) &&
01158         ((((head->funit->stat->state_hit < head->funit->stat->state_total) || 
01159            (head->funit->stat->arc_hit < head->funit->stat->arc_total)) && !report_covered) ||
01160            (head->funit->stat->state_total == -1) ||
01161            (head->funit->stat->arc_total   == -1) ||
01162          (((head->funit->stat->state_hit > 0) || (head->funit->stat->arc_hit > 0)) && report_covered) ||
01163          ((head->funit->stat->arc_excluded > 0) && report_exclusions)) ) {
01164 
01165       /* Get printable version of functional unit name */
01166       pname = scope_gen_printable( funit_flatten_name( head->funit ) );
01167 
01168       fprintf( ofile, "\n" );
01169       switch( head->funit->type ) {
01170         case FUNIT_MODULE       :  fprintf( ofile, "    Module: " );       break;
01171         case FUNIT_ANAMED_BLOCK :
01172         case FUNIT_NAMED_BLOCK  :  fprintf( ofile, "    Named Block: " );  break;
01173         case FUNIT_AFUNCTION    :
01174         case FUNIT_FUNCTION     :  fprintf( ofile, "    Function: " );     break;
01175         case FUNIT_ATASK        :
01176         case FUNIT_TASK         :  fprintf( ofile, "    Task: " );         break;
01177         default                 :  fprintf( ofile, "    UNKNOWN: " );      break;
01178       }
01179       fprintf( ofile, "%s, File: %s\n", pname, obf_file( head->funit->filename ) );
01180       fprintf( ofile, "    -------------------------------------------------------------------------------------------------------------\n" );
01181 
01182       free_safe( pname, (strlen( pname ) + 1) );
01183 
01184       fsm_display_verbose( ofile, head->funit );
01185 
01186     }
01187 
01188     head = head->next;
01189 
01190   }
01191 
01192   PROFILE_END;
01193 
01194 }

void fsm_gather_signals expression expr,
sig_link **  head,
sig_link **  tail,
int  expr_id,
int **  expr_ids,
int *  expr_id_size
[static]
 

Recursively iterates through specified expression, adding the signal of each expression that points to one to the specified signal list. Also captures the expression ID of the statement containing this signal for each signal found (if expr_id is a non-negative value).

Parameters:
expr  Pointer to expression to get signals from
head  Pointer to head of signal list to populate
tail  Pointer to tail of signal list to populate
expr_id  Expression ID of the statement containing this expression
expr_ids  Pointer to expression ID array
expr_id_size  Number of elements currently stored in expr_ids array

00474   { PROFILE(FSM_GATHER_SIGNALS);
00475 
00476   if( expr != NULL ) {
00477 
00478     if( expr->sig != NULL ) {
00479 
00480       /* Add this signal to the list */
00481       sig_link_add( expr->sig, head, tail );
00482 
00483       /* Add specified expression ID to the expression IDs array, if needed */
00484       if( expr_id >= 0 ) {
00485         (*expr_ids)                  = (int*)realloc_safe( *expr_ids, (sizeof( int ) * (*expr_id_size)), (sizeof( int ) * ((*expr_id_size) + 1)) );
00486         (*expr_ids)[(*expr_id_size)] = expr_id;
00487         (*expr_id_size)++;
00488       }
00489 
00490     } else {
00491 
00492       fsm_gather_signals( expr->left,  head, tail, expr_id, expr_ids, expr_id_size );
00493       fsm_gather_signals( expr->right, head, tail, expr_id, expr_ids, expr_id_size );
00494 
00495     }
00496 
00497   }
00498 
00499   PROFILE_END;
00500 
00501 }

void fsm_get_coverage func_unit funit,
int  expr_id,
char ***  total_fr_states,
unsigned int *  total_fr_state_num,
char ***  total_to_states,
unsigned int *  total_to_state_num,
char ***  hit_fr_states,
unsigned int *  hit_fr_state_num,
char ***  hit_to_states,
unsigned int *  hit_to_state_num,
char ***  total_from_arcs,
char ***  total_to_arcs,
int **  total_ids,
int **  excludes,
char ***  reasons,
int *  total_arc_num,
char ***  hit_from_arcs,
char ***  hit_to_arcs,
int *  hit_arc_num,
char ***  input_state,
unsigned int *  input_size,
char ***  output_state,
unsigned int *  output_size
 

Collects all coverage information for the specified FSM.

Gets the FSM coverage information for the specified FSM in the specified functional unit. Used by the GUI for creating the contents of the verbose FSM viewer.

Parameters:
funit  Pointer to functional unit
expr_id  Expression ID of output state expression to find
total_fr_states  Pointer to a string array containing all possible from states in this FSM
total_fr_state_num  Pointer to the number of elements in the total_fr_states array
total_to_states  Pointer to a string array containing all possible to states in this FSM
total_to_state_num  Pointer to the number of elements in the total_to_states array
hit_fr_states  Pointer to a string array containing the hit fr_states in this FSM
hit_fr_state_num  Pointer to the number of elements in the hit_fr_states array
hit_to_states  Pointer to a string array containing the hit to_states in this FSM
hit_to_state_num  Pointer to the number of elements in the hit_to_states array
total_from_arcs  Pointer to a string array containing all possible state transition from states
total_to_arcs  Pointer to a string array containing all possible state transition to states
total_ids  Pointer to an integer array containing the arc transition IDs for each transition
excludes  Pointer to an integer array containing the exclude values for each state transition
reasons  Pointer to a string array containing exclusion reasons
total_arc_num  Pointer to the number of elements in both the total_from_arcs, total_to_arcs and excludes arrays
hit_from_arcs  Pointer to a string array containing the hit state transition from states
hit_to_arcs  Pointer to a string array containing the hit state transition to states
hit_arc_num  Pointer to the number of elements in both the hit_from_arcs and hit_to_arcs arrays
input_state  Pointer to a string array containing the code for the input state expression
input_size  Pointer to the number of elements stored in the input state array
output_state  Pointer to a string array containing the code for the output state expression
output_size  Pointer to the number of elements stored in the output state array

00586   { PROFILE(FSM_GET_COVERAGE);
00587 
00588   fsm_link* curr_fsm;     /* Pointer to current FSM link */
00589   int*      tmp_ids;      /* Temporary integer array */
00590   int*      tmp;          /* Temporary integer array */
00591   char**    tmp_reasons;  /* Temporary reason array */
00592 
00593   curr_fsm = funit->fsm_head;
00594   while( (curr_fsm != NULL) && (curr_fsm->table->to_state->id != expr_id) ) {
00595     curr_fsm = curr_fsm->next; 
00596   }
00597 
00598   assert( curr_fsm != NULL );
00599 
00600   /* Get state information */
00601   arc_get_states( total_fr_states, total_fr_state_num, total_to_states, total_to_state_num, curr_fsm->table->table, TRUE, TRUE ); 
00602   arc_get_states( hit_fr_states,   hit_fr_state_num,   hit_to_states,   hit_to_state_num,   curr_fsm->table->table, TRUE, FALSE );
00603 
00604   /* Get state transition information */
00605   arc_get_transitions( total_from_arcs, total_to_arcs, total_ids, excludes, reasons,      total_arc_num, curr_fsm->table->table, funit, TRUE, TRUE );
00606   arc_get_transitions( hit_from_arcs,   hit_to_arcs,   &tmp_ids,  &tmp,     &tmp_reasons, hit_arc_num,   curr_fsm->table->table, funit, TRUE, FALSE );
00607 
00608   /* Get input state code */
00609   codegen_gen_expr( curr_fsm->table->from_state, curr_fsm->table->from_state->op, input_state, input_size, NULL );
00610 
00611   /* Get output state code */
00612   codegen_gen_expr( curr_fsm->table->to_state, curr_fsm->table->to_state->op, output_state, output_size, NULL );
00613 
00614   /* Deallocate unused state information */
00615   if( *hit_arc_num > 0 ) {
00616     unsigned int i;
00617     free_safe( tmp_ids, (sizeof( int ) * (*hit_arc_num)) );
00618     free_safe( tmp,     (sizeof( int ) * (*hit_arc_num)) );
00619     for( i=0; i<(*hit_arc_num); i++ ) {
00620       free_safe( tmp_reasons[i], (strlen( tmp_reasons[i] ) + 1) );
00621     }
00622     free_safe( tmp_reasons, (sizeof( char* ) * (*hit_arc_num)) );
00623   }
00624 
00625   PROFILE_END;
00626 
00627 }

void fsm_get_funit_summary func_unit funit,
int *  hit,
int *  excluded,
int *  total
 

Retrieves the FSM summary information for the specified functional unit.

Retrieves the FSM summary information for the specified functional unit.

Parameters:
funit  Pointer to functional unit
hit  Pointer to location to store the number of hit state transitions for the specified functional unit
excluded  Pointer to number of excluded arcs
total  Pointer to location to store the total number of state transitions for the specified functional unit

00434   { PROFILE(FSM_GET_FUNIT_SUMMARY);
00435 
00436   *hit      = funit->stat->arc_hit;
00437   *excluded = funit->stat->arc_excluded;
00438   *total    = funit->stat->arc_total;
00439 
00440   PROFILE_END;
00441 
00442 }

void fsm_get_inst_summary funit_inst inst,
int *  hit,
int *  excluded,
int *  total
 

Retrieves the FSM summary information for the specified functional unit.

Retrieves the FSM summary information for the specified functional unit instance.

Parameters:
inst  Pointer to functional unit instance
hit  Pointer to location to store the number of hit state transitions for the specified functional unit
excluded  Pointer to number of excluded arcs
total  Pointer to location to store the total number of state transitions for the specified functional unit

00452   { PROFILE(FSM_GET_INST_SUMMARY);
00453 
00454   *hit      = inst->stat->arc_hit;
00455   *excluded = inst->stat->arc_excluded;
00456   *total    = inst->stat->arc_total;
00457 
00458   PROFILE_END;
00459 
00460 }

void fsm_get_stats fsm_link table,
int *  state_hit,
int *  state_total,
int *  arc_hit,
int *  arc_total,
int *  arc_excluded
 

Gathers statistics about the current FSM.

Gathers the FSM state and state transition statistics for the given table and assigns this information to the specified pointers.

Parameters:
table  Pointer to FSM to get statistics from
state_hit  Number of states reached in this FSM
state_total  Total number of states within this FSM
arc_hit  Number of arcs reached in this FSM
arc_total  Total number of arcs within this FSM
arc_excluded  Total number of excluded arcs

00412   { PROFILE(FSM_GET_STATS);
00413 
00414   fsm_link* curr;   /* Pointer to current FSM in table list */
00415 
00416   curr = table;
00417   while( curr != NULL ) {
00418     arc_get_stats( curr->table->table, state_hit, state_total, arc_hit, arc_total, arc_excluded );
00419     curr = curr->next;
00420   }
00421 
00422   PROFILE_END;
00423 
00424 }

bool fsm_instance_summary FILE *  ofile,
funit_inst root,
char *  parent_inst,
int *  state_hits,
int *  state_total,
int *  arc_hits,
int *  arc_total
[static]
 

Returns:
Returns TRUE if any FSM states/arcs were found missing; otherwise, returns FALSE.
Generates an instance summary report of the current FSM states and arcs hit during simulation.
Parameters:
ofile  Pointer to output file to display report contents to
root  Pointer to current root of instance tree to report
parent_inst  String containing Verilog hierarchy of this instance's parent
state_hits  Pointer to total number of states hit in design
state_total  Pointer to total number of states in design
arc_hits  Pointer to total number of arcs traversed
arc_total  Pointer to total number of arcs in design

00679   { PROFILE(FSM_INSTANCE_SUMMARY);
00680 
00681   funit_inst* curr;                /* Pointer to current child functional unit instance of this node */
00682   char        tmpname[4096];       /* Temporary name holder for instance */
00683   char*       pname;               /* Printable version of instance name */
00684   bool        miss_found = FALSE;  /* Set to TRUE if at least state or arc was not hit */
00685 
00686   assert( root != NULL );
00687   assert( root->stat != NULL );
00688 
00689   /* Generate printable version of instance name */
00690   pname = scope_gen_printable( root->name );
00691 
00692   if( db_is_unnamed_scope( pname ) || root->suppl.name_diff ) {
00693     strcpy( tmpname, parent_inst );
00694   } else if( strcmp( parent_inst, "*" ) == 0 ) {
00695     strcpy( tmpname, pname );
00696   } else {
00697     unsigned int rv = snprintf( tmpname, 4096, "%s.%s", parent_inst, pname ); 
00698     assert( rv < 4096 );
00699   }
00700 
00701   free_safe( pname, (strlen( pname ) + 1) );
00702 
00703   if( (root->funit != NULL) && root->stat->show && !funit_is_unnamed( root->funit ) &&
00704       ((info_suppl.part.assert_ovl == 0) || !ovl_is_assertion_module( root->funit )) ) {
00705 
00706     miss_found |= fsm_display_instance_summary( ofile, tmpname, root->stat->state_hit, root->stat->state_total, root->stat->arc_hit, root->stat->arc_total );
00707 
00708     /* Update accumulated information */
00709     *state_hits += root->stat->state_hit; 
00710     if( (root->stat->state_total == -1) || (*state_total == -1) ) {
00711       *state_total = -1;
00712     } else {
00713       *state_total += root->stat->state_total;
00714     }
00715     *arc_hits += root->stat->arc_hit;
00716     if( (root->stat->arc_total == -1) || (*arc_total == -1) ) {
00717       *arc_total = -1;
00718     } else {
00719       *arc_total += root->stat->arc_total;
00720     }
00721 
00722   }
00723 
00724   /* If this is an assertion module, don't output any further */
00725   if( (info_suppl.part.assert_ovl == 0) || !ovl_is_assertion_module( root->funit ) ) {
00726 
00727     curr = root->child_head;
00728     while( curr != NULL ) {
00729       miss_found |= fsm_instance_summary( ofile, curr, tmpname, state_hits, state_total, arc_hits, arc_total );
00730       curr = curr->next;
00731     }
00732 
00733   }
00734 
00735   PROFILE_END;
00736 
00737   return( miss_found );
00738 
00739 }

void fsm_instance_verbose FILE *  ofile,
funit_inst root,
char *  parent_inst
[static]
 

Generates an instance verbose report of the current FSM states and arcs hit during simulation.

Parameters:
ofile  Pointer to output file to display report contents to
root  Pointer to root of instance tree to traverse
parent_inst  String containing name of this instance's parent instance

01083   { PROFILE(FSM_INSTANCE_VERBOSE);
01084 
01085   funit_inst* curr_inst;      /* Pointer to current instance being evaluated */
01086   char        tmpname[4096];  /* Temporary name holder for instance */
01087   char*       pname;          /* Printable version of instance name */
01088 
01089   assert( root != NULL );
01090 
01091   /* Get printable version of instance name */
01092   pname = scope_gen_printable( root->name );
01093 
01094   if( db_is_unnamed_scope( pname ) || root->suppl.name_diff ) {
01095     strcpy( tmpname, parent_inst );
01096   } else if( strcmp( parent_inst, "*" ) == 0 ) {
01097     strcpy( tmpname, pname );
01098   } else {
01099     unsigned int rv = snprintf( tmpname, 4096, "%s.%s", parent_inst, pname );
01100     assert( rv < 4096 );
01101   }
01102 
01103   free_safe( pname, (strlen( pname ) + 1) );
01104 
01105   if( (root->funit != NULL) && !funit_is_unnamed( root->funit ) &&
01106       ((((root->stat->state_hit < root->stat->state_total) || (root->stat->arc_hit < root->stat->arc_total)) && !report_covered) ||
01107          (root->stat->state_total == -1) ||
01108          (root->stat->arc_total   == -1) ||
01109        (((root->stat->state_hit > 0) || (root->stat->arc_hit > 0)) && report_covered) ||
01110        ((root->stat->arc_excluded > 0) && report_exclusions)) ) {
01111 
01112     /* Get printable version of functional unit name */
01113     pname = scope_gen_printable( funit_flatten_name( root->funit ) );
01114 
01115     fprintf( ofile, "\n" );
01116     switch( root->funit->type ) {
01117       case FUNIT_MODULE       :  fprintf( ofile, "    Module: " );       break;
01118       case FUNIT_ANAMED_BLOCK :
01119       case FUNIT_NAMED_BLOCK  :  fprintf( ofile, "    Named Block: " );  break;
01120       case FUNIT_AFUNCTION    :
01121       case FUNIT_FUNCTION     :  fprintf( ofile, "    Function: " );     break;
01122       case FUNIT_ATASK        :
01123       case FUNIT_TASK         :  fprintf( ofile, "    Task: " );         break;
01124       default                 :  fprintf( ofile, "    UNKNOWN: " );      break;
01125     }
01126     fprintf( ofile, "%s, File: %s, Instance: %s\n", pname, obf_file( root->funit->filename ), tmpname );
01127     fprintf( ofile, "    -------------------------------------------------------------------------------------------------------------\n" );
01128 
01129     free_safe( pname, (strlen( pname ) + 1) );
01130 
01131     fsm_display_verbose( ofile, root->funit );
01132 
01133   }
01134 
01135   curr_inst = root->child_head;
01136   while( curr_inst != NULL ) {
01137     fsm_instance_verbose( ofile, curr_inst, tmpname );
01138     curr_inst = curr_inst->next;
01139   }
01140 
01141   PROFILE_END;
01142 
01143 }

void fsm_merge fsm base,
fsm other
 

Merges two FSMs, placing the result into the base FSM.

Merges two FSMs, placing the resulting FSM into the base. This function is called when merging modules for the GUI.

Parameters:
base  Base FSM to store merged results
other  Other FSM that will be merged with the base FSM

00351   { PROFILE(FSM_MERGE);
00352 
00353   assert( base != NULL );
00354   assert( base->from_state != NULL );
00355   assert( base->to_state != NULL );
00356   assert( other != NULL );
00357   assert( other->from_state != NULL );
00358   assert( other->to_state != NULL );
00359 
00360   if( base->table != NULL ) {
00361     assert( other->table != NULL );
00362     arc_merge( base->table, other->table );
00363   }
00364 
00365   PROFILE_END;
00366 
00367 }

void fsm_report FILE *  ofile,
bool  verbose
 

Generates report output for FSM coverage.

After the design is read into the functional unit hierarchy, parses the hierarchy by functional unit, reporting the FSM coverage for each functional unit encountered. The parent functional unit will specify its own FSM coverage along with a total FSM coverage including its children.

Parameters:
ofile  Pointer to file to output results to
verbose  Specifies whether or not to provide verbose information

01205   { PROFILE(FSM_REPORT);
01206 
01207   bool       missed_found  = FALSE;  /* If set to TRUE, FSM cases were found to be missed */
01208   inst_link* instl;                  /* Pointer to current instance link */
01209   int        acc_st_hits   = 0;      /* Accumulated number of states hit */
01210   int        acc_st_total  = 0;      /* Accumulated number of states in design */
01211   int        acc_arc_hits  = 0;      /* Accumulated number of arcs hit */
01212   int        acc_arc_total = 0;      /* Accumulated number of arcs in design */
01213 
01214   fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
01215   fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   FINITE STATE MACHINE COVERAGE RESULTS   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
01216   fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" );
01217 
01218   if( report_instance ) {
01219 
01220     fprintf( ofile, "                                                               State                             Arc\n" );
01221     fprintf( ofile, "Instance                                          Hit/Miss/Total    Percent hit    Hit/Miss/Total    Percent hit\n" );
01222     fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01223 
01224     instl = db_list[curr_db]->inst_head;
01225     while( instl != NULL ) {
01226       missed_found |= fsm_instance_summary( ofile, instl->inst, (instl->inst->suppl.name_diff ? "<NA>" : "*"), &acc_st_hits, &acc_st_total, &acc_arc_hits, &acc_arc_total );
01227       instl = instl->next;
01228     }
01229     fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01230     (void)fsm_display_instance_summary( ofile, "Accumulated", acc_st_hits, acc_st_total, acc_arc_hits, acc_arc_total );
01231    
01232     if( verbose && (missed_found || report_covered || report_exclusions) ) {
01233       fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01234       instl = db_list[curr_db]->inst_head;
01235       while( instl != NULL ) {
01236         fsm_instance_verbose( ofile, instl->inst, (instl->inst->suppl.name_diff ? "<NA>" : "*") );
01237         instl = instl->next;
01238       }
01239     }
01240 
01241   } else {
01242 
01243     fprintf( ofile, "                                                               State                             Arc\n" );
01244     fprintf( ofile, "Module/Task/Function      Filename                Hit/Miss/Total    Percent Hit    Hit/Miss/Total    Percent hit\n" );
01245     fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01246 
01247     missed_found = fsm_funit_summary( ofile, db_list[curr_db]->funit_head, &acc_st_hits, &acc_st_total, &acc_arc_hits, &acc_arc_total );
01248     fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01249     (void)fsm_display_funit_summary( ofile, "Accumulated", "", acc_st_hits, acc_st_total, acc_arc_hits, acc_arc_total );
01250 
01251     if( verbose && (missed_found || report_covered || report_exclusions) ) {
01252       fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" );
01253       fsm_funit_verbose( ofile, db_list[curr_db]->funit_head );
01254     }
01255 
01256   }
01257 
01258   fprintf( ofile, "\n\n" );
01259 
01260   PROFILE_END;
01261 
01262 }

void fsm_table_set expression expr,
const sim_time time
 

Sets the bit in set table based on the values of last and curr.

Taking the from and to state signal values, a new table entry is added to the specified FSM structure arc array (if an entry does not already exist in the array).

Parameters:
expr  Pointer to expression that contains FSM table to modify
time  Pointer to current simulation time

00377   { PROFILE(FSM_TABLE_SET);
00378 
00379   /* If the expression is the input state expression, make sure that the output state expression is simulated this clock period */
00380   if( (expr->table->from_state->id == expr->id) && (expr->table->from_state->id != expr->table->to_state->id) ) {
00381 
00382     sim_expr_changed( expr->table->to_state, time );
00383 
00384   /* Otherwise, add the state/state transition */
00385   } else {
00386 
00387     /* Add the states and state transition */
00388     arc_add( expr->table->table, expr->table->from_state->value, expr->table->to_state->value, 1, expr->table->exclude );
00389 
00390     /* If from_state was not specified, we need to copy the current contents of to_state to from_state */
00391     if( expr->table->from_state->id == expr->id ) {
00392       vector_copy( expr->value, expr->table->from_state->value );
00393     }
00394 
00395   }
00396 
00397   PROFILE_END;
00398 
00399 }


Variable Documentation

unsigned int curr_db
 

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

db** db_list
 

Array of database pointers storing all currently loaded databases.

bool flag_output_exclusion_ids
 

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

isuppl info_suppl
 

Informational line for the CDD file.

unsigned int report_comb_depth
 

If set to a non-zero value, causes Covered to only generate combinational logic report information for depths up to the number specified.

bool report_covered
 

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.

bool report_exclusions
 

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.

bool report_instance
 

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.

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:21 2009 for Covered by doxygen 1.3.4