xschem netlist command accepts an optional filename argument

This commit is contained in:
stefan schippers 2023-07-03 09:06:46 +02:00
parent 9f23965096
commit cdecc6ad04
6 changed files with 63 additions and 24 deletions

6
doc/xschem_man/create_pdf_man Normal file → Executable file
View File

@ -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 '/<img/s/>/ width="640">/' *.html
sed -i '/<img/s/<img /<img width="640" /' *.html
#### generate pdf from list of html files.
htmldoc --top 10mm --bottom 10mm --right 10mm --left 10mm --webpage --linkcolor blue \
@ -40,7 +40,5 @@ generate_pdf () {
rm -rf $tmpdir
}
#### generate pdf doc for github/repo.hi xschem version, with autoconfiguration (./configure && make)
#### generate pdf doc
generate_pdf /home/schippes/xschem-repo/trunk/doc/xschem_man/xschem_man.html xschem_man.pdf
#### generate pdf doc for sourceforge xschem version, with NO autoconfiguration (edit Makefile and make)
generate_pdf xschem_man.html xschem_man_sourceforge.pdf

View File

@ -494,7 +494,6 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> abort_operation</kbd></li><pre>
Resets UI state, unselect all and abort any pending operation </pre>
<li><kbd> add_symbol_pin</kbd></li><pre>
@ -864,8 +863,15 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
<li><kbd> net_pin_mismatch</kbd></li><pre>
Highlight nets attached to selected symbols with
a different name than symbol pin </pre>
<li><kbd> netlist</kbd></li><pre>
do a netlist of current schematic in currently defined netlist format </pre>
<li><kbd> netlist [filename]</kbd></li><pre>
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 </pre>
<li><kbd> new_process [f]</kbd></li><pre>
Start a new xschem process for a schematic.
If 'f' is given load specified schematic. </pre>
@ -1234,6 +1240,10 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns"
</ul>
<!-- TCL global variables -->
@ -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

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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
}
}