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

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


Detailed Description

Author:
Trevor Williams (phase1geo@gmail.com)
Date:
5/6/2005

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "vpi_user.h"
#include "binding.h"
#include "db.h"
#include "defines.h"
#include "instance.h"
#include "link.h"
#include "obfuscate.h"
#include "profiler.h"
#include "symtable.h"
#include "sys_tasks.h"
#include "util.h"

Data Structures

struct  sym_value_s

Typedefs

typedef sym_value_s sym_value

Functions

void vpi_print_output (const char *msg)
 Displays the given message to standard output.

void sym_value_store (char *sym, char *value)
void add_sym_values_to_sim ()
PLI_INT32 covered_value_change_bin (p_cb_data cb)
PLI_INT32 covered_value_change_real (p_cb_data cb)
PLI_INT32 covered_end_of_sim (p_cb_data cb)
PLI_INT32 covered_cb_error_handler (p_cb_data cb)
char * gen_next_symbol ()
void covered_create_value_change_cb (vpiHandle sig)
void covered_parse_task_func (vpiHandle mod)
void covered_parse_signals (vpiHandle mod)
void covered_parse_instance (vpiHandle inst)
PLI_INT32 covered_sim_calltf (char *name)
void covered_register ()

Variables

char in_db_name [1024]
char out_db_name [1024]
uint64 last_time = 0
sym_valuesv_head = NULL
sym_valuesv_tail = NULL
bool report_gui = FALSE
bool one_instance_found = FALSE
int timestep_update = 0
bool report_covered = FALSE
bool flag_use_line_width = FALSE
int line_width = DEFAULT_LINE_WIDTH
bool report_instance = FALSE
int flag_race_check = WARNING
tnodedef_table = NULL
int fork_depth = -1
int * fork_block_depth
int block_depth = 0
int merge_in_num
char ** merge_in = NULL
char * top_module = NULL
char * top_instance = NULL
unsigned int flag_global_generation = GENERATION_SV
int generate_expr_mode = 0
bool cli_debug_mode = FALSE
bool flag_use_command_line_debug = FALSE
exception_context the_exception_context [1]
str_linkmerge_in_head = NULL
str_linkmerge_in_tail = NULL
char * cdd_message = NULL
char * merged_file = NULL
bool flag_output_exclusion_ids = FALSE
bool report_exclusions = FALSE
str_linkrace_ignore_mod_head = NULL
str_linkrace_ignore_mod_tail = NULL
bool debug_mode
symtablevcd_symtab
int vcd_symtab_size
symtable ** timestep_tab
char ** curr_inst_scope
int curr_inst_scope_size
funit_instcurr_instance
char user_msg [USER_MSG_LENGTH]
isuppl info_suppl
void(* vlog_startup_routines [])()=


Typedef Documentation

typedef struct sym_value_s sym_value
 

Renaming sym_value_s structure for convenience.


Function Documentation

void add_sym_values_to_sim  ) 
 

Iterates through the sym_value list, adding the information to Covered's simulation core and deallocating its memory. Called by the covered_sim_calltf function.

00149                              { PROFILE(ADD_SYM_VALUES_TO_SIM);
00150 
00151   sym_value* sval;  /* Pointer to current sym_value structure */
00152 
00153   sval = sv_head;
00154   while( sv_head != NULL ) {
00155 
00156     /* Assign the current sv_head to the sval pointer */
00157     sval    = sv_head;
00158     sv_head = sv_head->next;
00159 
00160     /* Set the given symbol to the given value in Covered's simulator */
00161     db_set_symbol_string( sval->sym, sval->value );
00162 
00163     /* Deallocate all memory associated with this sym_table structure */
00164     free_safe( sval->sym, (strlen( sval->sym ) + 1) );
00165     free_safe( sval->value, (strlen( sval->value ) + 1) );
00166     free_safe( sval, sizeof( sym_value ) );
00167   }
00168 
00169   PROFILE_END;
00170 
00171 }

PLI_INT32 covered_cb_error_handler p_cb_data  cb  ) 
 

00357                                                    { PROFILE(COVERED_CB_ERROR_HANDLER);
00358 
00359   struct t_vpi_error_info einfotab;
00360   struct t_vpi_error_info *einfop;
00361   char   s1[128];
00362 
00363   einfop = &einfotab;
00364   vpi_chk_error( einfop );
00365 
00366   if( einfop->state == vpiCompile ) {
00367     strcpy( s1, "vpiCompile" );
00368   } else if( einfop->state == vpiPLI ) {
00369     strcpy( s1, "vpiPLI" );
00370   } else if( einfop->state == vpiRun ) {
00371     strcpy( s1, "vpiRun" );
00372   } else {
00373     strcpy( s1, "**unknown**" );
00374   }
00375 
00376   vpi_printf( "covered VPI: ERR(%s) %s (level %d) at **%s(%d):\n  %s\n",
00377     einfop->code, s1, einfop->level, obf_file( einfop->file ), einfop->line, einfop->message );
00378 
00379   /* If serious error give up */
00380   if( (einfop->level == vpiError) || (einfop->level == vpiSystem) || (einfop->level == vpiInternal) ) {
00381     vpi_printf( "covered VPI: FATAL: encountered error - giving up\n" );
00382     vpi_control( vpiFinish, 0 );
00383   }
00384 
00385   PROFILE_END;
00386 
00387   return( 0 );
00388 
00389 }

void covered_create_value_change_cb vpiHandle  sig  ) 
 

Finds the given VPI signal in Covered's database and creates a callback function that will be called whenever this signal changes value during simulation. Also retrieves the initial value of the signal and stores it in the sym_value list and creates a symbol in the symtable structure for this signal.

Parameters:
sig  Pointer to vpiHandle for a given signal

00423   { PROFILE(COVERED_CREATE_VALUE_CHANGE_CB);
00424 
00425   p_cb_data   cb;
00426   sig_link*   vsigl = NULL;
00427   vsignal*    vsig  = NULL;
00428   func_unit*  found_funit;
00429   char*       symbol;
00430   s_vpi_value value;
00431 
00432   /* Only add the signal if it is in our database and needs to be assigned from the simulator */
00433   if( (curr_instance->funit != NULL) &&
00434       (((vsigl = sig_link_find( vpi_get_str( vpiName, sig ), curr_instance->funit->sig_head )) != NULL) ||
00435        scope_find_signal( vpi_get_str( vpiName, sig ), curr_instance->funit, &vsig, &found_funit, 0 )) &&
00436       (((vsigl != NULL) && (vsigl->sig->suppl.part.assigned == 0)) ||
00437        ((vsig  != NULL) && (vsig->suppl.part.assigned == 0))) ) {
00438 
00439     if( vsigl != NULL ) {
00440       vsig = vsigl->sig;
00441     }
00442 
00443 #ifdef DEBUG_MODE
00444     if( debug_mode ) {
00445       unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Adding callback for signal: %s", obf_sig( vsig->name ) );
00446       assert( rv < USER_MSG_LENGTH );
00447       print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00448     }
00449 #endif
00450 
00451     /* Generate new symbol */
00452     if( (symbol = gen_next_symbol()) == NULL ) {
00453       vpi_printf( "covered VPI: INTERNAL ERROR:  Unable to generate unique symbol name\n" );
00454       /* Need to increase number of characters in symbol array */
00455       vpi_control( vpiFinish, 0 );
00456     }
00457 
00458     /* Add signal/symbol to symtab database */
00459     db_assign_symbol( vpi_get_str( vpiName, sig ), symbol, ((vsig->value->width + vsig->dim[0].lsb) - 1), vsig->dim[0].lsb ); 
00460 
00461     /* Get initial value of this signal and store it for later retrieval */
00462     if( vpi_get( vpiType, sig ) == vpiRealVar ) {
00463 
00464       char real_str[64];
00465       value.format = vpiRealVal;
00466       vpi_get_value( sig, &value );
00467       snprintf( real_str, 64, "%f", value.value.real );
00468       sym_value_store( symbol, real_str );
00469 
00470     } else {
00471 
00472       value.format = vpiBinStrVal;
00473       vpi_get_value( sig, &value );
00474       sym_value_store( symbol, value.value.str );
00475 
00476     }
00477 
00478     /* Add a callback for a value change to this net */
00479     cb                   = (p_cb_data)malloc( sizeof( s_cb_data ) );
00480     cb->reason           = cbValueChange;
00481     if( vpi_get( vpiType, sig ) == vpiRealVar ) {
00482       cb->cb_rtn         = covered_value_change_real;
00483     } else {
00484       cb->cb_rtn         = covered_value_change_bin;
00485     }
00486     cb->obj              = sig;
00487     cb->time             = (p_vpi_time)malloc( sizeof( s_vpi_time ) ); 
00488     cb->time->type       = vpiSimTime;
00489     cb->time->high       = 0;
00490     cb->time->low        = 0;
00491 #ifdef NOIV
00492     cb->value            = (p_vpi_value)malloc( sizeof( s_vpi_value ) );
00493     if( vpi_get( vpiType, sig ) == vpiRealVar ) {
00494       cb->value->format    = vpiRealVal;
00495     } else {
00496       cb->value->format    = vpiBinStrVal;
00497       cb->value->value.str = NULL;
00498     }
00499 #else
00500     cb->value            = NULL;
00501 #endif
00502     cb->user_data        = symbol;
00503     vpi_register_cb( cb );
00504 
00505   }
00506 
00507   PROFILE_END;
00508 
00509 }

PLI_INT32 covered_end_of_sim p_cb_data  cb  ) 
 

00305                                              { PROFILE(COVERED_END_OF_SIM);
00306 
00307   p_vpi_time final_time;
00308 
00309   (void)db_do_timestep( last_time, FALSE );
00310 
00311   /* Get the final simulation time */
00312   final_time       = (p_vpi_time)malloc_safe( sizeof( s_vpi_time ) );
00313   final_time->type = vpiSimTime;
00314   vpi_get_time( NULL, final_time );
00315 
00316   /* Flush any pending statement trees that are waiting for delay */
00317   last_time = ((uint64)final_time->high << 32) | (uint64)final_time->low;
00318   (void)db_do_timestep( last_time, FALSE );
00319 
00320   /* Perform one last simulation timestep */
00321   (void)db_do_timestep( 0, TRUE );
00322 
00323   /* Indicate that this CDD contains scored information */
00324   info_suppl.part.scored = 1;
00325 
00326   /* Write contents to database file */
00327   Try {
00328     db_write( out_db_name, FALSE, FALSE, FALSE );
00329     vpi_printf( "covered VPI: Output coverage information to %s\n", out_db_name );
00330   } Catch_anonymous {
00331     vpi_printf( "covered VPI: Unable to write database file\n" );
00332   }
00333 
00334   /* Deallocate memory */
00335   if( curr_inst_scope_size > 0 ) {
00336     unsigned int i;
00337     for( i=0; i<curr_inst_scope_size; i++ ) {
00338       free_safe( curr_inst_scope[i], (strlen( curr_inst_scope[i] ) + 1) );
00339     }
00340     free_safe( curr_inst_scope, sizeof( char* ) );
00341     curr_inst_scope_size = 0;
00342   }
00343   symtable_dealloc( vcd_symtab );
00344   sim_dealloc();
00345   sys_task_dealloc();
00346   db_close();
00347   if( timestep_tab != NULL ) {
00348     free_safe( timestep_tab, (sizeof( symtable*) * vcd_symtab_size) );
00349   }
00350 
00351   PROFILE_END;
00352 
00353   return( 0 );
00354 
00355 }

void covered_parse_instance vpiHandle  inst  ) 
 

00678                                               { PROFILE(COVERED_PARSE_INSTANCE);
00679 
00680   vpiHandle iter, handle;
00681 
00682   /* Set current scope in database */
00683   if( curr_inst_scope[0] != NULL ) {
00684     free_safe( curr_inst_scope[0], (strlen( curr_inst_scope[0] ) + 1) );
00685   }
00686   curr_inst_scope[0] = strdup_safe( vpi_get_str( vpiFullName, inst ) );
00687   curr_inst_scope_size = 1;
00688 
00689   /* Synchronize curr_instance to point to curr_inst_scope */
00690   db_sync_curr_instance();
00691 
00692   /* If current instance is known, parse this instance */
00693   if( curr_instance != NULL ) {
00694 
00695 #ifdef DEBUG_MODE
00696     if( debug_mode ) {
00697       unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Found module to be covered: %s, hierarchy: %s",
00698                                   obf_funit( vpi_get_str( vpiName, inst ) ), obf_inst( curr_inst_scope[0] ) );
00699       assert( rv < USER_MSG_LENGTH );
00700       print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00701     }
00702 #endif
00703 
00704     /*
00705      Set one_instance_found to TRUE to indicate that we were successful in
00706      matching our design to the actual design
00707     */
00708     one_instance_found = TRUE;
00709 
00710     /* Parse all signals */
00711     covered_parse_signals( inst );
00712 
00713     /* Parse all functions/tasks */
00714     covered_parse_task_func( inst );
00715 
00716   }
00717 
00718   /* Search children modules */
00719   if( (iter = vpi_iterate( vpiModule, inst )) != NULL ) {
00720 
00721     while( (handle = vpi_scan( iter )) != NULL ) {
00722       covered_parse_instance( handle );
00723     }
00724 
00725   }
00726 
00727   PROFILE_END;
00728 
00729 }

void covered_parse_signals vpiHandle  mod  ) 
 

00615                                             { PROFILE(COVERED_PARSE_SIGNALS);
00616 
00617   vpiHandle iter, handle;
00618   int       type;
00619 
00620   /* Parse nets */
00621   if( (iter = vpi_iterate( vpiNet, mod )) != NULL ) {
00622     while( (handle = vpi_scan( iter )) != NULL ) {
00623 #ifdef DEBUG_MODE
00624       if( debug_mode ) {
00625         unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Found net: %s", obf_sig( vpi_get_str( vpiName, handle ) ) );
00626         assert( rv < USER_MSG_LENGTH );
00627         print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00628       }
00629 #endif
00630       covered_create_value_change_cb( handle );
00631     }
00632   }
00633 
00634   /* Parse regs */
00635   if( (iter = vpi_iterate( vpiReg, mod )) != NULL ) {
00636     while( (handle = vpi_scan( iter )) != NULL ) {
00637 #ifdef DEBUG_MODE
00638       if( debug_mode ) {
00639         unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Found reg: %s", obf_sig( vpi_get_str( vpiName, handle ) ) );
00640         assert( rv < USER_MSG_LENGTH );
00641         print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00642       }
00643 #endif
00644       covered_create_value_change_cb( handle );
00645     }
00646   }
00647 
00648   /* Parse integers */
00649   if( (iter = vpi_iterate( vpiVariables, mod )) != NULL ) {
00650     while( (handle = vpi_scan( iter )) != NULL ) {
00651       type = vpi_get( vpiType, handle );
00652       if( (type == vpiIntegerVar) || (type == vpiTimeVar) || (type == vpiReg) || (type == vpiRealVar) ) {
00653 #ifdef DEBUG_MODE
00654         if( debug_mode ) {
00655           unsigned int rv;
00656           if( type == vpiIntegerVar ) {
00657             rv = snprintf( user_msg, USER_MSG_LENGTH, "Found integer: %s", obf_sig( vpi_get_str( vpiName, handle ) ) );
00658           } else if( type == vpiTimeVar ) {
00659             rv = snprintf( user_msg, USER_MSG_LENGTH, "Found time: %s", obf_sig( vpi_get_str( vpiName, handle ) ) );
00660           } else if( type == vpiRealVar ) {
00661             rv = snprintf( user_msg, USER_MSG_LENGTH, "Found real: %s", obf_sig( vpi_get_str( vpiName, handle ) ) );
00662           } else if( type == vpiReg ) {
00663             rv = snprintf( user_msg, USER_MSG_LENGTH, "Found reg: %s", obf_sig( vpi_get_str( vpiName, handle ) ) );
00664           }
00665           assert( rv < USER_MSG_LENGTH );
00666           print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00667         }
00668 #endif
00669         covered_create_value_change_cb( handle );
00670       }
00671     }
00672   }
00673 
00674   PROFILE_END;
00675 
00676 }

void covered_parse_task_func vpiHandle  mod  ) 
 

00511                                               { PROFILE(COVERED_PARSE_TASK_FUNC);
00512 
00513   vpiHandle iter, handle;
00514   vpiHandle liter, scope;
00515   int       type;
00516         
00517   /* Parse all internal scopes for tasks and functions */
00518   if( (iter = vpi_iterate( vpiInternalScope, mod )) != NULL ) {
00519 
00520     while( (scope = vpi_scan( iter )) != NULL ) {
00521       
00522       type = vpi_get( vpiType, scope );
00523 
00524       if( (type == vpiTask) || (type == vpiFunction) || (type == vpiNamedBegin) ) {
00525 
00526 #ifdef DEBUG_MODE
00527         if( debug_mode ) {
00528           unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Parsing task/function %s", obf_funit( vpi_get_str( vpiFullName, scope ) ) );
00529           assert( rv < USER_MSG_LENGTH );
00530           print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00531         }
00532 #endif
00533 
00534         /* Set current scope in database */
00535         if( curr_inst_scope[0] != NULL ) {
00536           free_safe( curr_inst_scope[0], (strlen( curr_inst_scope[0] ) + 1) );
00537         }
00538         curr_inst_scope[0]   = strdup_safe( vpi_get_str( vpiFullName, scope ) );
00539         curr_inst_scope_size = 1;
00540 
00541         /* Synchronize curr_instance to point to curr_inst_scope */
00542         db_sync_curr_instance();
00543 
00544         if( curr_instance != NULL ) {
00545 
00546           /* Parse signals */
00547           if( (liter = vpi_iterate( vpiNet, scope )) != NULL ) {
00548             while( (handle = vpi_scan( liter )) != NULL ) {
00549 #ifdef DEBUG_MODE
00550               if( debug_mode ) {
00551                 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Found net: %s", obf_sig( vpi_get_str( vpiFullName, handle ) ) );
00552                 assert( rv < USER_MSG_LENGTH );
00553                 print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00554               }
00555 #endif
00556               covered_create_value_change_cb( handle );
00557             }
00558           }
00559 
00560           if( (liter = vpi_iterate( vpiReg, scope )) != NULL ) {
00561             while( (handle = vpi_scan( liter )) != NULL ) {
00562 #ifdef DEBUG_MODE
00563               if( debug_mode ) {
00564                 unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "Found reg %s", obf_sig( vpi_get_str( vpiFullName, handle ) ) );
00565                 assert( rv < USER_MSG_LENGTH );
00566                 print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00567               }
00568 #endif
00569               covered_create_value_change_cb( handle );
00570             }
00571           }
00572 
00573           if( (liter = vpi_iterate( vpiVariables, scope )) != NULL ) {
00574             while( (handle = vpi_scan( liter )) != NULL ) {
00575               type = vpi_get( vpiType, handle );
00576 #ifdef DEBUG_MODE
00577               if( debug_mode ) {
00578                 unsigned int rv;
00579                 if( type == vpiReg ) {
00580                   rv = snprintf( user_msg, USER_MSG_LENGTH, "Found reg %s", obf_sig( vpi_get_str( vpiFullName, handle ) ) );
00581                 } else if( type == vpiIntegerVar ) {
00582                   rv = snprintf( user_msg, USER_MSG_LENGTH, "Found integer %s", obf_sig( vpi_get_str( vpiFullName, handle ) ) );
00583                 } else if( type == vpiTimeVar ) {
00584                   rv = snprintf( user_msg, USER_MSG_LENGTH, "Found time %s", obf_sig( vpi_get_str( vpiFullName, handle ) ) );
00585                 } else if( type == vpiRealVar ) {
00586                   rv = snprintf( user_msg, USER_MSG_LENGTH, "Found real %s", obf_sig( vpi_get_str( vpiFullName, handle ) ) );
00587                 }
00588                 assert( rv < USER_MSG_LENGTH );
00589                 print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00590               }
00591 #endif
00592               covered_create_value_change_cb( handle );
00593             }
00594           }
00595 
00596           /* Recursively check scope */
00597           if( (liter = vpi_iterate( vpiInternalScope, scope )) != NULL ) {
00598             while( (handle = vpi_scan( liter )) != NULL ) {
00599               covered_parse_task_func( handle );
00600             }
00601           }
00602 
00603         }
00604 
00605       }
00606 
00607     }
00608 
00609   }
00610 
00611   PROFILE_END;
00612 
00613 }

void covered_register  ) 
 

00859                         {
00860 
00861   s_vpi_systf_data tf_data;
00862 
00863   tf_data.type      = vpiSysTask;
00864   tf_data.tfname    = "$covered_sim";
00865   tf_data.calltf    = covered_sim_calltf;
00866   tf_data.compiletf = 0;
00867   tf_data.sizetf    = 0;
00868   tf_data.user_data = "$covered_sim";
00869   vpi_register_systf( &tf_data );
00870 
00871 }

PLI_INT32 covered_sim_calltf char *  name  ) 
 

00738                                            {
00739 #endif
00740   PROFILE(COVERED_SIM_CALLTF);
00741 
00742   vpiHandle       systf_handle, arg_iterator, module_handle;
00743   vpiHandle       arg_handle;
00744   s_vpi_vlog_info info;
00745   p_cb_data       cb;
00746   int             i;
00747   char*           argvptr;
00748   sig_link*       vsigl;
00749   s_vpi_value     value;
00750 
00751   /* Initialize the exception handler context structure */
00752   init_exception_context( the_exception_context );
00753 
00754   systf_handle = vpi_handle( vpiSysTfCall, NULL );
00755   arg_iterator = vpi_iterate( vpiArgument, systf_handle );
00756 
00757   /* Create callback that will handle the end of simulation */
00758   cb            = (p_cb_data)malloc( sizeof( s_cb_data ) );
00759   cb->reason    = cbEndOfSimulation;
00760   cb->cb_rtn    = covered_end_of_sim;
00761   cb->obj       = NULL;
00762   cb->time      = NULL;
00763   cb->value     = NULL;
00764   cb->user_data = NULL;
00765   vpi_register_cb( cb );
00766 
00767 #ifdef TBD
00768   /* Create error handling callback */
00769   cb            = (p_cb_data)malloc( sizeof( s_cb_data ) );
00770   cb->reason    = cbError;
00771   cb->cb_rtn    = covered_cb_error_handler;
00772   cb->obj       = NULL;
00773   cb->time      = NULL;
00774   cb->value     = NULL;
00775   cb->user_data = NULL;
00776   vpi_register_cb( cb );
00777 #endif
00778 
00779   /* Get name of CDD database file from system call arguments */
00780   if( (arg_handle = vpi_scan( arg_iterator )) != NULL ) {
00781     s_vpi_value data;
00782     data.format = vpiStringVal;
00783     vpi_get_value( arg_handle, &data );
00784     strcpy( in_db_name, data.value.str );
00785   }
00786 
00787   /* Get name of CDD database to write to (default is cov.cdd) and debug mode */
00788   strcpy( out_db_name, "cov.cdd" );
00789   profiler_set_mode( FALSE );
00790   if( vpi_get_vlog_info( &info ) ) {
00791     for( i=1; i<info.argc; i++ ) {
00792       argvptr = info.argv[i];
00793       if( strncmp( "+covered_cdd=", argvptr, 13 ) == 0 ) {
00794         argvptr += 13;
00795         strcpy( out_db_name, argvptr );
00796       } else if( strncmp( "+covered_debug", argvptr, 14 ) == 0 ) {
00797         vpi_printf( "covered VPI: Turning debug mode on\n" );
00798         debug_mode = TRUE;
00799       } else if( strncmp( "+covered_profile=", argvptr, 17 ) == 0 ) {
00800         vpi_printf( "covered VPI: Turning profiler on.  Outputting to %s\n", argvptr + 17 );
00801         profiler_set_mode( TRUE );
00802         profiler_set_filename( argvptr + 17 );
00803       } else if( strncmp( "+covered_profile", argvptr, 16 ) == 0 ) {
00804         vpi_printf( "covered VPI: Turning profiler on.  Outputting to %s\n", PROFILING_OUTPUT_NAME );
00805         profiler_set_mode( TRUE );
00806         profiler_set_filename( PROFILING_OUTPUT_NAME );
00807       }
00808       sys_task_store_plusarg( info.argv[i] + 1 );
00809     }
00810   }
00811 
00812   /* Read in contents of specified database file */
00813   Try {
00814     db_read( in_db_name, READ_MODE_NO_MERGE ); 
00815   } Catch_anonymous {
00816     vpi_printf( "covered VPI: Unable to read database file\n" );
00817     vpi_control( vpiFinish, EXIT_FAILURE );
00818   }
00819 
00820   vpi_printf( "covered VPI: Read design information from %s\n", in_db_name );
00821 
00822   /* Bind expressions to signals/functional units */
00823   Try {
00824     bind_perform( TRUE, 0 );
00825   } Catch_anonymous {
00826     vpi_control( vpiFinish, EXIT_FAILURE );
00827   }
00828 
00829   /* Add static values to simulator */
00830   sim_initialize();
00831 
00832   /* Create initial symbol table */
00833   vcd_symtab = symtable_create();
00834 
00835   /* Initialize the curr_inst_scope structure */
00836   curr_inst_scope      = (char**)malloc( sizeof( char* ) );
00837   curr_inst_scope[0]   = NULL;
00838   curr_inst_scope_size = 1;
00839 
00840   /* Parse child instances - associate a signal in the design with a signal in Covered */
00841   while( (module_handle = vpi_scan( arg_iterator )) != NULL ) {
00842     covered_parse_instance( module_handle );
00843   }
00844 
00845   /* Create timestep symbol table array */
00846   if( vcd_symtab_size > 0 ) {
00847     timestep_tab = malloc_safe_nolimit( (sizeof( symtable*) * vcd_symtab_size) );
00848   }
00849 
00850   /* Add all of the sym_value structures to the simulation core */
00851   add_sym_values_to_sim();
00852 
00853   PROFILE_END;
00854 
00855   return 0;
00856 
00857 }

PLI_INT32 covered_value_change_bin p_cb_data  cb  ) 
 

Returns:
Returns 0.
This callback function is called whenever a signal changes within the simulator. It places this value in the Covered symtable and calls the db_do_timestep if this value change occurred on a new timestep.
Parameters:
cb  Pointer to callback data structure from vpi_user.h

00182   { PROFILE(COVERED_VALUE_CHANGE_BIN);
00183 
00184 #ifndef NOIV
00185   s_vpi_value value;
00186 
00187   /* Setup value */
00188   value.format = vpiBinStrVal;
00189   vpi_get_value( cb->obj, &value );
00190 
00191 #ifdef DEBUG_MODE
00192   if( debug_mode ) {
00193     unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "In covered_value_change_bin, name: %s, time: %llu, value: %s",
00194                                 obf_sig( vpi_get_str( vpiFullName, cb->obj ) ), (((uint64)cb->time->high << 32) | (uint64)cb->time->low), value.value.str );
00195     assert( rv < USER_MSG_LENGTH );
00196     print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00197   }
00198 #endif
00199 
00200   if( (cb->time->low  != (PLI_INT32)(last_time & 0xffffffff)) || (cb->time->high != (PLI_INT32)((last_time >> 32) & 0xffffffff)) ) {
00201     if( !db_do_timestep( last_time, FALSE ) ) {
00202       vpi_control( vpiFinish, EXIT_SUCCESS );
00203     }
00204   }
00205   last_time = ((uint64)cb->time->high << 32) | (uint64)cb->time->low;
00206   
00207   /* Set symbol value */
00208   db_set_symbol_string( cb->user_data, value.value.str );
00209 #else
00210 #ifdef DEBUG_MODE
00211   if( debug_mode ) {
00212     unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "In covered_value_change_bin, name: %s, time: %llu, value: %s",
00213                                 obf_sig( vpi_get_str( vpiFullName, cb->obj ) ), (((uint64)cb->time->high << 32) | (uint64)cb->time->low), cb->value->value.str );
00214     assert( rv < USER_MSG_LENGTH );
00215     print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00216   }
00217 #endif
00218 
00219   if( (cb->time->low  != (PLI_INT32)(last_time & 0xffffffff)) || (cb->time->high != (PLI_INT32)((last_time >> 32) & 0xffffffff)) ) {
00220     if( !db_do_timestep( last_time, FALSE ) ) {
00221       vpi_control( vpiFinish, EXIT_SUCCESS );
00222     }
00223   }
00224   last_time = ((uint64)cb->time->high << 32) | (uint64)cb->time->low;
00225 
00226   /* Set symbol value */
00227   db_set_symbol_string( cb->user_data, cb->value->value.str );
00228 #endif
00229 
00230   PROFILE_END;
00231 
00232   return( 0 );
00233 
00234 }

PLI_INT32 covered_value_change_real p_cb_data  cb  ) 
 

Returns:
Returns 0.
This callback function is called whenever a signal changes within the simulator. It places this value in the Covered symtable and calls the db_do_timestep if this value change occurred on a new timestep.
Parameters:
cb  Pointer to callback data structure from vpi_user.h

00245   { PROFILE(COVERED_VALUE_CHANGE_REAL);
00246 
00247   char real_str[64];
00248 
00249 #ifndef NOIV
00250   s_vpi_value value;
00251 
00252   /* Setup value */
00253   value.format = vpiRealVal;
00254   vpi_get_value( cb->obj, &value );
00255 
00256 #ifdef DEBUG_MODE
00257   if( debug_mode ) {
00258     unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "In covered_value_change_real, name: %s, time: %llu, value: %.16f",
00259                                 obf_sig( vpi_get_str( vpiFullName, cb->obj ) ), (((uint64)cb->time->high << 32) | (uint64)cb->time->low), value.value.real );
00260     assert( rv < USER_MSG_LENGTH );
00261     print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00262   }
00263 #endif
00264 
00265   if( (cb->time->low  != (PLI_INT32)(last_time & 0xffffffff)) || (cb->time->high != (PLI_INT32)((last_time >> 32) & 0xffffffff)) ) {
00266     if( !db_do_timestep( last_time, FALSE ) ) {
00267       vpi_control( vpiFinish, EXIT_SUCCESS );
00268     }
00269   }
00270   last_time = ((uint64)cb->time->high << 32) | (uint64)cb->time->low;
00271 
00272   /* Set symbol value */
00273   snprintf( real_str, 64, "%.16f", value.value.real );
00274   db_set_symbol_string( cb->user_data, real_str );
00275 #else
00276 #ifdef DEBUG_MODE
00277   if( debug_mode ) {
00278     unsigned int rv = snprintf( user_msg, USER_MSG_LENGTH, "In covered_value_change_real, name: %s, time: %llu, value: %.16f",
00279                                 obf_sig( vpi_get_str( vpiFullName, cb->obj ) ), (((uint64)cb->time->high << 32) | (uint64)cb->time->low), cb->value->value.real );
00280     assert( rv < USER_MSG_LENGTH );
00281     print_output( user_msg, DEBUG, __FILE__, __LINE__ );
00282   }
00283 #endif
00284 
00285   if( (cb->time->low  != (PLI_INT32)(last_time & 0xffffffff)) || (cb->time->high != (PLI_INT32)((last_time >> 32) & 0xffffffff)) ) {
00286     if( !db_do_timestep( last_time, FALSE ) ) {
00287       vpi_control( vpiFinish, EXIT_SUCCESS );
00288     }
00289   }
00290   last_time = ((uint64)cb->time->high << 32) | (uint64)cb->time->low;
00291 
00292   /* Set symbol value */
00293   snprintf( real_str, 64, "%.16f", cb->value->value.real );
00294   db_set_symbol_string( cb->user_data, real_str );
00295 #endif
00296 
00297   PROFILE_END;
00298 
00299   return( 0 );
00300 
00301 }

char* gen_next_symbol  ) 
 

00391                         { PROFILE(GEN_NEXT_SYMBOL);
00392 
00393   static char symbol[21]   = {32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,'\0'};
00394   static int  symbol_index = 19;
00395   int         i            = 19;
00396 
00397   while( (i >= symbol_index) && (symbol[i] == 126) ) {
00398     symbol[i] = 33;
00399     if( (i - 1) < symbol_index ) {
00400       symbol_index--;
00401       if( symbol_index < 0 ) {
00402         return( NULL );
00403       }
00404     }
00405     i--;
00406   }
00407   symbol[i]++;
00408 
00409   PROFILE_END;
00410 
00411   return( strdup_safe( symbol + symbol_index ) );
00412 
00413 }

void sym_value_store char *  sym,
char *  value
 

Stores the given signal symbol and initial value in the sym_value list that will be assigned to the simulator once the timestep table has been allocated.

Parameters:
sym  Symbol string of signal to store
value  Initial signal value to store

00123   { PROFILE(SYM_VALUE_STORE);
00124 
00125   sym_value* sval;  /* Pointer to newly allocated sym_value structure */
00126 
00127   /* Allocate and initialize the sym_value structure */
00128   sval = (sym_value*)malloc_safe( sizeof( sym_value ) );
00129   sval->sym   = strdup_safe( sym );
00130   sval->value = strdup_safe( value );
00131   sval->next  = NULL; 
00132 
00133   /* Add the newly created sym_value structure to the sv list */
00134   if( sv_head == NULL ) {
00135     sv_head = sv_tail = sval;
00136   } else {
00137     sv_tail->next = sval;
00138     sv_tail       = sval;
00139   }
00140 
00141   PROFILE_END;
00142 
00143 }

void vpi_print_output const char *  msg  ) 
 

Displays the given message to standard output.

Parameters:
msg Message to output to standard output
Outputs the given message to standard output using the vpi_printf function.

00110                                          {
00111 
00112   vpi_printf( "covered VPI: %s\n", msg );
00113 
00114 }


Variable Documentation

int block_depth = 0
 

char* cdd_message = NULL
 

User-supplied message to include in the CDD database

bool cli_debug_mode = FALSE
 

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

funit_inst* curr_instance
 

Pointer to the current instance selected by the VCD parser. If this value is NULL, the current instance does not reside in the design specified for coverage.

bool debug_mode
 

If set to TRUE, causes debug information to be spewed to screen.

tnode* def_table = NULL
 

unsigned int flag_global_generation = GENERATION_SV
 

Specifies the supported global generation value

bool flag_output_exclusion_ids = FALSE
 

Outputs the exclusion ID for an output coverage point. The exclusion ID can be used by the exclude command for excluding/including coverage points.

int flag_race_check = WARNING
 

Specifies how race conditions should be handled

bool flag_use_command_line_debug = FALSE
 

Specifies whether the command-line debugger should be enabled

bool flag_use_line_width = FALSE
 

If set to a boolean value of TRUE, displays combination logic output in a by-line-width format (instead of the user specified Verilog source format).

int* fork_block_depth
 

int fork_depth = -1
 

int generate_expr_mode = 0
 

char in_db_name[1024]
 

Name of input CDD file

isuppl info_suppl
 

Informational line for the CDD file.

uint64 last_time = 0
 

Last simulation time seen from simulator

int line_width = DEFAULT_LINE_WIDTH
 

Specifies the number of characters wide that an expression will allowed to be output for if the flag_use_line_width value is set to TRUE.

char** merge_in = NULL
 

str_link* merge_in_head = NULL
 

Pointer to head of list containing names of the input CDD files.

int merge_in_num
 

Specifies the number of merged CDD files.

str_link* merge_in_tail = NULL
 

Pointer to tail of list containing names of the input CDD files.

char* merged_file = NULL
 

Specifies the output filename of the CDD file that contains the merged data.

bool one_instance_found = FALSE
 

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.

char out_db_name[1024]
 

Name of output CDD file

str_link* race_ignore_mod_head = NULL
 

Pointer to head of string list containing the names of modules that should be ignored for race condition checking.

str_link* race_ignore_mod_tail = NULL
 

Pointer to tail of string list containing the names of modules that should be ignored for race condition checking.

bool report_covered = FALSE
 

If set to a boolean value of TRUE, displays covered logic for a particular CDD file. By default, Covered will display uncovered logic. Must be used in conjunction with the -d v|d (verbose output) option.

bool report_exclusions = FALSE
 

If set to a boolean value of TRUE, displays excluded coverage points for a particular CDD file. By default, Covered will not display excluded coverage points. This can be useful when used in conjunction with the -x option for including excluded coverage points. Must be used in conjunction with the -d v|d (verbose output) option.

bool report_gui = FALSE
 

If set to a boolean value of TRUE, displays GUI report viewer instead of generating text report files.

bool report_instance = FALSE
 

If set to a boolean value of TRUE, provides a coverage information for individual functional unit instances. If set to a value of FALSE, reports coverage information on a functional unit basis, merging results from all instances of same functional unit.

sym_value* sv_head = NULL
 

Pointer to head of sym_value list

sym_value* sv_tail = NULL
 

Pointer to tail of sym_value list

struct exception_context the_exception_context[1]
 

Exception context structure used by cexcept.h for throwing and catching exceptions.

symtable** timestep_tab
 

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

int timestep_update = 0
 

Specifies timestep increment to display current time

char* top_instance = NULL
 

Name of top-level instance name

char* top_module = NULL
 

Name of top-level module to score

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.

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.

void(* vlog_startup_routines[])() =
 

00874                                     {
00875         covered_register,
00876         0
00877 };


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