Beispiel #1
0
/*************************************************
  lxt2_init
    - Open lxt file and enable collection
 ************************************************/
static void lxt2_init()
{
    char*  filename;
    if( lxt.inited ) {
	tf_error( "recording has alreay begun" );
        tf_dofinish();
	return;
    }
    if( lxt.filename ) {
	filename = lxt.filename;
    } else if( lxt.design ) {
	filename = (char*)malloc( strlen(lxt.design)+4+1 );
	if( !filename ) {
	    tf_error( "could not allocate memory" );
            tf_dofinish();
	    return;
	}
	sprintf( filename, "%s.lxt", lxt.design );
	lxt.filename = filename;
    } else {
	char* top = acc_fetch_name( acc_next_topmod(null) );
	filename = (char*)malloc( strlen(top)+3+1 );
	sprintf( filename, "%s.lxt", top );	
	lxt.filename = filename;
    }
    lxt.t = lxt2_wr_init( filename );
#if DEBUG
    io_printf( "lxt2_init: %p\n", lxt.t );
#endif
    if( !lxt.t ) {
	tf_error( "could not create file '%s'", filename );
        tf_dofinish();
	return;
    }

    lxt2_wr_set_timescale( lxt.t, acc_fetch_precision() );
    if( lxt.compress ) {
	lxt2_wr_set_compression_depth(lxt.t, 9);
	lxt2_wr_set_partial_off(lxt.t);
    } else {
	lxt2_wr_set_compression_depth(lxt.t, 4);
	lxt2_wr_set_partial_on(lxt.t, 1);
    }
    lxt2_wr_set_break_size(lxt.t, lxt.incSize);

    lxt.inited     = 1;
    lxt.enabled    = 1;
    lxt.updateList = 0;
    lxt.eventList  = 0;
    lxt.hunk	   = 0;

    lxt2_wr_set_initial_value( lxt.t, 'x' );
    lxt2_wr_symbol_bracket_stripping( lxt.t, 1 );
    lxt2_timemarker(); 
}
Beispiel #2
0
TimeType vcd_main(char *fname, char *lxname)
{
#ifdef ONLY_NEEDED_FOR_VALGRIND_CLEAN_TEST
struct vcdsymbol *v, *v2;
#endif

vcd_hier_delimeter[0]=hier_delimeter;

errno=0;	/* reset in case it's set for some reason */

yytext=(char *)malloc_2(T_MAX_STR+1);

if((strlen(fname)>2)&&(!strcmp(fname+strlen(fname)-3,".gz")))
	{
	char *str;
	int dlen;
	dlen=strlen(WAVE_DECOMPRESSOR);
	str=(char *)wave_alloca(strlen(fname)+dlen+1);
	strcpy(str,WAVE_DECOMPRESSOR);
	strcpy(str+dlen,fname);
	vcd_handle=popen(str,"r");
	vcd_is_compressed=~0;
	}
	else
	{
	if(strcmp("-",fname))
		{
		vcd_handle=fopen(fname,"rb");
		}
		else
		{
		vcd_handle=stdin;
		}
	vcd_is_compressed=0;
	}

if(!vcd_handle)
	{
	fprintf(stderr, "Error opening %s .vcd file '%s'.\n",
		vcd_is_compressed?"compressed":"", fname);
	exit(1);
	}

lt=lxt2_wr_init(lxname);
if(!lt)
	{
	fprintf(stderr, "Problem opening output file '%s'\n", lxname);
	perror("Why");
	exit(255);
	}

if(opt_partial_mode>=0)
	{
	lxt2_wr_set_partial_on(lt, opt_partial_mode);
	}

if((opt_checkpoint_disable)&&(!opt_break_size))
	{
	lxt2_wr_set_checkpoint_off(lt);
	}

lxt2_wr_set_compression_depth(lt, opt_depth);
lxt2_wr_set_break_size(lt, (off_t)opt_break_size);
lxt2_wr_set_maxgranule(lt, opt_maxgranule);
lxt2_wr_symbol_bracket_stripping(lt, 1);	/* this is intentional */

sym=(struct symbol **)calloc_2(SYMPRIME,sizeof(struct symbol *));
printf("\nConverting VCD File '%s' to LXT2 file '%s'...\n\n",(vcd_handle!=stdin)?fname:"from stdin", lxname);
build_slisthier();
vcd_parse();
if(varsplit)
	{
	free_2(varsplit);
	varsplit=NULL;
	}

add_tail_histents();

printf("["TTFormat"] start time.\n["TTFormat"] end time.\n\n", start_time, end_time);

lxt2_wr_close(lt);
lt=NULL;

min_time=start_time*time_scale;
max_time=end_time*time_scale;

if((min_time==max_time)||(max_time==0))
        {
        fprintf(stderr, "VCD times range is equal to zero.  Exiting.\n");
        exit(1);
        }

if(vcd_handle!=stdin)
	{
	fclose(vcd_handle);
	vcd_handle=NULL;
	}

free(yytext); yytext=NULL;
if(indexed) { free(indexed); indexed=NULL; }
if(sorted) { free(sorted); sorted=NULL; }

#ifdef ONLY_NEEDED_FOR_VALGRIND_CLEAN_TEST
v=vcdsymroot;
while(v)
	{
	if(v->name) { free(v->name); v->name=NULL; }
	if(v->id) { free(v->id); v->id=NULL; }
	if(v->value) { free(v->value); v->value=NULL; }

	if(v->narray)
		{
		int i;
		for(i=0;i<v->size;i++)
			{
			struct HistEnt *h1, *h2;

			if((h1 = v->narray[i]->head.next))
				{
				h1 = v->narray[i]->head.next;	
				while(h1)
					{
					h2 = h1->next;
					free(h1);
					h1 = h2;
					}
				}

			free(v->narray[i]); v->narray[i]=NULL;
			}

		free(v->narray); v->narray=NULL;
		}

	v2=v->next;
	free(v);
	v=v2;
	}
vcdsymroot=vcdsymcurr=NULL;
#endif

free(sym); sym=NULL;

if(slisthier) { free(slisthier); slisthier=NULL; }

return(max_time);
}