score.h File Reference

Contains functions for score command. More...

Go to the source code of this file.

Functions

void score_generate_top_dumpvars_module (const char *dumpvars_file)
 Creates a module that contains all of the signals to dump from the design for coverage purposes.
void score_parse_define (const char *def)
 Parses the specified define from the command-line.
void command_score (int argc, int last_arg, const char **argv)
 Parses score command-line and performs score.

Detailed Description

Contains functions for score command.

Author:
Trevor Williams (phase1geo@gmail.com)
Date:
11/29/2001

Function Documentation

void command_score ( int  argc,
int  last_arg,
const char **  argv 
)

Parses score command-line and performs score.

Performs score command functionality.

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

References Catch_anonymous, COVERED_HEADER, db_close(), db_create(), defparam_dealloc(), DFLT_OUTPUT_CDD, directive_filename, dump_file, DUMP_FMT_FST, DUMP_FMT_LXT, DUMP_FMT_NONE, DUMP_FMT_VCD, dump_mode, dumpvars_file, FALSE, flag_display_sim_stats, free_safe, fsm_var_cleanup(), HEADER, largest_malloc_size, NORMAL, output_db, parse_and_score_dumpfile(), parse_design(), perf_output_inst_report(), ppfilename, pragma_coverage_name, pragma_racecheck_name, print_output(), PROFILE, PROFILE_END, score_generate_pli_tab_file(), score_generate_top_vpi_module(), score_parse_args(), search_free_lists(), search_init(), str_link_delete_list(), strdup_safe, sys_task_dealloc(), Throw, timescale, top_instance, top_module, TRUE, Try, user_msg, USER_MSG_LENGTH, and vpi_file.

Referenced by main().

01179   { PROFILE(COMMAND_SCORE);
01180 
01181   unsigned int rv;  /* Return value from snprintf calls */
01182   bool         error = FALSE;
01183 
01184   /* Output header information */
01185   rv = snprintf( user_msg, USER_MSG_LENGTH, COVERED_HEADER );
01186   assert( rv < USER_MSG_LENGTH );
01187   print_output( user_msg, HEADER, __FILE__, __LINE__ );
01188 
01189   Try {
01190 
01191     /* Create a database to start storing the results */
01192     (void)db_create();
01193 
01194     /* Parse score command-line */
01195     if( !score_parse_args( argc, last_arg, argv ) ) {
01196 
01197       if( output_db == NULL ) {
01198         output_db = strdup_safe( DFLT_OUTPUT_CDD );
01199       }
01200  
01201       /* Parse design */
01202       if( use_files_head != NULL ) {
01203         print_output( "Reading design...", NORMAL, __FILE__, __LINE__ );
01204         search_init();
01205         parse_design( top_module, output_db );
01206         print_output( "", NORMAL, __FILE__, __LINE__ );
01207       }
01208 
01209       /* Generate VPI-based top module */
01210       if( vpi_file != NULL ) {
01211 
01212         rv = snprintf( user_msg, USER_MSG_LENGTH, "Outputting VPI file %s...", vpi_file );
01213         assert( rv < USER_MSG_LENGTH );
01214         print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01215         score_generate_top_vpi_module( vpi_file, output_db, top_instance );
01216         score_generate_pli_tab_file( vpi_file, top_module );
01217 
01218       /* Read dumpfile and score design */
01219       } else if( dump_mode != DUMP_FMT_NONE ) {
01220 
01221         switch( dump_mode ) {
01222           case DUMP_FMT_VCD :  rv = snprintf( user_msg, USER_MSG_LENGTH, "Scoring VCD dumpfile %s...", dump_file );  break;
01223           case DUMP_FMT_LXT :  rv = snprintf( user_msg, USER_MSG_LENGTH, "Scoring LXT dumpfile %s...", dump_file );  break;
01224           case DUMP_FMT_FST :  rv = snprintf( user_msg, USER_MSG_LENGTH, "Scoring FST dumpfile %s...", dump_file );  break;
01225         }
01226         assert( rv < USER_MSG_LENGTH );
01227         print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01228         parse_and_score_dumpfile( output_db, dump_file, dump_mode );
01229         print_output( "", NORMAL, __FILE__, __LINE__ );
01230 
01231       }
01232 
01233       if( dump_mode != DUMP_FMT_NONE ) {
01234         print_output( "***  Scoring completed successfully!  ***\n", NORMAL, __FILE__, __LINE__ );
01235       }
01236       /*@-duplicatequals -formatcode -formattype@*/
01237       rv = snprintf( user_msg, USER_MSG_LENGTH, "Dynamic memory allocated:   %" FMT64 "u bytes", largest_malloc_size );
01238       assert( rv < USER_MSG_LENGTH );
01239       /*@=duplicatequals =formatcode =formattype@*/
01240       print_output( user_msg, NORMAL, __FILE__, __LINE__ );
01241       print_output( "", NORMAL, __FILE__, __LINE__ );
01242 
01243       /* Display simulation statistics if specified */
01244       if( flag_display_sim_stats ) {
01245         perf_output_inst_report( stdout );
01246       }
01247 
01248     }
01249 
01250   } Catch_anonymous {
01251     fsm_var_cleanup();
01252     error = TRUE;
01253   }
01254 
01255   /* Close database */
01256   db_close();
01257 
01258   /* Deallocate memory for search engine */
01259   search_free_lists();
01260 
01261   /* Deallocate memory for defparams */
01262   defparam_dealloc();
01263 
01264   /* Deallocate memory for system tasks */
01265   sys_task_dealloc();
01266 
01267   /* Deallocate generation module string list */
01268   str_link_delete_list( gen_mod_head );
01269 
01270   /* Deallocate race ignore string list */
01271   str_link_delete_list( race_ignore_mod_head );
01272 
01273   free_safe( output_db, (strlen( output_db ) + 1) );
01274   free_safe( dump_file, (strlen( dump_file ) + 1) );
01275   free_safe( vpi_file, (strlen( vpi_file ) + 1) );
01276   free_safe( dumpvars_file, (strlen( dumpvars_file ) + 1) );
01277   free_safe( top_module, (strlen( top_module ) + 1) );
01278   free_safe( ppfilename, (strlen( ppfilename ) + 1) );
01279   ppfilename = NULL;
01280 
01281   free_safe( directive_filename, (strlen( directive_filename ) + 1) );
01282   free_safe( top_instance, (strlen( top_instance ) + 1) );
01283   free_safe( timescale, (strlen( timescale ) + 1) );
01284   free_safe( pragma_coverage_name, (strlen( pragma_coverage_name ) + 1) );
01285   free_safe( pragma_racecheck_name, (strlen( pragma_racecheck_name ) + 1) );
01286 
01287   if( error ) {
01288     Throw 0;
01289   }
01290 
01291   PROFILE_END;
01292 
01293 }

void score_generate_top_dumpvars_module ( const char *  dumpvars_file  ) 

Creates a module that contains all of the signals to dump from the design for coverage purposes.

Exceptions:
anonymous Throw

Creates the dumpvars top-level module to use for dumping only needed portions of the design to the designated dumpfile.

Parameters:
dumpvars_file Name of dumpvars file to create

References Catch_anonymous, db_output_dumpvars(), FATAL, free_safe, print_output(), PROFILE, PROFILE_END, scope_extract_front(), strdup_safe, Throw, timescale, Try, user_msg, and USER_MSG_LENGTH.

Referenced by parse_design().

00354   { PROFILE(SCORE_GENERATE_TOP_DUMPVARS_MODULE);
00355 
00356   FILE* vfile;     /* File handle to top-level module */
00357   char* mod_name;  /* Name of dumpvars module */
00358   char* ext;       /* Extension of dumpvars module */
00359 
00360   /* Extract the name of the module from the given filename */
00361   mod_name = strdup_safe( dumpvars_file );
00362   ext      = strdup_safe( dumpvars_file );
00363   scope_extract_front( dumpvars_file, mod_name, ext );
00364 
00365   Try {
00366 
00367     if( ext[0] != '\0' ) {
00368 
00369       if( (vfile = fopen( dumpvars_file, "w" )) != NULL ) {
00370 
00371         unsigned int rv;
00372         if( timescale != NULL ) {
00373           fprintf( vfile, "`timescale %s\n", timescale );
00374         }
00375         fprintf( vfile, "module %s;\n", mod_name );
00376         fprintf( vfile, "initial begin\n" );
00377         fprintf( vfile, "  $dumpfile( \"%s.vcd\" );\n", mod_name );
00378         db_output_dumpvars( vfile );
00379         fprintf( vfile, "end\n" );
00380         fprintf( vfile, "endmodule\n" );
00381         rv = fclose( vfile );
00382         assert( rv == 0 );
00383 
00384       } else {
00385 
00386         unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Unable to open %s for writing", dumpvars_file );
00387         assert( rv < USER_MSG_LENGTH );
00388         print_output( user_msg, FATAL, __FILE__, __LINE__ );
00389         Throw 0;
00390 
00391       }
00392 
00393     } else {
00394 
00395       print_output( "Specified -dumpvars filename did not contain a file extension", FATAL, __FILE__, __LINE__ );
00396       Throw 0;
00397 
00398     }
00399 
00400   } Catch_anonymous {
00401     free_safe( mod_name, (strlen( mod_name ) + 1) );
00402     free_safe( ext, (strlen( ext ) + 1) );
00403     Throw 0;
00404   }
00405 
00406   /* Deallocate memory */
00407   free_safe( mod_name, (strlen( dumpvars_file ) + 1) );
00408   free_safe( ext, (strlen( dumpvars_file ) + 1) );
00409 
00410   PROFILE_END;
00411 
00412 }

void score_parse_define ( const char *  def  ) 

Parses the specified define from the command-line.

Parameters:
def Define value to parse

Parses the specified define from the command-line, storing the define value in the define tree according to its value.

References define_macro(), free_safe, PROFILE, and strdup_safe.

Referenced by score_parse_args().

00482                                            { PROFILE(SCORE_PARSE_DEFINE);
00483 
00484   char* tmp = strdup_safe( def );  /* Temporary copy of the given argument */
00485   char* ptr = tmp;                 /* Pointer to current character in define */
00486 
00487   while( (*ptr != '\0') && (*ptr != '=') ) {
00488     ptr++;
00489   }
00490 
00491   if( *ptr == '=' ) {
00492     *ptr = '\0';
00493     ptr++;
00494     define_macro( tmp, ptr );
00495   } else {
00496     define_macro( tmp, "" );
00497   }
00498 
00499   /* Deallocate memory */
00500   free_safe( tmp, (strlen( def ) + 1) );
00501 
00502 }

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