Exemplo n.º 1
0
int do_timfile_save(const char *fname)
{
const char *time_prefix=WAVE_SI_UNITS;
const double negpow[] = { 1.0, 1.0e-3, 1.0e-6, 1.0e-9, 1.0e-12, 1.0e-15, 1.0e-18, 1.0e-21 };
char *pnt;
int offset;
Trptr t = GLOBALS->traces.first;
int i = 1; /* trace index in the .tim file */
TimeType tmin, tmax;

errno = 0;

if((GLOBALS->tims.marker > LLDescriptor(0)) && (GLOBALS->tims.baseline > LLDescriptor(0)))
	{
	if(GLOBALS->tims.marker < GLOBALS->tims.baseline)
		{
	        tmin = GLOBALS->tims.marker;
	        tmax = GLOBALS->tims.baseline;
		}
		else
		{
	        tmax = GLOBALS->tims.marker;
	        tmin = GLOBALS->tims.baseline;
		}
	}
	else
	{
        tmin = GLOBALS->min_time;
        tmax = GLOBALS->max_time;
	}

GLOBALS->f_vcd_saver_c_1 = fopen(fname, "wb");
if(!GLOBALS->f_vcd_saver_c_1)
	{
        return(VCDSAV_FILE_ERROR);
        }

pnt=strchr(time_prefix, (int)GLOBALS->time_dimension);
if(pnt) { offset=pnt-time_prefix; } else offset=0;

w32redirect_fprintf(0, GLOBALS->f_vcd_saver_c_1,
	"Timing Analyzer Settings\n"
	"     Time_Scale:        %E\n"
	"     Time_Per_Division: %E\n"
	"     NumberDivisions:   10\n"
	"     Start_Time:        "TTFormat".0\n"
	"     End_Time:          "TTFormat".0\n",

	negpow[offset],
	(tmax-tmin) / 10.0,
	tmin,
	tmax
	);

while(t)
	{
	write_tim_tracedata(t, &i, tmin, tmax);
        t = GiveNextTrace(t);
	}

fclose(GLOBALS->f_vcd_saver_c_1);
GLOBALS->f_vcd_saver_c_1 = NULL;

return(errno ? VCDSAV_FILE_ERROR : VCDSAV_OK);
}
Exemplo n.º 2
0
int install_ttrans_filter(int which)
{
int found = 0;

if((which<0)||(which>=(PROC_FILTER_MAX+1)))
        {
        which = 0;
        }

if(GLOBALS->traces.first)  
        {
        Trptr t = GLOBALS->traces.first;
        while(t)
                {
                if(t->flags&TR_HIGHLIGHT)
                        {
			if((!t->vector) && (which))
				{
				bvptr v = combine_traces(1, t); /* down: make single signal a vector */
				if(v)
					{
					v->transaction_nd = t->n.nd; /* cache for savefile, disable */
					t->vector = 1;
					t->n.vec = v;		/* splice in */
					}
				}

                        if((t->vector) && (!(t->flags&(TR_BLANK|TR_ANALOG_BLANK_STRETCH))))
                                {
                                t->t_filter = which;
				t->t_filter_converted = 0;

				/* back out allocation to revert (if any) */
				if(t->n.vec->transaction_cache)
					{
					int i;
					bvptr bv = t->n.vec;
					bvptr bv2;
					nptr ndcache = NULL;

					t->n.vec = bv->transaction_cache;
					if((t->n.vec->transaction_nd) && (!which))
						{
						ndcache = t->n.vec->transaction_nd;
						}

					while(bv)
						{
						bv2 = bv->transaction_chain;

						if(bv->bvname)
							{
							free_2(bv->bvname);
							}

						for(i=0;i<bv->numregions;i++)
							{
							free_2(bv->vectors[i]);
							}

						free_2(bv);
						bv = bv2;
						}

					t->name = t->n.vec->bvname;
	                  		if(GLOBALS->hier_max_level)
	                    			t->name = hier_extract(t->name, GLOBALS->hier_max_level);

					if(ndcache)
						{
						t->n.nd = ndcache;
						t->vector = 0;
						/* still need to deallocate old t->n.vec! */
						}
					}

				if(!which)
					{
					t->flags &= (~(TR_TTRANSLATED|TR_ANALOGMASK));
					}
					else
					{
					t->flags &= (~(TR_ANALOGMASK));
					t->flags |= TR_TTRANSLATED;
					if(t->transaction_args) free_2(t->transaction_args);
					if(GLOBALS->ttranslate_args)
						{
						t->transaction_args = strdup_2(GLOBALS->ttranslate_args);
						}
						else
						{
						t->transaction_args = NULL;
						}
					traverse_vector_nodes(t);
					}
                                found++;

				if(t->t_match)
					{
					Trptr curr_trace = t;
					t = t->t_next;
					while(t && (t->t_match != curr_trace))					
						{
						t = t->t_next;
						}
					}
                                }
                        }
                t=GiveNextTrace(t);
                }
        }

if(found)
	{
	regen_display();
	}

return(found);
}