Contains functions for determining/reporting FSM coverage. More...
#include <stdio.h>
#include "defines.h"
Go to the source code of this file.
Functions | |
fsm * | fsm_create (expression *from_state, expression *to_state, int line, 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. |
Contains functions for determining/reporting FSM coverage.
void fsm_add_arc | ( | fsm * | table, | |
expression * | from_state, | |||
expression * | to_state | |||
) |
Adds new FSM arc structure to specified FSMs arc list.
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 |
References fsm_s::arc_head, fsm_s::arc_tail, fsm_arc_s::from_state, malloc_safe, fsm_arc_s::next, PROFILE, PROFILE_END, and fsm_arc_s::to_state.
Referenced by fsm_arg_parse_trans().
00103 { PROFILE(FSM_ADD_ARC); 00104 00105 fsm_arc* arc; /* Pointer to newly created FSM arc structure */ 00106 00107 /* Create an initialize specified arc */ 00108 arc = (fsm_arc*)malloc_safe( sizeof( fsm_arc ) ); 00109 arc->from_state = from_state; 00110 arc->to_state = to_state; 00111 arc->next = NULL; 00112 00113 /* Add new arc to specified FSM structure */ 00114 if( table->arc_head == NULL ) { 00115 table->arc_head = table->arc_tail = arc; 00116 } else { 00117 table->arc_tail->next = arc; 00118 table->arc_tail = arc; 00119 } 00120 00121 PROFILE_END; 00122 00123 }
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.
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 |
References arc_are_any_excluded(), arc_get_stats(), fsm_gather_signals(), func_unit_s::fsm_head, expression_s::id, fsm_link_s::next, PROFILE, PROFILE_END, realloc_safe, fsm_s::table, fsm_link_s::table, and fsm_s::to_state.
00522 { PROFILE(FSM_COLLECT); 00523 00524 fsm_link* curr_fsm; /* Pointer to current FSM link being evaluated */ 00525 int size = 0; /* Number of expressions IDs stored in expr_ids array */ 00526 00527 /* Initialize list pointers */ 00528 *sig_tail = *sig_head = NULL; 00529 *expr_ids = *excludes = NULL; 00530 00531 curr_fsm = funit->fsm_head; 00532 while( curr_fsm != NULL ) { 00533 00534 /* Get the state and arc statistics */ 00535 int state_hit = 0; 00536 int state_total = 0; 00537 int arc_hit = 0; 00538 int arc_total = 0; 00539 int arc_excluded = 0; 00540 arc_get_stats( curr_fsm->table->table, &state_hit, &state_total, &arc_hit, &arc_total, &arc_excluded ); 00541 00542 /* Allocate some more memory for the excluded array */ 00543 *excludes = (int*)realloc_safe( *excludes, (sizeof( int ) * size), (sizeof( int ) * (size + 1)) ); 00544 00545 /* If the total number of arcs is not known, consider this FSM as uncovered */ 00546 if( (cov == 0) && ((arc_total == -1) || (arc_total != arc_hit)) ) { 00547 (*excludes)[size] = 0; 00548 fsm_gather_signals( curr_fsm->table->to_state, sig_head, sig_tail, curr_fsm->table->to_state->id, expr_ids, &size ); 00549 } else { 00550 if( (cov == 0) && arc_are_any_excluded( curr_fsm->table->table ) ) { 00551 fsm_gather_signals( curr_fsm->table->to_state, sig_head, sig_tail, curr_fsm->table->to_state->id, expr_ids, &size ); 00552 (*excludes)[size] = 1; 00553 } else if( cov == 1 ) { 00554 fsm_gather_signals( curr_fsm->table->to_state, sig_head, sig_tail, -1, expr_ids, &size ); 00555 } 00556 } 00557 00558 curr_fsm = curr_fsm->next; 00559 00560 } 00561 00562 PROFILE_END; 00563 00564 }
fsm* fsm_create | ( | expression * | from_state, | |
expression * | to_state, | |||
int | line, | |||
bool | exclude | |||
) |
Creates and initializes new FSM structure.
Allocates and initializes an FSM structure.
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 | |
line | First line of FSM attribute | |
exclude | Value to set the exclude bit to |
References fsm_s::arc_head, fsm_s::arc_tail, fsm_s::exclude, fsm_s::from_state, fsm_s::line, malloc_safe, fsm_s::name, PROFILE, fsm_s::table, and fsm_s::to_state.
Referenced by fsm_db_read(), fsm_var_add(), and fsm_var_bind_stmt().
00078 { PROFILE(FSM_CREATE); 00079 00080 fsm* table; /* Pointer to newly created FSM */ 00081 00082 table = (fsm*)malloc_safe( sizeof( fsm ) ); 00083 table->name = NULL; 00084 table->line = line; 00085 table->from_state = from_state; 00086 table->to_state = to_state; 00087 table->arc_head = NULL; 00088 table->arc_tail = NULL; 00089 table->table = NULL; 00090 table->exclude = exclude; 00091 00092 return( table ); 00093 00094 }
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.
table | Pointer to FSM structure to set table sizes to |
References arc_add(), arc_create(), fsm_s::arc_head, fsm_s::exclude, expression_operate(), FALSE, sim_time_s::final, fsm_arc_s::from_state, sim_time_s::full, sim_time_s::hi, sim_time_s::lo, fsm_arc_s::next, PROFILE, PROFILE_END, fsm_s::table, fsm_arc_s::to_state, fsm_s::to_state, TRUE, expression_s::value, and vector_s::width.
Referenced by funit_size_elements().
00132 { PROFILE(FSM_CREATE_TABLES); 00133 00134 fsm_arc* curr_arc; /* Pointer to current FSM arc structure */ 00135 bool set = TRUE; /* Specifies if specified bit was set */ 00136 sim_time time; /* Current simulation time */ 00137 00138 /* Create the FSM arc transition table */ 00139 assert( table != NULL ); 00140 assert( table->to_state != NULL ); 00141 assert( table->to_state->value != NULL ); 00142 assert( table->table == NULL ); 00143 table->table = arc_create( table->to_state->value->width ); 00144 00145 /* Initialize the current time */ 00146 time.lo = 0; 00147 time.hi = 0; 00148 time.full = 0; 00149 time.final = FALSE; 00150 00151 /* Set valid table */ 00152 curr_arc = table->arc_head; 00153 while( (curr_arc != NULL) && set ) { 00154 00155 /* Evaluate from and to state expressions */ 00156 (void)expression_operate( curr_arc->from_state, NULL, &time ); 00157 (void)expression_operate( curr_arc->to_state, NULL, &time ); 00158 00159 /* Set table entry in table, if possible */ 00160 arc_add( table->table, curr_arc->from_state->value, curr_arc->to_state->value, 0, table->exclude ); 00161 00162 curr_arc = curr_arc->next; 00163 00164 } 00165 00166 PROFILE_END; 00167 00168 }
void fsm_db_merge | ( | fsm * | base, | |
char ** | line | |||
) |
Reads and merges two FSMs, placing result into base FSM.
base | Pointer to FSM structure to merge data into. | |
line | Pointer to read in line from CDD file to merge. |
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.
References arc_db_merge(), FATAL, fsm_s::from_state, print_output(), PROFILE, PROFILE_END, fsm_s::table, Throw, and fsm_s::to_state.
Referenced by funit_db_inst_merge(), and funit_db_mod_merge().
00319 { PROFILE(FSM_DB_MERGE); 00320 00321 int fline; /* First line number of FSM */ 00322 int iid; /* Input state variable expression ID */ 00323 int oid; /* Output state variable expression ID */ 00324 int chars_read; /* Number of characters read from line */ 00325 int is_table; /* Holds value of is_table signifier */ 00326 00327 assert( base != NULL ); 00328 assert( base->from_state != NULL ); 00329 assert( base->to_state != NULL ); 00330 00331 if( sscanf( *line, "%d %d %d %d%n", &fline, &iid, &oid, &is_table, &chars_read ) == 4 ) { 00332 00333 *line = *line + chars_read + 1; 00334 00335 if( is_table == 1 ) { 00336 00337 arc_db_merge( base->table, line ); 00338 00339 } 00340 00341 } else { 00342 00343 print_output( "Database being merged is not compatible with the original database.", FATAL, __FILE__, __LINE__ ); 00344 Throw 0; 00345 00346 } 00347 00348 PROFILE_END; 00349 00350 }
void fsm_db_read | ( | char ** | line, | |
func_unit * | funit | |||
) |
Reads in contents of specified FSM.
line | Pointer to current line being read from the CDD file. | |
funit | Pointer to current functional unit. |
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.
References arc_db_read(), bind_append_fsm_expr(), Catch_anonymous, exp_link_s::exp, func_unit_s::exp_head, exp_link_find(), EXP_OP_STATIC, expression_create(), FALSE, FATAL, fsm_s::from_state, fsm_create(), fsm_dealloc(), func_unit_s::fsm_head, fsm_link_add(), func_unit_s::fsm_tail, print_output(), PROFILE, PROFILE_END, fsm_s::table, expression_s::table, Throw, fsm_s::to_state, Try, user_msg, USER_MSG_LENGTH, expression_s::value, and vector_dealloc().
Referenced by db_read(), and funit_db_mod_merge().
00218 { PROFILE(FSM_DB_READ); 00219 00220 int fline; /* First line of FSM attribute */ 00221 int iexp_id; /* Input expression ID */ 00222 int oexp_id; /* Output expression ID */ 00223 exp_link* iexpl; /* Pointer to found state variable */ 00224 exp_link* oexpl; /* Pointer to found state variable */ 00225 int chars_read; /* Number of characters read from sscanf */ 00226 fsm* table; /* Pointer to newly created FSM structure from CDD */ 00227 int is_table; /* Holds value of is_table entry of FSM output */ 00228 00229 if( sscanf( *line, "%d %d %d %d%n", &fline, &iexp_id, &oexp_id, &is_table, &chars_read ) == 4 ) { 00230 00231 *line = *line + chars_read + 1; 00232 00233 if( funit == NULL ) { 00234 00235 print_output( "Internal error: FSM in database written before its functional unit", FATAL, __FILE__, __LINE__ ); 00236 Throw 0; 00237 00238 } else { 00239 00240 /* Find specified signal */ 00241 if( ((iexpl = exp_link_find( iexp_id, funit->exp_head )) != NULL) && 00242 ((oexpl = exp_link_find( oexp_id, funit->exp_head )) != NULL) ) { 00243 00244 /* Create new FSM */ 00245 table = fsm_create( iexpl->exp, oexpl->exp, fline, FALSE ); 00246 00247 /* 00248 If the input state variable is the same as the output state variable, create the new expression now. 00249 */ 00250 if( iexp_id == oexp_id ) { 00251 Try { 00252 table->from_state = expression_create( NULL, NULL, EXP_OP_STATIC, FALSE, iexp_id, 0, 0, 0, FALSE ); 00253 } Catch_anonymous { 00254 fsm_dealloc( table ); 00255 Throw 0; 00256 } 00257 vector_dealloc( table->from_state->value ); 00258 bind_append_fsm_expr( table->from_state, iexpl->exp, funit ); 00259 } else { 00260 table->from_state = iexpl->exp; 00261 } 00262 00263 /* Set input/output expression tables to point to this FSM */ 00264 table->from_state->table = table; 00265 table->to_state->table = table; 00266 00267 /* Now read in set table */ 00268 if( is_table == 1 ) { 00269 00270 Try { 00271 arc_db_read( &(table->table), line ); 00272 } Catch_anonymous { 00273 fsm_dealloc( table ); 00274 Throw 0; 00275 } 00276 00277 } 00278 00279 /* Add fsm to current functional unit */ 00280 fsm_link_add( table, &(funit->fsm_head), &(funit->fsm_tail) ); 00281 00282 } else { 00283 00284 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Unable to find state variable expressions (%d, %d) for current FSM", iexp_id, oexp_id ); 00285 assert( rv < USER_MSG_LENGTH ); 00286 print_output( user_msg, FATAL, __FILE__, __LINE__ ); 00287 Throw 0; 00288 00289 } 00290 00291 } 00292 00293 } else { 00294 00295 print_output( "Unable to parse FSM line in database file. Unable to read.", FATAL, __FILE__, __LINE__ ); 00296 Throw 0; 00297 00298 } 00299 00300 PROFILE_END; 00301 00302 }
Outputs contents of specified FSM to CDD file.
Outputs the contents of the specified FSM to the specified CDD file.
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 |
References arc_db_write(), arc_dealloc(), DB_TYPE_FSM, expression_get_id(), fsm_s::from_state, fsm_s::line, PROFILE, PROFILE_END, fsm_s::table, and fsm_s::to_state.
Referenced by funit_db_write().
00177 { PROFILE(FSM_DB_WRITE); 00178 00179 fprintf( file, "%d %d %d %d ", 00180 DB_TYPE_FSM, 00181 table->line, 00182 expression_get_id( table->from_state, ids_issued ), 00183 expression_get_id( table->to_state, ids_issued ) 00184 ); 00185 00186 /* Print set table */ 00187 if( table->table != NULL ) { 00188 fprintf( file, "1 " ); 00189 arc_db_write( table->table, file ); 00190 00191 /* Deallocate the given table after writing it */ 00192 if( table->table != NULL ) { 00193 arc_dealloc( table->table ); 00194 table->table = NULL; 00195 } 00196 } else { 00197 fprintf( file, "0" ); 00198 } 00199 00200 fprintf( file, "\n" ); 00201 00202 PROFILE_END; 00203 00204 }
void fsm_dealloc | ( | fsm * | table | ) |
Deallocates specified FSM structure.
Deallocates all allocated memory for the specified FSM structure.
table | Pointer to FSM structure to deallocate |
References arc_dealloc(), fsm_s::arc_head, expression_dealloc(), FALSE, free_safe, fsm_s::from_state, fsm_arc_s::from_state, expression_s::id, fsm_s::name, fsm_arc_s::next, PROFILE, PROFILE_END, fsm_s::table, fsm_s::to_state, and fsm_arc_s::to_state.
Referenced by fsm_db_read(), and fsm_link_delete_list().
01284 { PROFILE(FSM_DEALLOC); 01285 01286 fsm_arc* tmp; /* Temporary pointer to current FSM arc structure to deallocate */ 01287 01288 if( table != NULL ) { 01289 01290 /* Free name if one was specified */ 01291 if( table->name != NULL ) { 01292 free_safe( table->name, (strlen( table->name ) + 1) ); 01293 } 01294 01295 /* Deallocate tables */ 01296 arc_dealloc( table->table ); 01297 01298 /* Deallocate FSM arc structure */ 01299 while( table->arc_head != NULL ) { 01300 tmp = table->arc_head; 01301 table->arc_head = table->arc_head->next; 01302 expression_dealloc( tmp->to_state, FALSE ); 01303 expression_dealloc( tmp->from_state, FALSE ); 01304 free_safe( tmp, sizeof( fsm_arc ) ); 01305 } 01306 01307 /* 01308 Deallocate from_state if it is the same expression ID as the to_state expression and is 01309 not the same expression structure 01310 */ 01311 if( (table->from_state != NULL) && 01312 (table->to_state != NULL) && 01313 (table->from_state != table->to_state ) && 01314 (table->from_state->id == table->to_state->id) ) { 01315 expression_dealloc( table->from_state, FALSE ); 01316 } 01317 01318 /* Deallocate this structure */ 01319 free_safe( table, sizeof( fsm ) ); 01320 01321 } 01322 01323 PROFILE_END; 01324 01325 }
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.
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 |
References arc_get_states(), arc_get_transitions(), codegen_gen_expr(), FALSE, free_safe, fsm_s::from_state, func_unit_s::fsm_head, expression_s::id, fsm_link_s::next, expression_s::op, PROFILE, PROFILE_END, fsm_s::table, fsm_link_s::table, fsm_s::to_state, TRUE, expression_s::value, and vector_s::width.
00594 { PROFILE(FSM_GET_COVERAGE); 00595 00596 fsm_link* curr_fsm; 00597 int* tmp_ids; 00598 int* tmp; 00599 char** tmp_reasons; 00600 unsigned int fr_width; 00601 unsigned int to_width; 00602 00603 curr_fsm = funit->fsm_head; 00604 while( (curr_fsm != NULL) && (curr_fsm->table->to_state->id != expr_id) ) { 00605 curr_fsm = curr_fsm->next; 00606 } 00607 00608 assert( curr_fsm != NULL ); 00609 00610 fr_width = curr_fsm->table->from_state->value->width; 00611 to_width = curr_fsm->table->to_state->value->width; 00612 00613 /* Get state information */ 00614 arc_get_states( total_fr_states, total_fr_state_num, total_to_states, total_to_state_num, curr_fsm->table->table, TRUE, TRUE, fr_width, to_width ); 00615 arc_get_states( hit_fr_states, hit_fr_state_num, hit_to_states, hit_to_state_num, curr_fsm->table->table, TRUE, FALSE, fr_width, to_width ); 00616 00617 /* Get state transition information */ 00618 arc_get_transitions( total_from_arcs, total_to_arcs, total_ids, excludes, reasons, total_arc_num, curr_fsm->table->table, funit, TRUE, TRUE, fr_width, to_width ); 00619 arc_get_transitions( hit_from_arcs, hit_to_arcs, &tmp_ids, &tmp, &tmp_reasons, hit_arc_num, curr_fsm->table->table, funit, TRUE, FALSE, fr_width, to_width ); 00620 00621 /* Get input state code */ 00622 codegen_gen_expr( curr_fsm->table->from_state, curr_fsm->table->from_state->op, input_state, input_size, NULL ); 00623 00624 /* Get output state code */ 00625 codegen_gen_expr( curr_fsm->table->to_state, curr_fsm->table->to_state->op, output_state, output_size, NULL ); 00626 00627 /* Deallocate unused state information */ 00628 if( *hit_arc_num > 0 ) { 00629 unsigned int i; 00630 free_safe( tmp_ids, (sizeof( int ) * (*hit_arc_num)) ); 00631 free_safe( tmp, (sizeof( int ) * (*hit_arc_num)) ); 00632 for( i=0; i<(*hit_arc_num); i++ ) { 00633 free_safe( tmp_reasons[i], (strlen( tmp_reasons[i] ) + 1) ); 00634 } 00635 free_safe( tmp_reasons, (sizeof( char* ) * (*hit_arc_num)) ); 00636 } 00637 00638 PROFILE_END; 00639 00640 }
void fsm_get_funit_summary | ( | func_unit * | funit, | |
int * | hit, | |||
int * | excluded, | |||
int * | total | |||
) |
Retrieves the FSM summary information for the specified functional unit.
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 |
References statistic_s::arc_excluded, statistic_s::arc_hit, statistic_s::arc_total, PROFILE, PROFILE_END, and func_unit_s::stat.
00442 { PROFILE(FSM_GET_FUNIT_SUMMARY); 00443 00444 *hit = funit->stat->arc_hit; 00445 *excluded = funit->stat->arc_excluded; 00446 *total = funit->stat->arc_total; 00447 00448 PROFILE_END; 00449 00450 }
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.
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 |
References statistic_s::arc_excluded, statistic_s::arc_hit, statistic_s::arc_total, PROFILE, PROFILE_END, and funit_inst_s::stat.
00460 { PROFILE(FSM_GET_INST_SUMMARY); 00461 00462 *hit = inst->stat->arc_hit; 00463 *excluded = inst->stat->arc_excluded; 00464 *total = inst->stat->arc_total; 00465 00466 PROFILE_END; 00467 00468 }
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.
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 |
References arc_get_stats(), fsm_link_s::next, PROFILE, PROFILE_END, fsm_s::table, and fsm_link_s::table.
Referenced by report_gather_funit_stats(), and report_gather_instance_stats().
00420 { PROFILE(FSM_GET_STATS); 00421 00422 fsm_link* curr; /* Pointer to current FSM in table list */ 00423 00424 curr = table; 00425 while( curr != NULL ) { 00426 arc_get_stats( curr->table->table, state_hit, state_total, arc_hit, arc_total, arc_excluded ); 00427 curr = curr->next; 00428 } 00429 00430 PROFILE_END; 00431 00432 }
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.
base | Base FSM to store merged results | |
other | Other FSM that will be merged with the base FSM |
References arc_merge(), fsm_s::from_state, PROFILE, PROFILE_END, fsm_s::table, and fsm_s::to_state.
Referenced by funit_merge().
00359 { PROFILE(FSM_MERGE); 00360 00361 assert( base != NULL ); 00362 assert( base->from_state != NULL ); 00363 assert( base->to_state != NULL ); 00364 assert( other != NULL ); 00365 assert( other->from_state != NULL ); 00366 assert( other->to_state != NULL ); 00367 00368 if( base->table != NULL ) { 00369 assert( other->table != NULL ); 00370 arc_merge( base->table, other->table ); 00371 } 00372 00373 PROFILE_END; 00374 00375 }
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.
ofile | Pointer to file to output results to | |
verbose | Specifies whether or not to provide verbose information |
References curr_db, FALSE, fsm_display_funit_summary(), fsm_display_instance_summary(), fsm_funit_summary(), fsm_funit_verbose(), fsm_instance_summary(), fsm_instance_verbose(), funit_head, inst_link_s::inst, db_s::inst_head, funit_inst_s::name_diff, inst_link_s::next, PROFILE, PROFILE_END, report_covered, report_exclusions, report_instance, and funit_inst_s::suppl.
Referenced by report_generate().
01220 { PROFILE(FSM_REPORT); 01221 01222 bool missed_found = FALSE; /* If set to TRUE, FSM cases were found to be missed */ 01223 inst_link* instl; /* Pointer to current instance link */ 01224 int acc_st_hits = 0; /* Accumulated number of states hit */ 01225 int acc_st_total = 0; /* Accumulated number of states in design */ 01226 int acc_arc_hits = 0; /* Accumulated number of arcs hit */ 01227 int acc_arc_total = 0; /* Accumulated number of arcs in design */ 01228 01229 fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" ); 01230 fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FINITE STATE MACHINE COVERAGE RESULTS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" ); 01231 fprintf( ofile, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" ); 01232 01233 if( report_instance ) { 01234 01235 fprintf( ofile, " State Arc\n" ); 01236 fprintf( ofile, "Instance Hit/Miss/Total Percent hit Hit/Miss/Total Percent hit\n" ); 01237 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" ); 01238 01239 instl = db_list[curr_db]->inst_head; 01240 while( instl != NULL ) { 01241 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 ); 01242 instl = instl->next; 01243 } 01244 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" ); 01245 (void)fsm_display_instance_summary( ofile, "Accumulated", acc_st_hits, acc_st_total, acc_arc_hits, acc_arc_total ); 01246 01247 if( verbose && (missed_found || report_covered || report_exclusions) ) { 01248 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" ); 01249 instl = db_list[curr_db]->inst_head; 01250 while( instl != NULL ) { 01251 fsm_instance_verbose( ofile, instl->inst, (instl->inst->suppl.name_diff ? "<NA>" : "*") ); 01252 instl = instl->next; 01253 } 01254 } 01255 01256 } else { 01257 01258 fprintf( ofile, " State Arc\n" ); 01259 fprintf( ofile, "Module/Task/Function Filename Hit/Miss/Total Percent Hit Hit/Miss/Total Percent hit\n" ); 01260 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" ); 01261 01262 missed_found = fsm_funit_summary( ofile, db_list[curr_db]->funit_head, &acc_st_hits, &acc_st_total, &acc_arc_hits, &acc_arc_total ); 01263 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" ); 01264 (void)fsm_display_funit_summary( ofile, "Accumulated", "", acc_st_hits, acc_st_total, acc_arc_hits, acc_arc_total ); 01265 01266 if( verbose && (missed_found || report_covered || report_exclusions) ) { 01267 fprintf( ofile, "---------------------------------------------------------------------------------------------------------------------\n" ); 01268 fsm_funit_verbose( ofile, db_list[curr_db]->funit_head ); 01269 } 01270 01271 } 01272 01273 fprintf( ofile, "\n\n" ); 01274 01275 PROFILE_END; 01276 01277 }
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).
expr | Pointer to expression that contains FSM table to modify | |
time | Pointer to current simulation time |
References arc_add(), fsm_s::exclude, fsm_s::from_state, expression_s::id, PROFILE, PROFILE_END, sim_expr_changed(), fsm_s::table, expression_s::table, fsm_s::to_state, expression_s::value, and vector_copy().
Referenced by expression_operate().
00385 { PROFILE(FSM_TABLE_SET); 00386 00387 /* If the expression is the input state expression, make sure that the output state expression is simulated this clock period */ 00388 if( (expr->table->from_state->id == expr->id) && (expr->table->from_state->id != expr->table->to_state->id) ) { 00389 00390 sim_expr_changed( expr->table->to_state, time ); 00391 00392 /* Otherwise, add the state/state transition */ 00393 } else { 00394 00395 /* Add the states and state transition */ 00396 arc_add( expr->table->table, expr->table->from_state->value, expr->table->to_state->value, 1, expr->table->exclude ); 00397 00398 /* If from_state was not specified, we need to copy the current contents of to_state to from_state */ 00399 if( expr->table->from_state->id == expr->id ) { 00400 vector_copy( expr->value, expr->table->from_state->value ); 00401 } 00402 00403 } 00404 00405 PROFILE_END; 00406 00407 }