diff --git a/XSchemWin/XSchemWix/xschemrc b/XSchemWin/XSchemWix/xschemrc index bc0feba7..f4775d3e 100644 --- a/XSchemWin/XSchemWix/xschemrc +++ b/XSchemWin/XSchemWix/xschemrc @@ -123,7 +123,6 @@ # set netlist_type spice #### Some netlisting options (these are the defaults) -# set hspice_netlist 1 # set verilog_2001 1 #### to use a fixed line with set change_lw to 0 and set some value to line_width @@ -179,7 +178,13 @@ #### instead of looking only in symbol directory. Default: disabled (0). # set search_schematic 0 - +#### focus the schematic window if mouse goes over it, even if a dialog box +#### is displayed, without needing to click. +#### This allows to move/zoom/pan the schematic while editing attributes. +#### Clicking in the schematic window usually closes the dialog box or starts +#### editing a new component if clicking on a new component. +#### default: enabled (1) +# set autofocus_mainwindow 0 ########################################################################### #### EXPORT FORMAT TRANSLATORS, PNG AND PDF ########################################################################### @@ -300,12 +305,6 @@ set editor {notepad.exe} # set show_infowindow 0 ########################################################################### -#### CONFIGURE COMPUTER FARM JOB REDIRECTORS FOR SIMULATIONS -########################################################################### -#### RTDA NC -# set computerfarm {nc run -Il} -#### LSF BSUB -# set computerfarm {bsub -Is} ########################################################################### #### TCP CONNECTION WITH GAW @@ -358,4 +357,25 @@ set editor {notepad.exe} ## like FAT32 or NTFS. ## Do not set this option if you don't know what you are doing. ## Default: not enabled (0) -# set case_insensitive 1 \ No newline at end of file +# set case_insensitive 1 + +########################################################################### +#### SHOW HIDDEN TEXTS +########################################################################### +## This option shows text objects even if they have attribute 'hide=true' set +## default: 0 (not set) +# set show_hidden_texts 1 + +########################################################################### +#### HIDE GRAPHS IF NO SPICE DATA LOADED +########################################################################### +## if enabled graphs will be hidden if no data is loaded. +## default: not enabled (0) +# set hide_empty_graphs 0 + +########################################################################### +#### LIVE BACKANNOTATION OF DATA AT CURSOR 2 (B) POSITION +########################################################################### +## if enabled will backannotate values in schematic at cursor 'b' position +## in graph. Default: not enabled (0) +# set live_cursor2_backannotate 1 \ No newline at end of file diff --git a/src/callback.c b/src/callback.c index 4e4173dc..e20a7891 100644 --- a/src/callback.c +++ b/src/callback.c @@ -177,7 +177,7 @@ static void backannotate_at_cursor_b_pos(xRect *r, Graph_ctx *gr) { if(xctx->graph_values) { - int dset, first, last, dataset = gr->dataset, i, p, ofs; + int dset, first, last, dataset = gr->dataset, i, p, ofs = 0; double start, end; int sweepvar_wrap = 0, sweep_idx; double xx, cursor2; /* xx is the p-th sweep variable value, cursor2 is cursor 'b' x position */ @@ -195,6 +195,7 @@ static void backannotate_at_cursor_b_pos(xRect *r, Graph_ctx *gr) dbg(1, "cursor b pos: %g dataset=%d\n", cursor2, gr->dataset); if(dataset < 0) dataset = 0; /* if all datasets are plotted use first for backannotation */ dbg(1, "dataset=%d\n", dataset); + ofs = 0; for(dset = 0 ; dset < xctx->graph_datasets; dset++) { double prev_x, prev_prev_x; int cnt=0, wrap; @@ -210,7 +211,7 @@ static void backannotate_at_cursor_b_pos(xRect *r, Graph_ctx *gr) cnt = 0; } if(xx >= start && xx <= end) { - int s; + int s=0; if((dataset == -1 && sweepvar_wrap == 0) || (dataset == sweepvar_wrap)) { if(first == -1) first = p; if(p == first) { diff --git a/src/draw.c b/src/draw.c index 6f5f9bc9..07eaeced 100644 --- a/src/draw.c +++ b/src/draw.c @@ -2338,20 +2338,6 @@ int embed_rawfile(const char *rawfile) return res; } -int read_embedded_rawfile(void) -{ - int res = 0; - - if(xctx->lastsel==1 && xctx->sel_array[0].type==ELEMENT) { - xInstance *i = &xctx->inst[xctx->sel_array[0].n]; - const char *b64_spice_data; - if(i->prop_ptr && (b64_spice_data = get_tok_value(i->prop_ptr, "spice_data", 0))[0]) { - res = read_rawfile_from_attr(b64_spice_data, strlen(b64_spice_data)); - } - } - return res; -} - /* when double clicking in a graph if this happens on a wave label * what == 1: * look up the wave and call tcl "graph_edit_wave " diff --git a/src/save.c b/src/save.c index 5f20bd2d..80a2ed88 100644 --- a/src/save.c +++ b/src/save.c @@ -231,7 +231,7 @@ static void read_binary_block(FILE *fd) int offset = 0; int ac = 0; - if(xctx->graph_sim_type == 3) ac = 1; /* AC analysis, complex numbers twice the size */ + if(!strcmp(xctx->graph_sim_type, "ac")) ac = 1; /* AC analysis, complex numbers twice the size */ for(p = 0 ; p < xctx->graph_datasets; p++) { offset += xctx->graph_npoints[p]; @@ -296,101 +296,128 @@ static void read_binary_block(FILE *fd) * 157 i(v1) current * Binary: */ -static int read_dataset(FILE *fd) +static int read_dataset(FILE *fd, const char *type) { int variables = 0, i, done_points = 0; char line[PATH_MAX], varname[PATH_MAX]; char *ptr; - int n = 0, done_header = 0; - int exit_status = 0; - xctx->graph_sim_type = 0; - + int n = 0, done_header = 0, ac = 0; + int exit_status = 0, npoints, nvars; + int dbglev=1; + xctx->graph_sim_type = NULL; + dbg(1, "read_dataset(): type=%s\n", type ? type : ""); while((fgets(line, sizeof(line), fd)) ) { - /* after this line comes the binary blob made of nvars * npoints * sizeof(double) bytes */ - if(!strcmp(line, "Values:\n") || !strcmp(line, "Values:\r\n")) { /* this is an ASCII raw file. We don't handle this (yet) */ + /* this is an ASCII raw file. We don't handle this (yet) */ + if(!strcmp(line, "Values:\n") || !strcmp(line, "Values:\r\n")) { free_rawfile(0); - dbg(0, "read_dataset(): ASCII raw files can not be read. " + dbg(dbglev, "read_dataset(): ASCII raw files can not be read. " "Use binary format in ngspice (set filetype=binary)\n"); tcleval("alert_ {read_dataset(): ASCII raw files can not be read. " "Use binary format in ngspice (set filetype=binary)}"); return 0; } + /* after this line comes the binary blob made of nvars * npoints * sizeof(double) bytes */ if(!strcmp(line, "Binary:\n") || !strcmp(line, "Binary:\r\n")) { - int npoints = xctx->graph_npoints[xctx->graph_datasets]; if(xctx->graph_sim_type) { done_header = 1; - dbg(1, "read_dataset(): read binary block, nvars=%d npoints=%d\n", xctx->graph_nvars, npoints); + dbg(dbglev, "read_dataset(): read binary block, nvars=%d npoints=%d\n", nvars, npoints); read_binary_block(fd); xctx->graph_datasets++; exit_status = 1; } else { - dbg(1, "read_dataset(): skip binary block, nvars=%d npoints=%d\n", xctx->graph_nvars, npoints); - fseek(fd, (xctx->graph_nvars) * npoints * sizeof(double), SEEK_CUR); /* skip binary block */ + dbg(dbglev, "read_dataset(): skip binary block, nvars=%d npoints=%d\n", nvars, npoints); + fseek(fd, nvars * npoints * sizeof(double), SEEK_CUR); /* skip binary block */ } done_points = 0; + ac = 0; } + /* if type is given (not NULL) choose the simulation that matches type, else take the first one */ + /* if xctx->graph_sim_type is set skip all datasets that do not match */ else if(!strncmp(line, "Plotname:", 9) && strstr(line, "Transient Analysis")) { - if(xctx->graph_sim_type && xctx->graph_sim_type != 1) xctx->graph_sim_type = 0; - else xctx->graph_sim_type = 1; + if(xctx->graph_sim_type && strcmp(xctx->graph_sim_type, "tran")) xctx->graph_sim_type = NULL; + else if(type && !strcmp(type, "tran")) xctx->graph_sim_type = "tran"; + else if(type && strcmp(type, "tran")) xctx->graph_sim_type = NULL; + else xctx->graph_sim_type = "tran"; + dbg(dbglev, "read_dataset(): tran graph_sim_type=%s\n", xctx->graph_sim_type ? xctx->graph_sim_type : ""); } else if(!strncmp(line, "Plotname:", 9) && strstr(line, "DC transfer characteristic")) { - if(xctx->graph_sim_type && xctx->graph_sim_type != 2) xctx->graph_sim_type = 0; - else xctx->graph_sim_type = 2; + if(xctx->graph_sim_type && strcmp(xctx->graph_sim_type, "dc")) xctx->graph_sim_type = NULL; + else if(type && !strcmp(type, "dc")) xctx->graph_sim_type = "dc"; + else if(type && strcmp(type, "dc")) xctx->graph_sim_type = NULL; + else xctx->graph_sim_type = "dc"; + dbg(dbglev, "read_dataset(): dc graph_sim_type=%s\n", xctx->graph_sim_type ? xctx->graph_sim_type : ""); } else if(!strncmp(line, "Plotname:", 9) && strstr(line, "Operating Point")) { - if(xctx->graph_sim_type && xctx->graph_sim_type != 4) xctx->graph_sim_type = 0; - else xctx->graph_sim_type = 4; + if(xctx->graph_sim_type && strcmp(xctx->graph_sim_type, "op")) xctx->graph_sim_type = NULL; + else if(type && !strcmp(type, "op")) xctx->graph_sim_type = "op"; + else if(type && strcmp(type, "op")) xctx->graph_sim_type = NULL; + else xctx->graph_sim_type = "op"; + dbg(dbglev, "read_dataset(): op graph_sim_type=%s\n", xctx->graph_sim_type ? xctx->graph_sim_type : ""); } else if(!strncmp(line, "Plotname:", 9) && strstr(line, "AC Analysis")) { - if(xctx->graph_sim_type && xctx->graph_sim_type != 3) xctx->graph_sim_type = 0; - else xctx->graph_sim_type = 3; - } - else if(!strncmp(line, "Plotname:", 9) && strstr(line, "constants")) { - if(xctx->graph_sim_type && xctx->graph_sim_type != 2) xctx->graph_sim_type = 0; - else xctx->graph_sim_type = 2; + ac = 1; + if(xctx->graph_sim_type && strcmp(xctx->graph_sim_type, "ac")) xctx->graph_sim_type = NULL; + else if(type && !strcmp(type, "ac")) xctx->graph_sim_type = "ac"; + else if(type && strcmp(type, "ac")) xctx->graph_sim_type = NULL; + else xctx->graph_sim_type = "ac"; + dbg(dbglev, "read_dataset(): ac graph_sim_type=%s\n", xctx->graph_sim_type ? xctx->graph_sim_type : ""); } else if(!strncmp(line, "Plotname:", 9)) { - xctx->graph_sim_type = 0; + char name[PATH_MAX]; + xctx->graph_sim_type = NULL; + n = sscanf(line, "Plotname: %s", name); + if(n==1) { + if(xctx->graph_sim_type && strcmp(xctx->graph_sim_type, "custom")) xctx->graph_sim_type = NULL; + else if(type && !strcmp(type, name)) xctx->graph_sim_type = "custom"; + } } /* points and vars are needed for all sections (also ones we are not interested in) * to skip binary blobs */ else if(!strncmp(line, "No. of Data Rows :", 18)) { /* array of number of points of datasets (they are of varialbe length) */ - my_realloc(1414, &xctx->graph_npoints, (xctx->graph_datasets+1) * sizeof(int)); - n = sscanf(line, "No. of Data Rows : %d", &xctx->graph_npoints[xctx->graph_datasets]); + n = sscanf(line, "No. of Data Rows : %d", &npoints); if(n < 1) { dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n"); return 1; } - /* multi-point OP is equivalent to a DC sweep. Change xctx->graph_sim_type */ - if(xctx->graph_npoints[xctx->graph_datasets] > 1 && xctx->graph_sim_type == 4 ) { - xctx->graph_sim_type = 2; - } else if(xctx->graph_sim_type == 4) xctx->graph_sim_type = 0; - + if(xctx->graph_sim_type) { + my_realloc(1414, &xctx->graph_npoints, (xctx->graph_datasets+1) * sizeof(int)); + xctx->graph_npoints[xctx->graph_datasets] = npoints; + /* multi-point OP is equivalent to a DC sweep. Change xctx->graph_sim_type */ + if(xctx->graph_npoints[xctx->graph_datasets] > 1 && !strcmp(xctx->graph_sim_type, "op") ) { + xctx->graph_sim_type = "dc"; + } + } done_points = 1; } else if(!strncmp(line, "No. Variables:", 14)) { - n = sscanf(line, "No. Variables: %d", &xctx->graph_nvars); + n = sscanf(line, "No. Variables: %d", &nvars); + dbg(dbglev, "read_dataset(): nvars=%d\n", nvars); + if(ac) nvars <<= 1; if(n < 1) { dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n"); return 1; } - if(xctx->graph_sim_type == 3) xctx->graph_nvars <<= 1; /* mag and phase */ - + if(xctx->graph_sim_type) { + xctx->graph_nvars = nvars; + } } else if(!done_points && !strncmp(line, "No. Points:", 11)) { - my_realloc(1415, &xctx->graph_npoints, (xctx->graph_datasets+1) * sizeof(int)); - n = sscanf(line, "No. Points: %d", &xctx->graph_npoints[xctx->graph_datasets]); + n = sscanf(line, "No. Points: %d", &npoints); if(n < 1) { dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n"); return 1; } - /* multi-point OP is equivalent to a DC sweep. Change xctx->graph_sim_type */ - if(xctx->graph_npoints[xctx->graph_datasets] > 1 && xctx->graph_sim_type == 4 ) { - xctx->graph_sim_type = 2; - } else if(xctx->graph_sim_type == 4) xctx->graph_sim_type = 0; + if(xctx->graph_sim_type) { + my_realloc(1415, &xctx->graph_npoints, (xctx->graph_datasets+1) * sizeof(int)); + xctx->graph_npoints[xctx->graph_datasets] = npoints; + /* multi-point OP is equivalent to a DC sweep. Change xctx->graph_sim_type */ + if(xctx->graph_npoints[xctx->graph_datasets] > 1 && !strcmp(xctx->graph_sim_type, "op") ) { + xctx->graph_sim_type = "dc"; + } + } } - if(!done_header && variables) { + if(xctx->graph_sim_type && !done_header && variables) { /* get the list of lines with index and node name */ if(!xctx->graph_names) xctx->graph_names = my_calloc(426, xctx->graph_nvars, sizeof(char *)); n = sscanf(line, "%d %s", &i, varname); /* read index and name of saved waveform */ @@ -405,7 +432,7 @@ static int read_dataset(FILE *fd) if(*ptr == ':') *ptr = '.'; ptr++; } - if(xctx->graph_sim_type == 3) { /* AC */ + if(xctx->graph_sim_type && !strcmp(xctx->graph_sim_type, "ac")) { /* AC */ my_strcat(415, &xctx->graph_names[i << 1], varname); int_hash_lookup(xctx->graph_raw_table, xctx->graph_names[i << 1], (i << 1), XINSERT_NOREPLACE); if(strstr(varname, "v(") == varname || strstr(varname, "i(") == varname) @@ -418,15 +445,17 @@ static int read_dataset(FILE *fd) int_hash_lookup(xctx->graph_raw_table, xctx->graph_names[i], i, XINSERT_NOREPLACE); } /* use hash table to store index number of variables */ - dbg(1, "read_dataset(): get node list -> names[%d] = %s\n", i, xctx->graph_names[i]); + dbg(dbglev, "read_dataset(): get node list -> names[%d] = %s\n", i, xctx->graph_names[i]); } /* after this line comes the list of indexes and associated nodes */ if(xctx->graph_sim_type && !strncmp(line, "Variables:", 10)) { variables = 1 ; } } - dbg(1, "read_dataset(): datasets=%d, last npoints=%d, nvars=%d\n", - xctx->graph_datasets, xctx->graph_npoints[xctx->graph_datasets-1], xctx->graph_nvars); + if(exit_status == 0 && xctx->graph_datasets && xctx->graph_npoints) { + dbg(dbglev, "raw file read: datasets=%d, last dataset points=%d, nvars=%d\n", + xctx->graph_datasets, xctx->graph_npoints[xctx->graph_datasets-1], xctx->graph_nvars); + } return exit_status; } @@ -486,7 +515,7 @@ char *base64_from_file(const char *f, size_t *length) return b64s; } -int read_rawfile_from_attr(const char *b64s, size_t length) +int raw_read_from_attr(const char *type) { int res = 0; unsigned char *s; @@ -494,51 +523,60 @@ int read_rawfile_from_attr(const char *b64s, size_t length) FILE *fd; char *tmp_filename; + if(xctx->graph_values || xctx->graph_npoints || xctx->graph_nvars || xctx->graph_datasets) { - dbg(0, "read_rawfile(_from_attr(): must clear current raw file before loading new\n"); + dbg(0, "raw_read(_from_attr(): must clear current raw file before loading new\n"); return res; } - if( (fd = open_tmpfile("rawfile_", &tmp_filename)) ) { - s = base64_decode(b64s, length, &decoded_length); - fwrite(s, decoded_length, 1, fd); - fclose(fd); - my_free(1479, &s); - res = read_rawfile(tmp_filename); - unlink(tmp_filename); - - } else { - dbg(0, "read_rawfile_from_attr(): failed to open file %s for reading\n", tmp_filename); + if(xctx->lastsel==1 && xctx->sel_array[0].type==ELEMENT) { + xInstance *i = &xctx->inst[xctx->sel_array[0].n]; + const char *b64_spice_data; + size_t length; + if(i->prop_ptr && (b64_spice_data = get_tok_value(i->prop_ptr, "spice_data", 0))[0]) { + length = strlen(b64_spice_data); + if( (fd = open_tmpfile("embedded_rawfile_", &tmp_filename)) ) { + s = base64_decode(b64_spice_data, length, &decoded_length); + fwrite(s, decoded_length, 1, fd); + fclose(fd); + my_free(1479, &s); + res = raw_read(tmp_filename, type); + unlink(tmp_filename); + } else { + dbg(0, "read_rawfile_from_attr(): failed to open file %s for reading\n", tmp_filename); + } + } } return res; } /* read a ngspice raw file (with data portion in binary format) */ -int read_rawfile(const char *f) +int raw_read(const char *f, const char *type) { int res = 0; FILE *fd; if(xctx->graph_values || xctx->graph_npoints || xctx->graph_nvars || xctx->graph_datasets) { - dbg(0, "read_rawfile(): must clear current raw file before loading new\n"); + dbg(0, "raw_read(): must clear current raw file before loading new\n"); return res; } fd = fopen(f, fopen_read_mode); if(fd) { - if((res = read_dataset(fd)) == 1) { + if((res = read_dataset(fd, type)) == 1) { int i; - dbg(0, "Raw file data read: %s\n", f); my_strdup2(1394, &xctx->graph_raw_schname, xctx->sch[xctx->currsch]); xctx->graph_allpoints = 0; for(i = 0; i < xctx->graph_datasets; i++) { xctx->graph_allpoints += xctx->graph_npoints[i]; } - draw(); + dbg(0, "Raw file data read: %s\n", f); + dbg(0, "points=%d, vars=%d, datasets=%d\n", + xctx->graph_allpoints, xctx->graph_nvars, xctx->graph_datasets); } else { - dbg(0, "read_rawfile(): no useful data found\n"); + dbg(0, "raw_read(): no useful data found\n"); } fclose(fd); return res; } - dbg(0, "read_rawfile(): failed to open file %s for reading\n", f); + dbg(0, "raw_read(): failed to open file %s for reading\n", f); return 0; } diff --git a/src/scheduler.c b/src/scheduler.c index fcf868a7..0c9095c2 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -364,6 +364,32 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg draw(); } + else if(!strcmp(argv[1],"annotate_op")) + { + int i; + char f[PATH_MAX]; + cmd_found = 1; + if(argc > 2) { + my_snprintf(f, S(f), "%s", argv[2]); + } else { + my_snprintf(f, S(f), "%s/%s.raw", tclgetvar("netlist_dir"), skip_dir(xctx->sch[xctx->currsch])); + } + tclsetvar("rawfile_loaded", "0"); + free_rawfile(1); + raw_read(f, "op"); + if(xctx->graph_values) xctx->graph_backannotate_p = 0; + for(i = 0; i < xctx->graph_nvars; i++) { + char s[100]; + int p = 0; + my_snprintf(s, S(s), "%.4g", xctx->graph_values[i][p]); + dbg(1, "%s = %g\n", xctx->graph_names[i], xctx->graph_values[i][p]); + tclvareval("array set ngspice::ngspice_data [list {", xctx->graph_names[i], "} ", s, "]", NULL); + } + tclvareval("set ngspice::ngspice_data(n\\ vars) ", my_itoa( xctx->graph_nvars), NULL); + tclvareval("set ngspice::ngspice_data(n\\ points) 1", NULL); + draw(); + } + else if(!strcmp(argv[1],"arc")) { cmd_found = 1; @@ -2167,8 +2193,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg tclsetvar("rawfile_loaded", "0"); } else if(argc > 2) { free_rawfile(0); - read_rawfile(argv[2]); - if(schematic_waves_loaded()) tclsetvar("rawfile_loaded", "1"); + if(argc > 3) raw_read(argv[2], argv[3]); + else raw_read(argv[2], NULL); + if(schematic_waves_loaded()) { + tclsetvar("rawfile_loaded", "1"); + draw(); + } else tclsetvar("rawfile_loaded", "0"); } Tcl_ResetResult(interp); @@ -2180,8 +2210,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg free_rawfile(1); } else { free_rawfile(0); - read_embedded_rawfile(); - if(schematic_waves_loaded()) tclsetvar("rawfile_loaded", "1"); + if(argc > 2) raw_read_from_attr(argv[2]); + else raw_read_from_attr(NULL); + if(schematic_waves_loaded()) { + tclsetvar("rawfile_loaded", "1"); + draw(); + } else tclsetvar("rawfile_loaded", "0"); } Tcl_ResetResult(interp); diff --git a/src/xinit.c b/src/xinit.c index fa523b3c..6e9eae46 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -449,7 +449,7 @@ static void alloc_xschem_data(const char *top_path, const char *win_path) xctx->graph_bottom = 0; xctx->graph_left = 0; xctx->graph_lastsel = -1; - xctx->graph_sim_type = 0; /* type of sim, 1: Tran, 2: Dc, 3: Ac */ + xctx->graph_sim_type = NULL; /* type of sim, "tran", "dc", "op", "ac", ... */ xctx->graph_backannotate_p = -1; /* point in raw file to use for annotating voltages/currents/etc */ xctx->graph_struct.hilight_wave = -1; /* index of wave */ xctx->graph_raw_schname = NULL; diff --git a/src/xschem.h b/src/xschem.h index 591254ff..dd3a29d0 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -908,7 +908,7 @@ typedef struct { int graph_bottom; int graph_left; int graph_lastsel; /* last graph that was clicked (selected) */ - int graph_sim_type; /* type of sim, 1: Tran, 2: Dc, 3: Ac */ + const char *graph_sim_type; /* type of sim, "tran", "dc", "ac", "op", ... */ int graph_backannotate_p; /* point in raw file to use for annotating schematic voltages/currents/etc */ Int_hashentry **graph_raw_table; /* when descending hierarchy xctx->current_name changes, xctx->graph_raw_schname @@ -1031,8 +1031,8 @@ extern void draw_image(int dr, xRect *r, double *x1, double *y1, double *x2, dou extern int filter_data(const char *din, const size_t ilen, char **dout, size_t *olen, const char *cmd); extern int embed_rawfile(const char *rawfile); -extern int read_rawfile_from_attr(const char *b64s, size_t length); -extern int read_embedded_rawfile(void); +extern int read_rawfile_from_attr(const char *b64s, size_t length, const char *type); +extern int raw_read_from_attr(const char *type); extern char *base64_from_file(const char *f, size_t *length); extern int set_rect_flags(xRect *r); extern int set_rect_extraptr(int what, xRect *drptr); @@ -1040,7 +1040,7 @@ extern unsigned char *base64_decode(const char *data, const size_t input_length, extern char *base64_encode(const unsigned char *data, const size_t input_length, size_t *output_length, int brk); extern int get_raw_index(const char *node); extern void free_rawfile(int dr); -extern int read_rawfile(const char *f); +extern int raw_read(const char *f, const char *type); extern double get_raw_value(int dataset, int idx, int point); extern int plot_raw_custom_data(int sweep_idx, int first, int last, const char *ntok); extern int calc_custom_data_yrange(int sweep_idx, const char *express, Graph_ctx *gr); diff --git a/xschem_library/examples/plot_manipulation.sch b/xschem_library/examples/plot_manipulation.sch index 630d5a4c..e3dd8da8 100644 --- a/xschem_library/examples/plot_manipulation.sch +++ b/xschem_library/examples/plot_manipulation.sch @@ -1,9 +1,29 @@ -v {xschem version=2.9.8 file_version=1.2} +v {xschem version=3.1.0 file_version=1.2 +} G {} K {} V {} S {} E {} +B 2 970 -630 1770 -230 {flags=graph +y1=-4.3e-13 +y2=1.4 +ypos1=0 +ypos2=2 +divy=5 +subdivy=1 +unity=1 +x1=0 +x2=6 +divx=5 +subdivx=1 +node=s_vec +color=4 +dataset=0 +unitx=u +logx=0 +logy=0 +} T {This example shows how to create an ngspice custom plot some op analyses are done and operating point data for node 'S' of all op runs is collected and stored into a new vector, @@ -97,6 +117,7 @@ value=" .option savecurrents .include \\"models_cmos_example.txt\\" .control +save all let vol = 0 let i = 1 set curplot = new $ create a new plot @@ -131,3 +152,10 @@ plot s_vec C {ngspice_probe.sym} 500 -210 0 0 {name=r9} C {lab_pin.sym} 430 -370 0 0 {name=p12 lab=G net_name=true} C {lab_pin.sym} 500 -230 0 0 {name=p19 lab=S net_name=true} +C {launcher.sym} 1100 -200 0 0 {name=h3 +descr="Select arrow and +Ctrl-Left-Click to load/unload waveforms" +tclcommand=" +xschem raw_read $netlist_dir/[file tail [file rootname [xschem get current_name]]].raw myplot +" +} diff --git a/xschem_library/examples/poweramp.sch b/xschem_library/examples/poweramp.sch index e9f1a958..34d7f336 100644 --- a/xschem_library/examples/poweramp.sch +++ b/xschem_library/examples/poweramp.sch @@ -19,8 +19,8 @@ B 2 1200 -500 1880 -310 {flags=graph y1 = -0.0059 y2 = 11 divy = 6 -x1=0.00757478 -x2=0.00916695 +x1=8e-09 +x2=0.0124755 divx=10 node="i(v.x1.vu) i(v.x0.vu) @@ -29,11 +29,11 @@ i(v.x0.vd)" color="11 13 12 7" unitx=m} B 2 1200 -830 1880 -520 {flags=graph -y1 = -49 -y2 = 59 +y1 = -31 +y2 = 77 divy = 12 -x1=0.00757478 -x2=0.00916695 +x1=8e-09 +x2=0.0124755 divx=10 node="outp outm @@ -47,8 +47,8 @@ B 2 1200 -1020 1880 -830 {flags=graph y1 = 2.4e-11 y2 = 840 divy = 6 -x1=0.00757478 -x2=0.00916695 +x1=8e-09 +x2=0.0124755 divx=10 @@ -60,8 +60,8 @@ B 2 1200 -310 1880 -120 {flags=graph y1 = 0.0077 y2 = 850 divy = 6 -x1=0.00757478 -x2=0.00916695 +x1=8e-09 +x2=0.0124755 divx=10 @@ -308,7 +308,7 @@ C {spice_probe.sym} 670 -1120 0 0 {name=p43 analysis=tran } C {spice_probe.sym} 950 -1200 0 0 {name=p44 analysis=tran } C {launcher.sym} 1000 -270 0 0 {name=h1 descr="Backannotate" -tclcommand="ngspice::annotate $netlist_dir/poweramp_op.raw"} +tclcommand="xschem annotate_op"} C {ngspice_get_expr.sym} 130 -1010 0 0 {name=r19 node="[ngspice::get_current \{r9[i]\}]" descr = current @@ -318,7 +318,7 @@ C {spice_probe.sym} 300 -1060 0 0 {name=p46 analysis=tran } C {launcher.sym} 1145 -1165 0 0 {name=h5 descr="load ngspice waves" tclcommand=" -xschem raw_read $netlist_dir/poweramp.raw +xschem raw_read $netlist_dir/poweramp.raw tran " } C {launcher.sym} 1450 -30 0 0 {name=h6 @@ -377,6 +377,6 @@ vvss vss 0 dc 0 C {launcher.sym} 1495 -1165 0 0 {name=h7 descr="load Xyce waves" tclcommand=" -xschem raw_read $netlist_dir/poweramp_xyce.raw +xschem raw_read $netlist_dir/poweramp_xyce.raw tran " } diff --git a/xschem_library/ngspice/autozero_comp.sch b/xschem_library/ngspice/autozero_comp.sch index 3ade1b78..47dc549d 100644 --- a/xschem_library/ngspice/autozero_comp.sch +++ b/xschem_library/ngspice/autozero_comp.sch @@ -19,12 +19,12 @@ L 4 410 -150 570 -150 {} L 4 570 -170 570 -150 {} L 4 570 -170 690 -170 {} L 7 1090 -260 2520 -260 {} -B 2 260 -1080 720 -920 {flags=graph +B 2 300 -1060 760 -900 {flags=graph y1 = 0 y2 = 0.93 divy = 5 -x1=8.50726e-08 -x2=4.38966e-07 +x1=6.17604e-08 +x2=4.71882e-07 divx=5 subdivx=4 unitx=n @@ -32,12 +32,12 @@ node="cal saout" color="4 5" dataset=-1} -B 2 260 -1220 720 -1090 {flags=graph +B 2 300 -1200 760 -1070 {flags=graph y1 = 0.647319 y2 = 0.652563 divy = 5 -x1=8.50726e-08 -x2=4.38966e-07 +x1=6.17604e-08 +x2=4.71882e-07 unitx=n divx=5 subdivx=4 @@ -45,6 +45,22 @@ node="plus minus" color="4 5" dataset=-1} +B 2 300 -1300 760 -1200 {flags=graph +y1 = 0 +y2 = 1 +divy = 5 +x1=6.17604e-08 +x2=4.71882e-07 +unitx=n +divx=5 +subdivx=4 +node="en +cal" +color="4 4" +dataset=-1 +digital=1 +ypos1=0.0602914 +ypos2=0.292255} T {CAL} 140 -180 0 1 0.4 0.4 {} T {EN} 140 -130 0 1 0.4 0.4 {} T {CALIBRATION @@ -60,7 +76,7 @@ Gaussian Threshold variation (via delvto parameter) is added to all MOS transist T {.param ABSVAR=0.05 delvto='agauss(0,ABSVAR,3)'} 1390 -120 0 0 0.6 0.6 {layer=8} T {Select one or more graphs (and no other objects) -and use arrow keys to zoom / pan waveforms} 300 -1320 0 0 0.3 0.3 {} +and use arrow keys to zoom / pan waveforms} 310 -1380 0 0 0.3 0.3 {} N 120 -470 120 -450 {lab=TEMPERAT} N 160 -1180 190 -1180 {lab=VSS} N 160 -1150 160 -1130 {lab=VSS} @@ -379,7 +395,7 @@ tclcommand="xschem netlist; xschem simulate"} C {parax_cap.sym} 980 -1090 0 0 {name=c4 value=5f} C {parax_cap.sym} 1470 -1090 0 0 {name=c6 value=5f} C {parax_cap.sym} 1960 -1090 0 0 {name=c7 value=5f} -C {launcher.sym} 315 -1365 0 0 {name=h1 +C {launcher.sym} 315 -1415 0 0 {name=h1 descr="Select arrow and Ctrl-Left-Click to load/unload waveforms" tclcommand="