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

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

#include "assert.h"
#include "defines.h"
#include "lxt2_read.h"
#include "symtable.h"
#include "db.h"
#include "util.h"

Functions

char * vcdid (int value)
void vcd_callback (struct lxt2_rd_trace **lt, lxtint64_t *pnt_time, lxtint32_t *pnt_facidx, char **pnt_value)
void lxt_parse (const char *lxt_file)
 Parses and scores LXT-style dumpfile.


Variables

char user_msg [USER_MSG_LENGTH]
char * top_instance
bool instance_specified
symtablevcd_symtab
int vcd_symtab_size
symtable ** timestep_tab
bool one_instance_found
char ** curr_inst_scope
int curr_inst_scope_size
lxtint64_t vcd_prevtime = 0
bool vcd_prevtime_valid = FALSE
bool vcd_blackout


Function Documentation

void lxt_parse const char *  lxt_file  ) 
 

Parses and scores LXT-style dumpfile.

Exceptions:
anonymous db_do_timestep Throw Throw Throw lxt2_rd_iter_blocks
Main LXT parsing function. Reads in an LXT-style dumpfile, tells Covered about signal information and simulation results.
Parameters:
lxt_file  Name of LXT file to read and score

00144   { PROFILE(LXT_PARSE);
00145 
00146   struct lxt2_rd_trace*    lt;             /* LXT read structure */
00147   int                      i;              /* Loop iterator */
00148   int                      numfacs;        /* Number of symbols in design */
00149   struct lxt2_rd_geometry* g;
00150   lxtint32_t               newindx;
00151   char                     netname[4096];  /* Name of current signal */
00152 
00153   /* Open LXT file for opening and extract members */
00154   if( (lt = lxt2_rd_init( lxt_file )) != NULL ) {
00155 
00156     numfacs = lxt2_rd_get_num_facs( lt );
00157 
00158     (void)lxt2_rd_set_fac_process_mask_all( lt );
00159     (void)lxt2_rd_set_max_block_mem_usage( lt, 0 ); /* no need to cache blocks */
00160 
00161     /* Create initial symbol table */
00162     vcd_symtab = symtable_create();
00163 
00164     /* Allocate memory for instance scope */
00165     curr_inst_scope      = (char**)malloc_safe( sizeof( char* ) );
00166     curr_inst_scope[0]   = (char*)malloc_safe( 4096 );
00167     curr_inst_scope_size = 1;
00168 
00169     Try {
00170 
00171       /* Get symbol information */
00172       for( i=0; i<numfacs; i++ ) {
00173 
00174         g       = lxt2_rd_get_fac_geometry( lt, i );
00175         newindx = lxt2_rd_get_alias_root( lt, i );
00176 
00177         /* Extract scope and net name from facility name */
00178         scope_extract_back( lxt2_rd_get_facname( lt, i ), netname, curr_inst_scope[0] );
00179         db_sync_curr_instance();
00180 
00181         if( g->flags & LXT2_RD_SYM_F_DOUBLE ) {
00182 
00183           db_assign_symbol( netname, vcdid( newindx ), 63, 0 );
00184 
00185         } else if( g->flags & LXT2_RD_SYM_F_STRING ) {
00186 
00187           /* We ignore string values at the moment */
00188 
00189         } else {
00190 
00191           if( g->len == 1 ) {
00192             if( g->msb != 0 ) {
00193               db_assign_symbol( netname, vcdid( newindx ), g->msb, g->msb );
00194             } else {
00195               db_assign_symbol( netname, vcdid( newindx ), 0, 0 );
00196             }
00197           } else {
00198             db_assign_symbol( netname, vcdid( newindx ), g->msb, g->lsb );
00199           }
00200 
00201         }
00202 
00203       }
00204 
00205       /* Check to see that at least one instance was found */
00206       if( !one_instance_found ) {
00207 
00208         print_output( "No instances were found in specified VCD file that matched design", FATAL, __FILE__, __LINE__ );
00209 
00210         /* If the -i option was not specified, let the user know */
00211         if( !instance_specified ) {
00212           print_output( "  Please use -i option to specify correct hierarchy to top-level module to score",
00213                         FATAL, __FILE__, __LINE__ );
00214         } else {
00215           unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "  Incorrect hierarchical path specified in -i option: %s", top_instance );
00216           assert( rv < USER_MSG_LENGTH );
00217           print_output( user_msg, FATAL, __FILE__, __LINE__ );
00218         }
00219 
00220         Throw 0;
00221 
00222       }
00223 
00224       /* Create timestep symbol table array */
00225       if( vcd_symtab_size > 0 ) {
00226         timestep_tab = malloc_safe_nolimit( sizeof( symtable*) * vcd_symtab_size );
00227       }
00228 
00229       /* Perform simulation */
00230       (void)lxt2_rd_iter_blocks( lt, vcd_callback, NULL );
00231 
00232       /* Perform last simulation if necessary */
00233       if( vcd_prevtime_valid ) {
00234         (void)db_do_timestep( vcd_prevtime, FALSE );
00235       }
00236 
00237     } Catch_anonymous {
00238       assert( curr_inst_scope_size == 1 );
00239       free_safe( curr_inst_scope[0], 4096 );
00240       free_safe( curr_inst_scope, sizeof( char* ) );
00241       curr_inst_scope      = NULL;
00242       curr_inst_scope_size = 0;
00243       symtable_dealloc( vcd_symtab );
00244       free_safe( timestep_tab, (sizeof( symtable* ) * vcd_symtab_size) );
00245       lxt2_rd_close( lt );
00246       Throw 0;
00247     }
00248 
00249     /* Deallocate memory */
00250     assert( curr_inst_scope_size == 1 );
00251     free_safe( curr_inst_scope[0], 4096 );
00252     free_safe( curr_inst_scope, sizeof( char* ) );
00253     curr_inst_scope      = NULL;
00254     curr_inst_scope_size = 0;
00255     symtable_dealloc( vcd_symtab );
00256     free_safe( timestep_tab, (sizeof( symtable* ) * vcd_symtab_size) );
00257 
00258     /* Close LXT file */
00259     lxt2_rd_close( lt );
00260 
00261   } else {
00262 
00263     print_output( "Unable to read data from LXT dumpfile.  Exiting without scoring.", FATAL, __FILE__, __LINE__ );
00264     Throw 0;
00265 
00266   }
00267 
00268   PROFILE_END;
00269 
00270 }

void vcd_callback struct lxt2_rd_trace **  lt,
lxtint64_t pnt_time,
lxtint32_t pnt_facidx,
char **  pnt_value
[static]
 

Exceptions:
anonymous db_do_timestep

00089   { PROFILE(VCD_CALLBACK);
00090 
00091   struct lxt2_rd_geometry *g = lxt2_rd_get_fac_geometry( *lt, *pnt_facidx );
00092 
00093   /* If this is a new timestamp, perform a simulation */
00094   if( (vcd_prevtime != *pnt_time) || !vcd_prevtime_valid ) {
00095     if( vcd_prevtime_valid ) {
00096       (void)db_do_timestep( vcd_prevtime, FALSE );
00097     }
00098     vcd_prevtime       = *pnt_time;
00099     vcd_prevtime_valid = TRUE;
00100   }
00101 
00102   /* Handle dumpon/off information */
00103   if( !(*pnt_value)[0] ) {
00104     if( !vcd_blackout ) {
00105       vcd_blackout = TRUE;
00106     }
00107     return;
00108   } else {
00109     if( vcd_blackout ) {
00110       vcd_blackout = FALSE;
00111     }   
00112   }
00113 
00114   if( g->flags & LXT2_RD_SYM_F_DOUBLE ) {
00115 
00116     db_set_symbol_string( vcdid( *pnt_facidx ), *pnt_value );
00117 
00118   } else if( g->flags & LXT2_RD_SYM_F_STRING ) {
00119 
00120     /* We ignore string values for now */
00121 
00122   } else {
00123 
00124     if( g->len==1 ) {
00125       db_set_symbol_char( vcdid( *pnt_facidx ), (*pnt_value)[0] );
00126     } else {                        
00127       db_set_symbol_string( vcdid( *pnt_facidx ), *pnt_value );
00128     }
00129 
00130   }                               
00131 
00132   PROFILE_END;
00133 
00134 }

char* vcdid int  value  )  [static]
 

Returns:
Returns a unique string ID for the given value
Parameters:
value  Unique ID for a specific signal

00061   { PROFILE(VCDID);
00062 
00063   static char buf[16];
00064   int         i;
00065 
00066   for( i=0; i<15; i++ ) {
00067     buf[i] = (char)((value % 94) + 33); /* for range 33..126 */
00068     value  = value / 94;
00069     if( !value ) {
00070       buf[i+1] = 0;
00071       break;
00072     }
00073   }
00074 
00075   PROFILE_END;
00076 
00077   return( buf );
00078 
00079 }


Variable Documentation

char** curr_inst_scope
 

Specifies the string Verilog scope that is currently specified in the VCD file.

int curr_inst_scope_size
 

Current size of curr_inst_scope array

bool instance_specified
 

Specifies if -i option was specified

bool one_instance_found
 

This flag is used to indicate if Covered was successfull in finding at least one matching instance from the VCD file. If no instances were found for the entire VCD file, the user has either not specified the -i option or has specified an incorrect path to the top-level module instance so let them know about this.

symtable** timestep_tab
 

Pointer to the current timestep table array. Please see the file description for how this structure is used.

char* top_instance
 

Name of top-level instance name

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.

bool vcd_blackout [static]
 

Specifies when we are handling dumping

lxtint64_t vcd_prevtime = 0 [static]
 

Specifies the last timestamp simulated

bool vcd_prevtime_valid = FALSE [static]
 

Specifies the vcd_prevtime value has been assigned by the simulator

symtable* vcd_symtab
 

Pointer to the VCD symbol table. Please see the file description for how this structure is used.

int vcd_symtab_size
 

Maintains current number of nodes in the VCD symbol table. This value is used to create the appropriately sized timestep_tab array.


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