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

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


Detailed Description

Contains functions for determining/reporting FSM coverage.

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

#include <stdio.h>
#include "defines.h"

Go to the source code of this file.

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_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.

void fsm_report (FILE *ofile, bool verbose)
 Generates report output for FSM coverage.

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


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 }

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 }

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 }


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