static int draw_scope(vpiHandle item, vpiHandle callh) { int depth; const char *name; const char *type; vpiHandle scope = vpi_handle(vpiScope, item); if (!scope) return 0; depth = 1 + draw_scope(scope, callh); name = vpi_get_str(vpiName, scope); switch (vpi_get(vpiType, scope)) { case vpiNamedBegin: type = "begin"; break; case vpiGenScope: type = "begin"; break; case vpiTask: type = "task"; break; case vpiFunction: type = "function"; break; case vpiNamedFork: type = "fork"; break; case vpiModule: type = "module"; break; default: type = "invalid"; vpi_printf("VCD Error: %s:%d: $dumpvars: Unsupported scope " "type (%d)\n", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh), (int)vpi_get(vpiType, item)); assert(0); } fprintf(dump_file, "$scope %s %s $end\n", type, name); return depth; }
static int draw_scope(vpiHandle item) { int depth; const char *name; char *type; vpiHandle scope = vpi_handle(vpiScope, item); if (!scope) return 0; depth = 1 + draw_scope(scope); name = vpi_get_str(vpiName, scope); switch (vpi_get(vpiType, item)) { case vpiNamedBegin: type = "begin"; break; case vpiTask: type = "task"; break; case vpiFunction: type = "function"; break; case vpiNamedFork: type = "fork"; break; default: type = "module"; break; } fprintf(dump_file, "$scope %s %s $end\n", type, name); return depth; }
static PLI_INT32 sys_dumpvars_calltf(ICARUS_VPI_CONST PLI_BYTE8*name) { vpiHandle callh = vpi_handle(vpiSysTfCall, 0); vpiHandle argv = vpi_iterate(vpiArgument, callh); vpiHandle item; s_vpi_value value; unsigned depth = 0; (void)name; /* Parameter is not used. */ if (dump_file == 0) { open_dumpfile(callh); if (dump_file == 0) { if (argv) vpi_free_object(argv); return 0; } } if (install_dumpvars_callback()) { if (argv) vpi_free_object(argv); return 0; } /* Get the depth if it exists. */ if (argv) { value.format = vpiIntVal; vpi_get_value(vpi_scan(argv), &value); depth = value.value.integer; } if (!depth) depth = 10000; /* This dumps all the modules in the design if none are given. */ if (!argv || !(item = vpi_scan(argv))) { argv = vpi_iterate(vpiModule, 0x0); assert(argv); /* There must be at least one top level module. */ item = vpi_scan(argv); } for ( ; item; item = vpi_scan(argv)) { int dep = draw_scope(item); scan_item(depth, item, 0); /* The scope list must be sorted after we scan an item. */ vcd_names_sort(&lxt_tab); while (dep--) pop_scope(); } /* Most effective compression. */ if (lxm_optimum_mode == LXM_SPACE) { lt_set_no_interlace(dump_file); } return 0; }
static int draw_scope(vpiHandle item) { int depth; const char *name; vpiHandle scope = vpi_handle(vpiScope, item); if (!scope) return 0; depth = 1 + draw_scope(scope); name = vpi_get_str(vpiName, scope); push_scope(name); return depth; }
static int draw_scope(vpiHandle item, vpiHandle callh) { int depth; const char *name; char *defname = NULL; PLI_INT32 scope_type, type; vpiHandle scope = vpi_handle(vpiScope, item); if (!scope) return 0; depth = 1 + draw_scope(scope, callh); scope_type = vpi_get(vpiType, scope); /* This must be done before the other name is fetched * and the string must always be freed */ if (scope_type == vpiModule) { defname = strdup(vpi_get_str(vpiDefName, scope)); } name = vpi_get_str(vpiName, scope); /* If the two names match only use the vpiName. */ if (defname && (strcmp(defname, name) == 0)) { free(defname); defname = NULL; } switch (scope_type) { case vpiNamedBegin: type = FST_ST_VCD_BEGIN; break; case vpiFunction: type = FST_ST_VCD_FUNCTION; break; case vpiNamedFork: type = FST_ST_VCD_FORK; break; case vpiGenScope: type = FST_ST_VCD_GENERATE; break; case vpiModule: type = FST_ST_VCD_MODULE; break; case vpiTask: type = FST_ST_VCD_TASK; break; default: type = FST_ST_VCD_MODULE; vpi_printf("FST Error: %s:%d: $dumpvars: Unsupported scope " "type (%d)\n", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh), (int)vpi_get(vpiType, item)); assert(0); } fstWriterSetScope(dump_file, type, name, defname); free(defname); return depth; }
static void trace_draw_scope(void *vp) { struct drawing_queue *q; q = (struct drawing_queue *)vp; if(!midi_trace.flush_flag) { if(view_soundspec_flag) draw_scope(q->values); if(ctl_speana_flag) { CtlEvent e; e.type = CTLE_SPEANA; e.v1 = (long)q->values; e.v2 = FFTSIZE/2; ctl->event(&e); } } free_queue(q); }
static int sys_dumpvars_calltf(char*name) { unsigned depth; s_vpi_value value; vpiHandle item = 0; vpiHandle sys = vpi_handle(vpiSysTfCall, 0); vpiHandle argv; if (dump_file == 0) { open_dumpfile(); if (dump_file == 0) return 0; } if (install_dumpvars_callback()) { return 0; } argv = vpi_iterate(vpiArgument, sys); depth = 0; if (argv && (item = vpi_scan(argv))) switch (vpi_get(vpiType, item)) { case vpiConstant: case vpiNet: case vpiReg: case vpiIntegerVar: case vpiMemoryWord: value.format = vpiIntVal; vpi_get_value(item, &value); depth = value.value.integer; break; } if (!depth) depth = 10000; if (!argv) { // $dumpvars; // search for the toplevel module vpiHandle parent = vpi_handle(vpiScope, sys); while (parent) { item = parent; parent = vpi_handle(vpiScope, item); } } else if (!item || !(item = vpi_scan(argv))) { // $dumpvars(level); // $dumpvars(); // dump the current scope item = vpi_handle(vpiScope, sys); argv = 0x0; } for ( ; item; item = argv ? vpi_scan(argv) : 0x0) { int dep = draw_scope(item); vcd_names_sort(&vcd_tab); scan_item(depth, item, 0); while (dep--) { fprintf(dump_file, "$upscope $end\n"); } } return 0; }
static PLI_INT32 sys_dumpvars_calltf(ICARUS_VPI_CONST PLI_BYTE8*name) { vpiHandle callh = vpi_handle(vpiSysTfCall, 0); vpiHandle argv = vpi_iterate(vpiArgument, callh); vpiHandle item; s_vpi_value value; unsigned depth = 0; (void)name; /* Parameter is not used. */ if (dump_file == 0) { open_dumpfile(callh); if (dump_file == 0) { if (argv) vpi_free_object(argv); return 0; } } if (install_dumpvars_callback()) { if (argv) vpi_free_object(argv); return 0; } /* Get the depth if it exists. */ if (argv) { value.format = vpiIntVal; vpi_get_value(vpi_scan(argv), &value); depth = value.value.integer; } if (!depth) depth = 10000; /* This dumps all the modules in the design if none are given. */ if (!argv || !(item = vpi_scan(argv))) { argv = vpi_iterate(vpiModule, 0x0); assert(argv); /* There must be at least one top level module. */ item = vpi_scan(argv); } for ( ; item; item = vpi_scan(argv)) { char *scname; const char *fullname; int add_var = 0; int dep; PLI_INT32 item_type = vpi_get(vpiType, item); /* If this is a signal make sure it has not already * been included. */ switch (item_type) { case vpiIntegerVar: case vpiBitVar: case vpiByteVar: case vpiShortIntVar: case vpiIntVar: case vpiLongIntVar: case vpiMemoryWord: case vpiNamedEvent: case vpiNet: case vpiParameter: case vpiRealVar: case vpiReg: case vpiTimeVar: /* Warn if the variables scope (which includes the * variable) or the variable itself was already * included. A scope does not automatically include * memory words so do not check the scope for them. */ scname = strdup(vpi_get_str(vpiFullName, vpi_handle(vpiScope, item))); fullname = vpi_get_str(vpiFullName, item); if (((item_type != vpiMemoryWord) && vcd_names_search(&fst_tab, scname)) || vcd_names_search(&fst_var, fullname)) { vpi_printf("FST warning: skipping signal %s, " "it was previously included.\n", fullname); free(scname); continue; } else { add_var = 1; } free(scname); } dep = draw_scope(item, callh); scan_item(depth, item, 0); /* The scope list must be sorted after we scan an item. */ vcd_names_sort(&fst_tab); while (dep--) fstWriterSetUpscope(dump_file); /* Add this signal to the variable list so we can verify it * is not included twice. This must be done after it has * been added */ if (add_var) { vcd_names_add(&fst_var, vpi_get_str(vpiFullName, item)); vcd_names_sort(&fst_var); } } return 0; }
int draw(void) { gint i = 0; gint j = 0; gint k = 0; gint x = 0; /* Used for frame per sec debugging gint elapsed_time_sec=0; gint elapsed_time_usec=0; gfloat elapsed=0.0; */ gfloat bands_per_block = 0; gfloat orig_bands_per_block = 0; gint fragcount = 0; gfloat fractional_bands = 0.0; // static gint lin_x_axis[MAXBANDS]; static gint log_x_axis[MAXBANDS]; gdouble val = 0; gint sum = 0; gint count = 0; gint factor = 0; gfloat resolution = 0.0; /* If no window, just return */ if (!main_display->window) return (TRUE); /* Run audio processor */ if (!input_chewer()) return (TRUE); /* Next set of routines ONLY ONLY needs to be done for 3D Landform * and 2D EQ. Scope, spikes, and spectrogram don't need these, so * why waste the cpu time.. */ if (mode == LAND_3D) { if (landflip == TRUE) factor = -1; else factor = 1; for (i=1; i<nsamp/2; i++) { disp_val[i-1] = (norm_fft[i]/20)*factor; } disp_val[(nsamp/2)-1]=0; } else if (mode == SPIKE_3D) { if (spikeflip == TRUE) factor = -1; else factor = 1; for (i=1; i<nsamp/2; i++) { disp_val[i-1] = (norm_fft[i]/20)*factor; } disp_val[(nsamp/2)-1]=0; } else { for (i=1; i<nsamp/2; i++) { disp_val[i-1] = (norm_fft[i]/20); } disp_val[(nsamp/2)-1]=0; } if ((mode == LAND_3D) || (mode == EQ_2D) || (mode == LINE_EQ)) { /* Gives a "log-like" x axis (for 2D (EQ like analyzer)) * hacking to make it work better with the various displays * the bin[i] determines how much data is summed together * for the display since the display can't fit a 1024 * point fft nicely. */ switch ((AxisType)axis_type) { case LINEAR: if (recalc_scale) { for(i = 0;i < bands;i++) { /* Linear x axis */ //lin_x_axis[i]=(nsamp/2)/bands; } } break; case LOG: if (recalc_scale) { scalefactor = 7.0; count = 0; recalc: count++; scale = bands/scalefactor; sum = 0; for (i=0; i < bands ; i++) { log_x_axis[i] = exp((i/scale)); sum = sum + log_x_axis[i]; } /* reduction algorithm, to get scalefactor so that ALL datapoints *in the FFT get onto the display */ if (sum > nsamp/2) { if (sum > (2.0*(nsamp/2))) scalefactor -= .500; if (sum > (1.25*(nsamp/2))) scalefactor -= .150; if (sum > (1.15*(nsamp/2))) scalefactor -= .025; if (sum > (1.05*(nsamp/2))) scalefactor -= .010; if (sum >= (1.02*(nsamp/2))) scalefactor -= .005; if (sum >= (1.01*(nsamp/2))) scalefactor -= .002; if (sum < (1.01*(nsamp/2))) scalefactor -= .001; goto recalc; } if (sum < (nsamp/2)*.99) { if (sum < (nsamp/2)*.99) scalefactor += .001; if (sum < (nsamp/2)*.98) scalefactor += .002; if (sum < (nsamp/2)*.95) scalefactor += .005; if (sum < (nsamp/2)*.85) scalefactor += .025; if (sum < (nsamp/2)*.75) scalefactor += .155; goto recalc; } #ifdef SCALEDEBUG for (i=0; i<bands; i++) g_print("Log_axis[%i] is %i\n",i,log_x_axis[i]); g_print("It took %i iterations to get the scalefactor\n",count); g_print("Scalefactor %f\n",scalefactor); g_print("Number of points in display is %i\n",sum); #endif recalc_scale = FALSE; } break; default: break; } /* * This function groups together the data from the * FFT so that it can fit into the smaller division * displayed on screen, since a 1024 point fft doesn't * fit well into 32 or 64 divisions. The lin/log_x_axis * arrays determine how the fft data is broken up for * a linear or log based frequency axis */ j=0; k=0; x=0; bands_per_block = (int)(floor((nsamp/2)/bands)); orig_bands_per_block = bands_per_block; fractional_bands = (((float)nsamp/2.0)/(float)bands)-bands_per_block; if(recalc_markers) { if (axis_type == LINEAR) resolution = ((ring_rate/2.0)/(float)bands)/decimation_factor; else if (axis_type == LOG) resolution = ring_rate/((float)nsamp*decimation_factor); switch (axis_type) { case LINEAR: freqmark[0]=resolution; for (x=1;x<bands;x++) freqmark[x]= freqmark[x-1]+resolution; break; case LOG: freqmark[0]=resolution*log_x_axis[0]; for (x=1;x<bands;x++) freqmark[x]= freqmark[x-1]+(resolution*log_x_axis[x]); break; } recalc_markers = 0; } for(i=0;i<bands;i++) { val=0; /* sum it, then average it so the scaling * doesn't go haywire */ switch (axis_type) { case LINEAR: bands_per_block = bands_per_block + fractional_bands; if (bands_per_block > orig_bands_per_block+1.0) { x=floor(bands_per_block); for(j=0;j<x;j++) val+=disp_val[k++]; val/=(double)bands_per_block; bands_per_block -= 1.0; fragcount++; } else { x=floor(bands_per_block); for(j=0;j<x;j++) val+=disp_val[k++]; val/=(double)bands_per_block; } break; case LOG: for(j=0;j<(log_x_axis[i]);j++) val+=disp_val[k++]; val/=(double)log_x_axis[i]; break; } if (bar_decay) { if (mode == LAND_3D) { if (landflip) { if (val>=(levels[i]-bar_decay_speed)) { levels[i]+=bar_decay_speed; if (levels[i]>0) levels[i]=0; } else levels[i]=val; } else { if (val<=(levels[i]-bar_decay_speed)) { levels[i]-=bar_decay_speed; if (levels[i]<0) levels[i]=0; } else levels[i]=val; } } else // 2D EQ { if (val<=(levels[i]-bar_decay_speed)) { levels[i]-=bar_decay_speed; if (levels[i]<0) levels[i]=0; } else levels[i]=val; } } else levels[i]=val; if (peak_decay) { trail_counter[i]--; if (val<=(trailers[i])) { if (trail_counter[i]<=0) { trailers[i]-=peak_decay_speed; if (trailers[i] < 0) trailers[i] = 0; } } else { trailers[i]=val; trail_counter[i]=peak_hold_time; } } else trailers[i]=val; } } switch (mode) { case LAND_3D: draw_land3d_fft(); break; case EQ_2D: draw_2d_eq(); break; case LINE_EQ: draw_line_eq(); break; case SCOPE: draw_scope(); break; case SPIKE_3D: draw_spike_3d(); break; case VERT_SPECGRAM: draw_vert_specgram(); break; case VERT_SPECGRAM2: draw_vert_specgram2(); break; case HORIZ_SPECGRAM: draw_horiz_specgram(); break; default: break; } /* shift current levels into the previous levels array, */ for( i=0; i < bands; i++ ) { plevels[i]=levels[i]; ptrailers[i]=trailers[i]; } /* Frame per second counter for debugging purposes... frame_cnt++; if (frame_cnt == 10) { if (gettimeofday(&cur_time,NULL)) g_print("Gettimeofday failed!\n"); elapsed_time_sec = cur_time.tv_sec - last_time.tv_sec; elapsed_time_usec = cur_time.tv_usec - last_time.tv_usec; elapsed = elapsed_time_sec + (float)elapsed_time_usec/1000000; g_print("%f FPS\n", 10.0/elapsed); last_time.tv_sec=cur_time.tv_sec; last_time.tv_usec=cur_time.tv_usec; frame_cnt = 0; } */ return (TRUE); }