#include "assert.h"
#include "defines.h"
#include "lxt2_read.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <unistd.h>
#include <inttypes.h>
#include "symtable.h"
#include "db.h"
#include "util.h"
Functions | |
static char * | vcdid (int value) |
static 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] |
symtable * | vcd_symtab |
int | vcd_symtab_size |
symtable ** | timestep_tab |
char ** | curr_inst_scope |
int | curr_inst_scope_size |
static lxtint64_t | vcd_prevtime = 0 |
static bool | vcd_prevtime_valid = FALSE |
static bool | vcd_blackout |
void lxt_parse | ( | const char * | lxt_file | ) |
Parses and scores LXT-style dumpfile.
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.
lxt_file | Name of LXT file to read and score |
References Catch_anonymous, curr_inst_scope, curr_inst_scope_size, db_assign_symbol(), db_check_dumpfile_scopes(), db_do_timestep(), db_sync_curr_instance(), FALSE, FATAL, lxt2_rd_geometry::flags, free_safe, lxt2_rd_geometry::len, lxt2_rd_geometry::lsb, lxt2_rd_close(), lxt2_rd_get_alias_root(), lxt2_rd_get_fac_geometry(), lxt2_rd_get_facname(), lxt2_rd_get_num_facs(), lxt2_rd_init(), lxt2_rd_iter_blocks(), lxt2_rd_set_fac_process_mask_all(), lxt2_rd_set_max_block_mem_usage(), LXT2_RD_SYM_F_DOUBLE, LXT2_RD_SYM_F_STRING, malloc_safe, malloc_safe_nolimit, lxt2_rd_geometry::msb, lxt2_rd_trace::numfacs, print_output(), PROFILE, PROFILE_END, scope_extract_back(), symtable_create(), symtable_dealloc(), Throw, Try, vcd_callback(), vcd_prevtime, vcd_prevtime_valid, vcd_symtab_size, and vcdid().
Referenced by parse_and_score_dumpfile().
00141 { PROFILE(LXT_PARSE); 00142 00143 struct lxt2_rd_trace* lt; /* LXT read structure */ 00144 int i; /* Loop iterator */ 00145 int numfacs; /* Number of symbols in design */ 00146 struct lxt2_rd_geometry* g; 00147 lxtint32_t newindx; 00148 char netname[4096]; /* Name of current signal */ 00149 00150 /* Open LXT file for opening and extract members */ 00151 if( (lt = lxt2_rd_init( lxt_file )) != NULL ) { 00152 00153 numfacs = lxt2_rd_get_num_facs( lt ); 00154 00155 (void)lxt2_rd_set_fac_process_mask_all( lt ); 00156 (void)lxt2_rd_set_max_block_mem_usage( lt, 0 ); /* no need to cache blocks */ 00157 00158 /* Create initial symbol table */ 00159 vcd_symtab = symtable_create(); 00160 00161 /* Allocate memory for instance scope */ 00162 curr_inst_scope = (char**)malloc_safe( sizeof( char* ) ); 00163 curr_inst_scope[0] = (char*)malloc_safe( 4096 ); 00164 curr_inst_scope_size = 1; 00165 00166 Try { 00167 00168 /* Get symbol information */ 00169 for( i=0; i<numfacs; i++ ) { 00170 00171 g = lxt2_rd_get_fac_geometry( lt, i ); 00172 newindx = lxt2_rd_get_alias_root( lt, i ); 00173 00174 /* Extract scope and net name from facility name */ 00175 scope_extract_back( lxt2_rd_get_facname( lt, i ), netname, curr_inst_scope[0] ); 00176 db_sync_curr_instance(); 00177 00178 if( g->flags & LXT2_RD_SYM_F_DOUBLE ) { 00179 00180 db_assign_symbol( netname, vcdid( newindx ), 63, 0 ); 00181 00182 } else if( g->flags & LXT2_RD_SYM_F_STRING ) { 00183 00184 /* We ignore string values at the moment */ 00185 00186 } else { 00187 00188 if( g->len == 1 ) { 00189 if( g->msb != 0 ) { 00190 db_assign_symbol( netname, vcdid( newindx ), g->msb, g->msb ); 00191 } else { 00192 db_assign_symbol( netname, vcdid( newindx ), 0, 0 ); 00193 } 00194 } else { 00195 db_assign_symbol( netname, vcdid( newindx ), g->msb, g->lsb ); 00196 } 00197 00198 } 00199 00200 } 00201 00202 /* Check to see that at least one instance was found */ 00203 db_check_dumpfile_scopes(); 00204 00205 /* Create timestep symbol table array */ 00206 if( vcd_symtab_size > 0 ) { 00207 timestep_tab = malloc_safe_nolimit( sizeof( symtable*) * vcd_symtab_size ); 00208 } 00209 00210 /* Perform simulation */ 00211 (void)lxt2_rd_iter_blocks( lt, vcd_callback, NULL ); 00212 00213 /* Perform last simulation if necessary */ 00214 if( vcd_prevtime_valid ) { 00215 (void)db_do_timestep( vcd_prevtime, FALSE ); 00216 } 00217 00218 } Catch_anonymous { 00219 assert( curr_inst_scope_size == 1 ); 00220 free_safe( curr_inst_scope[0], 4096 ); 00221 free_safe( curr_inst_scope, sizeof( char* ) ); 00222 curr_inst_scope = NULL; 00223 curr_inst_scope_size = 0; 00224 symtable_dealloc( vcd_symtab ); 00225 free_safe( timestep_tab, (sizeof( symtable* ) * vcd_symtab_size) ); 00226 lxt2_rd_close( lt ); 00227 Throw 0; 00228 } 00229 00230 /* Deallocate memory */ 00231 assert( curr_inst_scope_size == 1 ); 00232 free_safe( curr_inst_scope[0], 4096 ); 00233 free_safe( curr_inst_scope, sizeof( char* ) ); 00234 curr_inst_scope = NULL; 00235 curr_inst_scope_size = 0; 00236 symtable_dealloc( vcd_symtab ); 00237 free_safe( timestep_tab, (sizeof( symtable* ) * vcd_symtab_size) ); 00238 00239 /* Close LXT file */ 00240 lxt2_rd_close( lt ); 00241 00242 } else { 00243 00244 print_output( "Unable to read data from LXT dumpfile. Exiting without scoring.", FATAL, __FILE__, __LINE__ ); 00245 Throw 0; 00246 00247 } 00248 00249 PROFILE_END; 00250 00251 }
static void vcd_callback | ( | struct lxt2_rd_trace ** | lt, | |
lxtint64_t * | pnt_time, | |||
lxtint32_t * | pnt_facidx, | |||
char ** | pnt_value | |||
) | [static] |
anonymous | db_do_timestep |
References db_do_timestep(), db_set_symbol_char(), db_set_symbol_string(), FALSE, lxt2_rd_geometry::flags, lxt2_rd_geometry::len, lxt2_rd_get_fac_geometry(), LXT2_RD_SYM_F_DOUBLE, LXT2_RD_SYM_F_STRING, PROFILE, PROFILE_END, TRUE, vcd_blackout, vcd_prevtime, vcd_prevtime_valid, and vcdid().
Referenced by lxt_parse().
00086 { PROFILE(VCD_CALLBACK); 00087 00088 struct lxt2_rd_geometry *g = lxt2_rd_get_fac_geometry( *lt, *pnt_facidx ); 00089 00090 /* If this is a new timestamp, perform a simulation */ 00091 if( (vcd_prevtime != *pnt_time) || !vcd_prevtime_valid ) { 00092 if( vcd_prevtime_valid ) { 00093 (void)db_do_timestep( vcd_prevtime, FALSE ); 00094 } 00095 vcd_prevtime = *pnt_time; 00096 vcd_prevtime_valid = TRUE; 00097 } 00098 00099 /* Handle dumpon/off information */ 00100 if( !(*pnt_value)[0] ) { 00101 if( !vcd_blackout ) { 00102 vcd_blackout = TRUE; 00103 } 00104 return; 00105 } else { 00106 if( vcd_blackout ) { 00107 vcd_blackout = FALSE; 00108 } 00109 } 00110 00111 if( g->flags & LXT2_RD_SYM_F_DOUBLE ) { 00112 00113 db_set_symbol_string( vcdid( *pnt_facidx ), *pnt_value ); 00114 00115 } else if( g->flags & LXT2_RD_SYM_F_STRING ) { 00116 00117 /* We ignore string values for now */ 00118 00119 } else { 00120 00121 if( g->len==1 ) { 00122 db_set_symbol_char( vcdid( *pnt_facidx ), (*pnt_value)[0] ); 00123 } else { 00124 db_set_symbol_string( vcdid( *pnt_facidx ), *pnt_value ); 00125 } 00126 00127 } 00128 00129 PROFILE_END; 00130 00131 }
static char* vcdid | ( | int | value | ) | [static] |
value | Unique ID for a specific signal |
References PROFILE, and PROFILE_END.
Referenced by lxt_parse(), and vcd_callback().
00058 { PROFILE(VCDID); 00059 00060 static char buf[16]; 00061 int i; 00062 00063 for( i=0; i<15; i++ ) { 00064 buf[i] = (char)((value % 94) + 33); /* for range 33..126 */ 00065 value = value / 94; 00066 if( !value ) { 00067 buf[i+1] = 0; 00068 break; 00069 } 00070 } 00071 00072 PROFILE_END; 00073 00074 return( buf ); 00075 00076 }
char** curr_inst_scope |
Specifies the string Verilog scope that is currently specified in the VCD file.
Current size of curr_inst_scope array
Pointer to the current timestep table array. Please see the file description for how this structure is used.
char user_msg[USER_MSG_LENGTH] |
lxt.c |
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
Referenced by vcd_callback().
lxtint64_t vcd_prevtime = 0 [static] |
Specifies the last timestamp simulated
Referenced by lxt_parse(), and vcd_callback().
bool vcd_prevtime_valid = FALSE [static] |
Specifies the vcd_prevtime value has been assigned by the simulator
Referenced by lxt_parse(), and vcd_callback().
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.