From cdecc6ad04602c01b97c95183f7654f5e8fa6482 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Mon, 3 Jul 2023 09:06:46 +0200 Subject: [PATCH] xschem netlist command accepts an optional filename argument --- doc/xschem_man/create_pdf_man | 6 ++---- doc/xschem_man/developer_info.html | 23 +++++++++++++++++++---- src/actions.c | 6 +++--- src/scheduler.c | 26 ++++++++++++++++++++++++-- src/xschem.h | 2 +- src/xschem.tcl | 24 ++++++++++++++---------- 6 files changed, 63 insertions(+), 24 deletions(-) mode change 100644 => 100755 doc/xschem_man/create_pdf_man diff --git a/doc/xschem_man/create_pdf_man b/doc/xschem_man/create_pdf_man old mode 100644 new mode 100755 index 625e6f23..eb8c7b22 --- a/doc/xschem_man/create_pdf_man +++ b/doc/xschem_man/create_pdf_man @@ -30,7 +30,7 @@ generate_pdf () { sed -i '/href *= *"video_tutorials\//s/="/="https:\/\/xschem.sourceforge.io\/stefan\/xschem_man\//' $(basename $root_file) #### resize images since htmldoc does not fit images in pdf pages at all. - sed -i '// width="640">/' *.html + sed -i '/ abort_operation
    Resets UI state, unselect all and abort any pending operation 
  • add_symbol_pin
  • @@ -864,8 +863,15 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
        
  • net_pin_mismatch
  •     Highlight nets attached to selected symbols with
        a different name than symbol pin 
    -
  • netlist
  • -   do a netlist of current schematic in currently defined netlist format 
    +
  • netlist [filename]
  • +   do a netlist of current schematic in currently defined netlist format 
    +   if 'filename'is given use specified name for the netlist
    +   if 'filename' contains path components place the file in specified path location.
    +   if only a name is given and no path ('/') components are given use the
    +   default netlisting directory.
    +   This means that 'xschem netlist test.spice' and 'xschem netlist ./test.spice'
    +   will create the netlist in different places.
    +   netlisting directory is reset to previous setting after completing this command 
  • new_process [f]
  •     Start a new xschem process for a schematic.
        If 'f' is given load specified schematic. 
    @@ -1234,6 +1240,10 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" + + + + @@ -1667,7 +1677,6 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" schpins_to_sympins select_inst select_layers - select_netlist_dir set_bindings set_env set_graph_linewidth @@ -1677,6 +1686,12 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" # set 'var' with '$val' if 'var' not existing set_ne var val + # set_netlist_dir force [path] + # if path is given set as new netlist path where netlists and simulations are done. + # force should be always set to 1 unless you just want to query current path. + # select_netlist_dir 0 will return current path (you can get with $netlist_dir as well) + set_netlist_dir + set_old_tk_fonts # when XSCHEM_LIBRARY_PATH is changed this function is called diff --git a/src/actions.c b/src/actions.c index e485345e..12798dfa 100644 --- a/src/actions.c +++ b/src/actions.c @@ -274,11 +274,11 @@ void set_grid(double newgrid) tclsetdoublevar("cadgrid", cg); } -int set_netlist_dir(int force, char *dir) +int set_netlist_dir(int force, const char *dir) { char cmd[PATH_MAX+200]; - if(dir) my_snprintf(cmd, S(cmd), "select_netlist_dir %d {%s}", force, dir); - else my_snprintf(cmd, S(cmd), "select_netlist_dir %d", force); + if(dir) my_snprintf(cmd, S(cmd), "set_netlist_dir %d {%s}", force, dir); + else my_snprintf(cmd, S(cmd), "set_netlist_dir %d", force); tcleval(cmd); if(!strcmp("", tclresult()) ) { return 0; diff --git a/src/scheduler.c b/src/scheduler.c index 51e6af4c..1e872b2a 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -2208,12 +2208,30 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg hilight_net_pin_mismatches(); } - /* netlist - * do a netlist of current schematic in currently defined netlist format */ + /* netlist [filename] + * do a netlist of current schematic in currently defined netlist format + * if 'filename'is given use specified name for the netlist + * if 'filename' contains path components place the file in specified path location. + * if only a name is given and no path ('/') components are given use the + * default netlisting directory. + * This means that 'xschem netlist test.spice' and 'xschem netlist ./test.spice' + * will create the netlist in different places. + * netlisting directory is reset to previous setting after completing this command */ else if(!strcmp(argv[1], "netlist") ) { int err = 0; + char save[PATH_MAX]; + const char *path; yyparse_error = 0; + my_strncpy(save, tclgetvar("netlist_dir"), S(save)); + if(argc > 2) { + my_strncpy(xctx->netlist_name, get_cell_w_ext(argv[2], 0), S(xctx->netlist_name)); + tclvareval("file dirname ", argv[2], NULL); + path = tclresult(); + if(strchr(argv[2], '/')) { + set_netlist_dir(1, path); + } + } if(set_netlist_dir(0, NULL) ) { if(xctx->netlist_type == CAD_SPICE_NETLIST) err = global_spice_netlist(1); /* 1 means global netlist */ @@ -2226,6 +2244,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg else if(has_x) tcleval("tk_messageBox -type ok -parent [xschem get topwindow] " "-message {Please Set netlisting mode (Options menu)}"); + if(argc > 2) { + my_strncpy(xctx->netlist_name, "", S(xctx->netlist_name)); + set_netlist_dir(1, save); + } Tcl_SetResult(interp, my_itoa(err), TCL_VOLATILE); } } diff --git a/src/xschem.h b/src/xschem.h index f153aa85..9e55ae34 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -1181,7 +1181,7 @@ extern void dbg(int level, char *fmt, ...); extern unsigned int hash_file(const char *f, int skip_path_lines); extern void here(double i); extern void print_version(void); -extern int set_netlist_dir(int force, char *dir); +extern int set_netlist_dir(int force, const char *dir); extern void netlist_options(int i); extern int check_lib(int what, const char *s); extern void select_all(void); diff --git a/src/xschem.tcl b/src/xschem.tcl index cd778aa5..040a45b4 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -1446,7 +1446,7 @@ proc simulate {{callback {}}} { simuldir set_sim_defaults set netlist_type [xschem get netlist_type] - if { [select_netlist_dir 0] ne {}} { + if { [set_netlist_dir 0] ne {}} { set d ${netlist_dir} set tool $netlist_type set S [xschem get schname] @@ -1589,7 +1589,7 @@ proc waves {} { simuldir set netlist_type [xschem get netlist_type] set_sim_defaults - if { [select_netlist_dir 0] ne {}} { + if { [set_netlist_dir 0] ne {}} { set d ${netlist_dir} set tool ${netlist_type} set S [xschem get schname] @@ -2361,7 +2361,7 @@ proc edit_netlist {netlist } { set netlist_type [xschem get netlist_type] if { [regexp vim $editor] } { set ftype "-c \":set filetype=$netlist_type\"" } else { set ftype {} } - if { [select_netlist_dir 0] ne "" } { + if { [set_netlist_dir 0] ne "" } { if {$OS == "Windows"} { set cmd "$editor \"$netlist_dir/${netlist}\"" eval exec $cmd & @@ -3245,14 +3245,18 @@ proc simuldir {} { } # -# force==0: force creation of $netlist_dir (if not empty) -# if netlist_dir empty and no dir given prompt user -# else set netlist_dir to dir +# force==0: force creation of $netlist_dir (if netlist_dir variable not empty) +# and return current setting. +# if netlist_dir variable empty: +# if no dir given prompt user +# else set netlist_dir to dir # # force==1: if no dir given prompt user # else set netlist_dir to dir # -proc select_netlist_dir { force {dir {} }} { +# Return current netlist directory +# +proc set_netlist_dir { force {dir {} }} { global netlist_dir env OS if { ( $force == 0 ) && ( $netlist_dir ne {} ) } { @@ -6186,7 +6190,7 @@ proc build_widgets { {topwin {} } } { $topwin.menubar.simulation.menu add command -label "Set netlist Dir" \ -command { - select_netlist_dir 1 + set_netlist_dir 1 } $topwin.menubar.simulation.menu add command -label "Set top level netlist name" \ -command { @@ -6194,7 +6198,7 @@ proc build_widgets { {topwin {} } } { } $topwin.menubar.simulation.menu add checkbutton -label "Use 'simulation' dir under current schematic dir" \ -variable local_netlist_dir \ - -command { if {$local_netlist_dir == 0 } { select_netlist_dir 1 } else { simuldir} } + -command { if {$local_netlist_dir == 0 } { set_netlist_dir 1 } else { simuldir} } $topwin.menubar.simulation.menu add command -label {Configure simulators and tools} -command {simconf} $topwin.menubar.simulation.menu add command -label {Monitor current simulation} -command { view_current_sim_output @@ -6208,7 +6212,7 @@ proc build_widgets { {topwin {} } } { inutile_translate [xschem get current_dirname]/stimuli.[file rootname [file tail [xschem get schname]]] } $topwin.menubar.simulation.menu add command -label {Shell [simulation path]} -command { - if { [select_netlist_dir 0] ne "" } { + if { [set_netlist_dir 0] ne "" } { simuldir; get_shell $netlist_dir } }