From bd626427fda1c5acd1c9bc821795c3a8aaeb1083 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Wed, 17 Nov 2021 01:12:55 +0100 Subject: [PATCH] fix status bar info correctly swicthing when focusing multiple xschem child windows; multiple schematic window handling within one xschem instance is now working --- doc/xschem_man/run_xschem.html | 1 + src/actions.c | 12 ++--- src/callback.c | 10 ++++- src/globals.c | 2 +- src/netlist.c | 27 +++++------ src/options.c | 4 ++ src/save.c | 4 +- src/scheduler.c | 82 ++++++++++++++++++++++------------ src/spice_netlist.c | 17 +++++-- src/verilog_netlist.c | 16 +++++-- src/vhdl_netlist.c | 16 +++++-- src/xinit.c | 32 ++++++------- src/xschem.h | 2 +- src/xschem.help | 1 + src/xschem.tcl | 62 ++++++++++++++----------- 15 files changed, 175 insertions(+), 113 deletions(-) diff --git a/doc/xschem_man/run_xschem.html b/doc/xschem_man/run_xschem.html index 1b2c47dd..fd0a4bf5 100644 --- a/doc/xschem_man/run_xschem.html +++ b/doc/xschem_man/run_xschem.html @@ -66,6 +66,7 @@ Options: --netlist_filename <file> -t --tedax Set netlist type to tEDAx. -s --spice Set netlist type to SPICE. + -y --symbol Set netlist type to SYMBOL (used when drawing symbols) -x --no_x Don't use X (only command mode). -z --rainbow Use a raibow-looking layer color table. -W --waves Show simulation waveforms. diff --git a/src/actions.c b/src/actions.c index 24562408..db068449 100644 --- a/src/actions.c +++ b/src/actions.c @@ -294,19 +294,19 @@ void new_window(const char *cell, int symbol) /* child of child */ if(!cell || !cell[0]) { if(!symbol) - execl(xschem_executable,xschem_executable,"-b", "--tcl", - "set netlist_type spice; set XSCHEM_START_WINDOW {}", NULL); + execl(xschem_executable,xschem_executable, "-b", "-s", "--tcl", + "set XSCHEM_START_WINDOW {}", NULL); else - execl(xschem_executable,xschem_executable,"-b", "--tcl", - "set netlist_type symbol; set XSCHEM_START_WINDOW {}", NULL); + execl(xschem_executable,xschem_executable, "-b", "-y", "--tcl", + "set XSCHEM_START_WINDOW {}", NULL); } else if(!symbol) { my_strncpy(f, cell, S(f)); - execl(xschem_executable,xschem_executable,"-b", "--tcl", "set netlist_type spice", f, NULL); + execl(xschem_executable,xschem_executable, "-b", "-s", f, NULL); } else { my_strncpy(f, cell, S(f)); - execl(xschem_executable,xschem_executable,"-b", "--tcl", "set netlist_type symbol", f, NULL); + execl(xschem_executable,xschem_executable, "-b", "-y", f, NULL); } } else { /* error */ diff --git a/src/callback.c b/src/callback.c index 966ef978..399df991 100644 --- a/src/callback.c +++ b/src/callback.c @@ -173,6 +173,14 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, } #endif + Tcl_VarEval(interp, xctx->top_path, ".statusbar.7 configure -text $netlist_type", NULL); + Tcl_VarEval(interp, xctx->top_path, ".statusbar.3 delete 0 end;", + xctx->top_path, ".statusbar.3 insert 0 $cadsnap", + NULL); + Tcl_VarEval(interp, xctx->top_path, ".statusbar.5 delete 0 end;", + xctx->top_path, ".statusbar.5 insert 0 $cadgrid", + NULL); + #if 0 /* exclude Motion and Expose events */ if(event!=6 /* && event!=12 */) dbg(0, "callback(): event=%d, winpath=%s, old_winpath=%s, semaphore=%d\n", @@ -773,7 +781,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key, if(key=='V' && state == ShiftMask) /* toggle spice/vhdl netlist */ { xctx->netlist_type++; if(xctx->netlist_type==6) xctx->netlist_type=1; - override_netlist_type(-1); + set_tcl_netlist_type(); break; } diff --git a/src/globals.c b/src/globals.c index 441d8a8a..cd6813a0 100644 --- a/src/globals.c +++ b/src/globals.c @@ -178,7 +178,7 @@ char old_winpath[PATH_MAX] = ".drw"; /* ---------------------------------------------------------- */ /* Cmdline options (used at xinit, and then not used anymore) */ /* ---------------------------------------------------------- */ -int cli_opt_netlist_type = -1; +int cli_opt_netlist_type = 0; char cli_opt_plotfile[PATH_MAX] = ""; diff --git a/src/netlist.c b/src/netlist.c index e47e29e3..85f5fcbd 100644 --- a/src/netlist.c +++ b/src/netlist.c @@ -522,6 +522,16 @@ void wirecheck(int k) /* recursive routine */ } } +void set_tcl_netlist_type(void) +{ + if(xctx->netlist_type == CAD_SPICE_NETLIST) tclsetvar("netlist_type", "spice"); + else if(xctx->netlist_type == CAD_VERILOG_NETLIST) tclsetvar("netlist_type", "verilog"); + else if(xctx->netlist_type == CAD_VHDL_NETLIST) tclsetvar("netlist_type", "vhdl"); + else if(xctx->netlist_type == CAD_TEDAX_NETLIST) tclsetvar("netlist_type", "tedax"); + else if(xctx->netlist_type == CAD_SYMBOL_ATTRS) tclsetvar("netlist_type", "symbol"); + else tclsetvar("netlist_type", "unknown"); +} + /* what==0 -> initialize */ /* what==1 -> get new node name, net## */ /* what==2 -> update multiplicity */ @@ -603,23 +613,6 @@ int record_global_node(int what, FILE *fp, char *node) return 0; } -/* set xctx->netlist_type tcl var to specified format, if -1 is given restore to default */ -void override_netlist_type(int type) -{ - if (type == CAD_VHDL_NETLIST) tclsetvar("netlist_type","vhdl"); - else if(type == CAD_VERILOG_NETLIST) tclsetvar("netlist_type","verilog"); - else if(type == CAD_TEDAX_NETLIST) tclsetvar("netlist_type","tedax"); - else if(type == CAD_SYMBOL_ATTRS) tclsetvar("netlist_type","symbol"); - else if(type == CAD_SPICE_NETLIST) tclsetvar("netlist_type","spice"); - else { - if (xctx->netlist_type == CAD_VHDL_NETLIST) tclsetvar("netlist_type","vhdl"); - else if(xctx->netlist_type == CAD_VERILOG_NETLIST) tclsetvar("netlist_type","verilog"); - else if(xctx->netlist_type == CAD_TEDAX_NETLIST) tclsetvar("netlist_type","tedax"); - else if(xctx->netlist_type == CAD_SYMBOL_ATTRS) tclsetvar("netlist_type","symbol"); - else if(xctx->netlist_type == CAD_SPICE_NETLIST) tclsetvar("netlist_type","spice"); - } -} - void prepare_netlist_structs(int for_netlist) { xRect *rct; diff --git a/src/options.c b/src/options.c index afb8ebe2..6fd58d6e 100644 --- a/src/options.c +++ b/src/options.c @@ -112,6 +112,10 @@ void check_opt(char *opt, char *optval, int type) dbg(1, "process_options(): set netlist type to spice\n"); cli_opt_netlist_type=CAD_SPICE_NETLIST; + } else if( (type == SHORT && *opt == 'y') || (type == LONG && !strcmp("symbol", opt)) ) { + dbg(1, "process_options(): set netlist type to symbol\n"); + cli_opt_netlist_type=CAD_SYMBOL_ATTRS; + } else if( (type == SHORT && *opt == 'V') || (type == LONG && !strcmp("vhdl", opt)) ) { dbg(1, "process_options(): set netlist type to vhdl\n"); cli_opt_netlist_type=CAD_VHDL_NETLIST; diff --git a/src/save.c b/src/save.c index d4e0f792..937e3ba2 100644 --- a/src/save.c +++ b/src/save.c @@ -1080,12 +1080,12 @@ void load_schematic(int load_symbols, const char *filename, int reset_undo) /* 2 if(!strcmp(tclresult(), "SYMBOL")) { save_netlist_type = xctx->netlist_type; xctx->netlist_type = CAD_SYMBOL_ATTRS; + set_tcl_netlist_type(); loaded_symbol = 1; - tclsetvar("netlist_type","symbol"); } else { if(loaded_symbol) { xctx->netlist_type = save_netlist_type; - override_netlist_type(-1); + set_tcl_netlist_type(); } loaded_symbol = 0; } diff --git a/src/scheduler.c b/src/scheduler.c index d223b3bd..e91a5d3e 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -204,7 +204,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg clear_drawing(); if(argc>=3 && !strcmp(argv[2],"SYMBOL")) { xctx->netlist_type = CAD_SYMBOL_ATTRS; - tclsetvar("netlist_type","symbol"); + set_tcl_netlist_type(); for(i=0;;i++) { if(i == 0) my_snprintf(name, S(name), "%s.sym", "untitled"); else my_snprintf(name, S(name), "%s-%d.sym", "untitled", i); @@ -214,7 +214,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg my_strncpy(xctx->current_name, name, S(xctx->current_name)); } else { xctx->netlist_type = CAD_SPICE_NETLIST; - tclsetvar("netlist_type","spice"); + set_tcl_netlist_type(); for(i=0;;i++) { if(i == 0) my_snprintf(name, S(name), "%s.sch", "untitled"); else my_snprintf(name, S(name), "%s-%d.sch", "untitled", i); @@ -477,12 +477,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg * ********** xschem get subcommands */ - if(!strcmp(argv[1],"get") && !strcmp(argv[2],"schname") && argc >= 3) + if(argc >= 3 && !strcmp(argv[1],"get") && !strcmp(argv[2],"schname")) { /* allows to retrieve name of n-th parent schematic */ int x; cmd_found = 1; - if(argc == 4) x = atoi(argv[3]); + if(argc >= 4) x = atoi(argv[3]); else x = xctx->currsch; if(x<0 && xctx->currsch+x>=0) { Tcl_SetResult(interp, xctx->sch[xctx->currsch+x], TCL_VOLATILE); @@ -490,7 +490,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg Tcl_SetResult(interp, xctx->sch[x], TCL_VOLATILE); } } - else if(!strcmp(argv[1],"get") && !strcmp(argv[2],"sch_path") && argc >= 3) + else if( argc >= 3 && !strcmp(argv[1],"get") && !strcmp(argv[2],"sch_path")) { int x; cmd_found = 1; @@ -593,6 +593,27 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg else if(!strcmp(argv[2],"netlist_name")) { Tcl_SetResult(interp, xctx->netlist_name, TCL_VOLATILE); } + else if(!strcmp(argv[2],"netlist_type")) + { + if(xctx->netlist_type == CAD_SPICE_NETLIST) { + Tcl_SetResult(interp, "spice", TCL_STATIC); + } + else if(xctx->netlist_type == CAD_VHDL_NETLIST) { + Tcl_SetResult(interp, "vhdl", TCL_STATIC); + } + else if(xctx->netlist_type == CAD_VERILOG_NETLIST) { + Tcl_SetResult(interp, "verilog", TCL_STATIC); + } + else if(xctx->netlist_type == CAD_TEDAX_NETLIST) { + Tcl_SetResult(interp, "tedax", TCL_STATIC); + } + else if(xctx->netlist_type == CAD_SYMBOL_ATTRS) { + Tcl_SetResult(interp, "symbol", TCL_STATIC); + } + else { + Tcl_SetResult(interp, "unknown", TCL_STATIC); + } + } else if(!strcmp(argv[2],"no_draw")) { if( xctx->no_draw != 0 ) Tcl_SetResult(interp, "1",TCL_STATIC); @@ -1469,29 +1490,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } } - else if(!strcmp(argv[1],"netlist_type")) - { - cmd_found = 1; - if(argc > 2) { - if(!strcmp(argv[2],"vhdl")) { - xctx->netlist_type=CAD_VHDL_NETLIST; - } - else if(!strcmp(argv[2],"verilog")) { - xctx->netlist_type=CAD_VERILOG_NETLIST; - } - else if(!strcmp(argv[2],"tedax")) { - xctx->netlist_type=CAD_TEDAX_NETLIST; - } - else if(!strcmp(argv[2],"symbol")) { - xctx->netlist_type=CAD_SYMBOL_ATTRS; - } - else if(!strcmp(argv[2],"spice")){ - xctx->netlist_type=CAD_SPICE_NETLIST; - } - override_netlist_type(-1); /* set tcl netlist_type variable */ - } - } - else if(!strcmp(argv[1],"new_schematic")) { cmd_found = 1; @@ -2127,6 +2125,34 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg else if(!strcmp(argv[2],"netlist_name")) { my_strncpy(xctx->netlist_name, argv[3], S(xctx->netlist_name)); } + else if(!strcmp(argv[2],"netlist_type")) + { + if(argc > 3) { + if(!strcmp(argv[3],"spice")){ + xctx->netlist_type=CAD_SPICE_NETLIST; + tclsetvar("netlist_type", "spice"); + } + else if(!strcmp(argv[3],"vhdl")) { + xctx->netlist_type=CAD_VHDL_NETLIST; + tclsetvar("netlist_type", "vhdl"); + } + else if(!strcmp(argv[3],"verilog")) { + xctx->netlist_type=CAD_VERILOG_NETLIST; + tclsetvar("netlist_type", "verilog"); + } + else if(!strcmp(argv[3],"tedax")) { + xctx->netlist_type=CAD_TEDAX_NETLIST; + tclsetvar("netlist_type", "tedax"); + } + else if(!strcmp(argv[3],"symbol")) { + xctx->netlist_type=CAD_SYMBOL_ATTRS; + tclsetvar("netlist_type", "symbol"); + } + else { + tclsetvar("netlist_type", "unknown"); + } + } + } else if(!strcmp(argv[2],"no_draw")) { int s = atoi(argv[3]); xctx->no_draw=s; diff --git a/src/spice_netlist.c b/src/spice_netlist.c index 01642061..256d78fd 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -253,11 +253,16 @@ void global_spice_netlist(int global) /* netlister driver */ if(split_f) { + int save; fclose(fd); my_snprintf(tcl_cmd_netlist, S(tcl_cmd_netlist), "netlist {%s} noshow {%s}", netl_filename, cellname); - override_netlist_type(CAD_SPICE_NETLIST); + save = xctx->netlist_type; + xctx->netlist_type = CAD_SPICE_NETLIST; + set_tcl_netlist_type(); tcleval(tcl_cmd_netlist); - override_netlist_type(-1); /* restore to xctx->netlist_type default */ + xctx->netlist_type = save; + set_tcl_netlist_type(); + if(debug_var==0) xunlink(netl_filename); } @@ -475,11 +480,15 @@ void spice_block_netlist(FILE *fd, int i) } fprintf(fd, ".ends\n\n"); if(split_f) { + int save; fclose(fd); my_snprintf(tcl_cmd_netlist, S(tcl_cmd_netlist), "netlist {%s} noshow {%s}", netl_filename, cellname); - override_netlist_type(CAD_SPICE_NETLIST); + save = xctx->netlist_type; + xctx->netlist_type = CAD_SPICE_NETLIST; + set_tcl_netlist_type(); tcleval(tcl_cmd_netlist); - override_netlist_type(-1); /* restore to xctx->netlist_type default */ + xctx->netlist_type = save; + set_tcl_netlist_type(); if(debug_var==0) xunlink(netl_filename); } } diff --git a/src/verilog_netlist.c b/src/verilog_netlist.c index 2524fd0c..af6e5c5a 100644 --- a/src/verilog_netlist.c +++ b/src/verilog_netlist.c @@ -265,11 +265,15 @@ void global_verilog_netlist(int global) /* netlister driver */ fprintf(fd, "endmodule\n"); if(split_f) { + int save; fclose(fd); my_snprintf(tcl_cmd_netlist, S(tcl_cmd_netlist), "netlist {%s} noshow {%s}", netl_filename, cellname); - override_netlist_type(CAD_VERILOG_NETLIST); + save = xctx->netlist_type; + xctx->netlist_type = CAD_VERILOG_NETLIST; + set_tcl_netlist_type(); tcleval(tcl_cmd_netlist); - override_netlist_type(-1); /* restore to xctx->netlist_type default */ + xctx->netlist_type = save; + set_tcl_netlist_type(); if(debug_var==0) xunlink(netl_filename); } @@ -496,11 +500,15 @@ void verilog_block_netlist(FILE *fd, int i) fprintf(fd,"---- end user architecture code\n"); fprintf(fd, "endmodule\n"); if(split_f) { + int save; fclose(fd); my_snprintf(tcl_cmd_netlist, S(tcl_cmd_netlist), "netlist {%s} noshow {%s}", netl_filename, cellname); - override_netlist_type(CAD_VERILOG_NETLIST); + save = xctx->netlist_type; + xctx->netlist_type = CAD_VERILOG_NETLIST; + set_tcl_netlist_type(); tcleval(tcl_cmd_netlist); - override_netlist_type(-1); /* restore to xctx->netlist_type default */ + xctx->netlist_type = save; + set_tcl_netlist_type(); if(debug_var==0) xunlink(netl_filename); } my_free(1079, &dir_tmp); diff --git a/src/vhdl_netlist.c b/src/vhdl_netlist.c index 0d57930a..d0ac9b3e 100644 --- a/src/vhdl_netlist.c +++ b/src/vhdl_netlist.c @@ -319,11 +319,15 @@ void global_vhdl_netlist(int global) /* netlister driver */ fprintf(fd, "end arch_%s ;\n\n", skip_dir( xctx->sch[xctx->currsch]) ); if(split_f) { + int save; fclose(fd); my_snprintf(tcl_cmd_netlist, S(tcl_cmd_netlist), "netlist {%s} noshow {%s}", netl_filename, cellname); - override_netlist_type(CAD_VHDL_NETLIST); + save = xctx->netlist_type; + xctx->netlist_type = CAD_VHDL_NETLIST; + set_tcl_netlist_type(); tcleval(tcl_cmd_netlist); - override_netlist_type(-1); /* restore to netlist_dir default */ + xctx->netlist_type = save; + set_tcl_netlist_type(); if(debug_var==0) xunlink(netl_filename); } xctx->netlist_count++; @@ -611,11 +615,15 @@ void vhdl_block_netlist(FILE *fd, int i) if(xctx->schvhdlprop && xctx->schvhdlprop[0]) fprintf(fd, "%s\n", xctx->schvhdlprop); fprintf(fd, "end arch_%s ;\n\n", skip_dir(xctx->sym[i].name) ); /* skip_dir( xctx->sch[xctx->currsch]) ); */ if(split_f) { + int save; fclose(fd); my_snprintf(tcl_cmd_netlist, S(tcl_cmd_netlist), "netlist {%s} noshow {%s}", netl_filename, cellname); - override_netlist_type(CAD_VHDL_NETLIST); + save = xctx->netlist_type; + xctx->netlist_type = CAD_VHDL_NETLIST; + set_tcl_netlist_type(); tcleval(tcl_cmd_netlist); - override_netlist_type(-1); /* restore to netlist_dir default */ + xctx->netlist_type = save; + set_tcl_netlist_type(); if(debug_var==0) xunlink(netl_filename); } xctx->netlist_count++; diff --git a/src/xinit.c b/src/xinit.c index c777b005..5bbc9a07 100644 --- a/src/xinit.c +++ b/src/xinit.c @@ -389,19 +389,6 @@ void free_gc() } } -void get_netlist_type_from_tcl(void) -{ - if(xctx->netlist_type==-1) { - if(!strcmp(tclgetvar("netlist_type"),"vhdl") ) xctx->netlist_type=CAD_VHDL_NETLIST; - else if(!strcmp(tclgetvar("netlist_type"),"verilog") ) xctx->netlist_type=CAD_VERILOG_NETLIST; - else if(!strcmp(tclgetvar("netlist_type"),"tedax") ) xctx->netlist_type=CAD_TEDAX_NETLIST; - else if(!strcmp(tclgetvar("netlist_type"),"symbol") ) xctx->netlist_type=CAD_SYMBOL_ATTRS; - else xctx->netlist_type=CAD_SPICE_NETLIST; - } else { - override_netlist_type(-1); /* set tcl netlist_type */ - } -} - void alloc_xschem_data(const char *top_path) { int i, j; @@ -572,7 +559,7 @@ void alloc_xschem_data(const char *top_path) xctx->n_active_layers = 0; xctx->active_layer=my_calloc(563, cadlayers, sizeof(int)); xctx->hide_symbols = 0; - xctx->netlist_type = -1; + xctx->netlist_type = CAD_SPICE_NETLIST; xctx->top_path = NULL; my_strdup2(1296, &xctx->top_path, top_path); xctx->fill_type=my_calloc(640, cadlayers, sizeof(int)); @@ -804,7 +791,6 @@ void preview_window(const char *what, const char *tk_win_path, const char *filen my_strdup(117, ¤t_file, filename); xctx = NULL; /* reset for preview */ alloc_xschem_data(""); /* alloc data into xctx */ - get_netlist_type_from_tcl(); init_pixdata(); /* populate xctx->fill_type array that is used in create_gc() to set fill styles */ preview_xctx = xctx; preview_xctx->window = pre_window; @@ -1479,10 +1465,18 @@ int Tcl_AppInit(Tcl_Interp *inter) xctx->draw_window=atoi(tclgetvar("draw_window")); /* set global variables fetching data from tcl code */ - xctx->netlist_type = cli_opt_netlist_type; - - get_netlist_type_from_tcl(); - + if(cli_opt_netlist_type) { + xctx->netlist_type = cli_opt_netlist_type; + set_tcl_netlist_type(); + } else { + const char *n; + n = tclgetvar("netlist_type"); + if(!strcmp(n, "spice")) xctx->netlist_type = CAD_SPICE_NETLIST; + else if(!strcmp(n, "vhdl")) xctx->netlist_type = CAD_VHDL_NETLIST; + else if(!strcmp(n, "verilog")) xctx->netlist_type = CAD_VERILOG_NETLIST; + else if(!strcmp(n, "tedax")) xctx->netlist_type = CAD_TEDAX_NETLIST; + else if(!strcmp(n, "symbol")) xctx->netlist_type = CAD_SYMBOL_ATTRS; + } init_pixdata();/* populate xctx->fill_type array that is used in create_gc() to set fill styles */ init_color_array(0.0, 0.0); my_snprintf(tmp, S(tmp), "%d",debug_var); diff --git a/src/xschem.h b/src/xschem.h index 1fd69104..97023228 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1139,7 +1139,7 @@ extern void select_connected_wires(int stop_at_junction); extern void draw_hilight_net(int on_window); extern void display_hilights(char **str); extern void redraw_hilights(int clear); -extern void override_netlist_type(int type); +extern void set_tcl_netlist_type(void); extern void prepare_netlist_structs(int for_netlist); extern void create_simdata(void); extern void free_simdata(void); diff --git a/src/xschem.help b/src/xschem.help index 32228d1b..426129e9 100644 --- a/src/xschem.help +++ b/src/xschem.help @@ -20,6 +20,7 @@ Options: -N Set name (only name, not path) of top level netlist file. -t --tedax Set netlist type to tEDAx. -s --spice Set netlist type to SPICE. + -y --symbol Set netlist type to SYMBOL (used when drawing symbols) -x --no_x Don't use X (only command mode). -z --rainbow Use a raibow-looking layer color table. -W --waves Show simulation waveforms. diff --git a/src/xschem.tcl b/src/xschem.tcl index 20e07014..d9adc5f9 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -131,9 +131,10 @@ proc execute {status args} { proc netlist {source_file show netlist_file} { global XSCHEM_SHAREDIR flat_netlist hspice_netlist netlist_dir - global verilog_2001 netlist_type debug_var + global verilog_2001 debug_var simuldir + set netlist_type [xschem get netlist_type] if {$debug_var <= -1} { puts "netlist: source_file=$source_file, netlist_type=$netlist_type" } if {$netlist_type eq {spice}} { if { $hspice_netlist == 1 } { @@ -309,11 +310,11 @@ proc edit_file {filename} { ## ## Other global vars: ## netlist_dir -## netlist_type ## computerfarm ## terminal +## netlist_type can be obtained with [xschem get netlist_type] proc save_sim_defaults {f} { - global sim netlist_dir netlist_type computerfarm terminal + global sim netlist_dir computerfarm terminal set a [catch {open $f w} fd] if { $a } { @@ -877,11 +878,12 @@ proc simulate {{callback {}}} { ## $S : schematic name full path (/home/schippes/.xschem/xschem_library/opamp.sch) ## $d : netlist directory - global netlist_dir netlist_type computerfarm terminal sim + global netlist_dir computerfarm terminal sim global execute_callback XSCHEM_SHAREDIR has_x OS simuldir set_sim_defaults + set netlist_type [xschem get netlist_type] if { [select_netlist_dir 0] ne {}} { set d ${netlist_dir} set tool $netlist_type @@ -1001,10 +1003,11 @@ proc waves {} { ## $S : schematic name full path (/home/schippes/.xschem/xschem_library/opamp.sch) ## $d : netlist directory - global netlist_dir netlist_type computerfarm terminal sim XSCHEM_SHAREDIR has_x + global netlist_dir computerfarm terminal sim XSCHEM_SHAREDIR has_x global bespice_listen_port env simuldir + set netlist_type [xschem get netlist_type] set_sim_defaults if { [select_netlist_dir 0] ne {}} { set d ${netlist_dir} @@ -1038,7 +1041,7 @@ proc waves {} { # ============================================================ proc utile_translate {schname} { - global netlist_dir netlist_type debug_var XSCHEM_SHAREDIR + global netlist_dir debug_var XSCHEM_SHAREDIR global utile_gui_path utile_cmd_path simuldir @@ -1048,7 +1051,7 @@ proc utile_translate {schname} { } proc utile_gui {schname} { - global netlist_dir netlist_type debug_var XSCHEM_SHAREDIR + global netlist_dir debug_var XSCHEM_SHAREDIR global utile_gui_path utile_cmd_path simuldir @@ -1058,7 +1061,7 @@ proc utile_gui {schname} { } proc utile_edit {schname} { - global netlist_dir netlist_type debug_var editor XSCHEM_SHAREDIR + global netlist_dir debug_var editor XSCHEM_SHAREDIR global utile_gui_path utile_cmd_path simuldir @@ -1068,7 +1071,7 @@ proc utile_edit {schname} { } proc get_shell { curpath } { - global netlist_dir netlist_type debug_var + global netlist_dir debug_var global terminal simuldir @@ -1076,10 +1079,11 @@ proc get_shell { curpath } { } proc edit_netlist {schname } { - global netlist_dir netlist_type debug_var + global netlist_dir debug_var global editor terminal OS simuldir + set netlist_type [xschem get netlist_type] set tmpname [file rootname "$schname"] if { [regexp vim $editor] } { set ftype "-c \":set filetype=$netlist_type\"" } else { set ftype {} } @@ -2176,7 +2180,9 @@ proc tclpropeval {s instname symname} { # this hook is called in translate() if whole string is contained in a tcleval(...) construct proc tclpropeval2 {s} { - global debug_var env netlist_type path + global debug_var env path + + set netlist_type [xschem get netlist_type] # puts "tclpropeval2: s=|$s|" if {$debug_var <=-1} {puts "tclpropeval2: $s"} set path [string range [xschem get sch_path] 1 end] @@ -2296,9 +2302,10 @@ proc ask_save { {ask {save file?}} } { proc edit_vi_prop {txtlabel} { - global XSCHEM_TMP_DIR retval symbol prev_symbol rcode debug_var netlist_type editor + global XSCHEM_TMP_DIR retval symbol prev_symbol rcode debug_var editor global user_wants_copy_cell + set netlist_dir [xschem get netlist_type] set user_wants_copy_cell 0 set rcode {} set filename .xschem_edit_file.[pid] @@ -2324,9 +2331,10 @@ proc edit_vi_prop {txtlabel} { } proc edit_vi_netlist_prop {txtlabel} { - global XSCHEM_TMP_DIR retval rcode debug_var netlist_type editor + global XSCHEM_TMP_DIR retval rcode debug_var editor global user_wants_copy_cell + set netlist_type [xschem get netlist_type] set user_wants_copy_cell 0 set filename .xschem_edit_file.[pid] if ![string compare $netlist_type "vhdl"] { set suffix vhd } else { set suffix v } @@ -3543,8 +3551,8 @@ set tctx::global_list { incr_hilight infowindow_text INITIALINSTDIR INITIALLOADDIR INITIALPROPDIR INITIALTEXTDIR input_line_cmd input_line_data launcher_default_program light_colors line_width local_netlist_dir myload_d myload_default_geometry myload_dir1 myload_dir2 myload_dirs2 myload_files1 myload_files2 myload_index1 - myload_retval myload_sash_pos myload_sel myload_type myload_yview netlist_dir netlist_show netlist_type - no_change_attrs noprint_libs old_selected_tok + myload_retval myload_sash_pos myload_sel myload_type myload_yview netlist_dir netlist_show + netlist_type no_change_attrs noprint_libs old_selected_tok only_probes path pathlist persistent_command preserve_unchanged_attrs prev_symbol ps_colors rainbow_colors rcode recentfile replace_key retval retval_orig rotated_text search_exact search_found search_select search_value selected_tok show_infowindow show_pin_net_names simconf_default_geometry simconf_vpos @@ -3715,7 +3723,7 @@ proc build_widgets { {topwin {} } } { global draw_grid big_grid_points sym_txt change_lw incr_hilight symbol_width global cadgrid draw_window show_pin_net_names toolbar_visible hide_symbols global disable_unique_names persistent_command autotrim_wires en_hilight_conn_inst - global local_netlist_dir editor netlist_dir spiceprefix initial_geometry simulate_bg + global local_netlist_dir editor netlist_type netlist_dir spiceprefix initial_geometry simulate_bg frame $topwin.menubar -relief raised -bd 2 toolbar_toolbar $topwin menubutton $topwin.menubar.file -text "File" -menu $topwin.menubar.file.menu -padx 3 -pady 0 @@ -3859,19 +3867,19 @@ proc build_widgets { {topwin {} } } { $topwin.menubar.option.menu add separator $topwin.menubar.option.menu add radiobutton -label "Spice netlist" -variable netlist_type -value spice \ -accelerator {Shift+V} \ - -command "xschem netlist_type spice" + -command "xschem set netlist_type spice" $topwin.menubar.option.menu add radiobutton -label "VHDL netlist" -variable netlist_type -value vhdl \ -accelerator {Shift+V} \ - -command "xschem netlist_type vhdl" + -command "xschem set netlist_type vhdl" $topwin.menubar.option.menu add radiobutton -label "Verilog netlist" -variable netlist_type -value verilog \ -accelerator {Shift+V} \ - -command "xschem netlist_type verilog" + -command "xschem set netlist_type verilog" $topwin.menubar.option.menu add radiobutton -label "tEDAx netlist" -variable netlist_type -value tedax \ -accelerator {Shift+V} \ - -command "xschem netlist_type tedax" + -command "xschem set netlist_type tedax" $topwin.menubar.option.menu add radiobutton -label "Symbol global attrs" -variable netlist_type -value symbol \ -accelerator {Shift+V} \ - -command "xschem netlist_type symbol" + -command "xschem set netlist_type symbol" $topwin.menubar.edit.menu add command -label "Undo" -command "xschem undo; xschem redraw" -accelerator U toolbar_create EditUndo "xschem undo; xschem redraw" "Undo" $topwin $topwin.menubar.edit.menu add command -label "Redo" -command "xschem redo; xschem redraw" -accelerator {Shift+U} @@ -4166,14 +4174,14 @@ proc build_widgets { {topwin {} } } { frame $topwin.statusbar label $topwin.statusbar.1 -text "STATUS BAR 1" label $topwin.statusbar.2 -text "SNAP:" - entry $topwin.statusbar.3 -textvariable cadsnap -relief sunken -bg white \ + entry $topwin.statusbar.3 -relief sunken -bg white \ -width 10 -foreground black -takefocus 0 label $topwin.statusbar.4 -text "GRID:" - entry $topwin.statusbar.5 -textvariable cadgrid -relief sunken -bg white \ + entry $topwin.statusbar.5 -relief sunken -bg white \ -width 10 -foreground black -takefocus 0 label $topwin.statusbar.6 -text "NETLIST MODE:" - entry $topwin.statusbar.7 -textvariable netlist_type -relief sunken -bg white \ - -width 8 -state disabled -disabledforeground black + label $topwin.statusbar.7 -relief sunken -bg white \ + -width 8 label $topwin.statusbar.8 -activebackground red -text {} } @@ -4364,6 +4372,9 @@ set_ne globfilter {*} ## list of tcl procedures to load at end of xschem.tcl set_ne tcl_files {} set_ne netlist_dir "$USER_CONF_DIR/simulations" +# this global exists only for netlist_type radiobuttons, don't use, use [xschem] subcommand to get/set values +# it is also used in xschemrc to set initial netlist type. +set_ne netlist_type spice set_ne local_netlist_dir 0 ;# if set use /simulation for netlist and sims set_ne bus_replacement_char {} ;# use {<>} to replace [] with <> in bussed signals set_ne hspice_netlist 1 @@ -4372,7 +4383,6 @@ set_ne spiceprefix 1 set_ne verilog_2001 1 set_ne split_files 0 set_ne flat_netlist 0 -set_ne netlist_type spice set_ne netlist_show 0 set_ne color_ps 1 set_ne transparent_svg 0