more Xyce integration, transform .save in .print tran, transform x1.x2.node to X1:X2:NODE in Xyce lookups, more checks for malformed raw files
This commit is contained in:
parent
907315191d
commit
193cf397bd
53
src/save.c
53
src/save.c
|
|
@ -300,7 +300,7 @@ static int read_dataset(FILE *fd)
|
|||
int variables = 0, i, done_points = 0;
|
||||
char line[PATH_MAX], varname[PATH_MAX];
|
||||
char *ptr;
|
||||
int done_header = 0;
|
||||
int n = 0, done_header = 0;
|
||||
int exit_status = 0;
|
||||
xctx->graph_sim_type = 0;
|
||||
|
||||
|
|
@ -318,8 +318,8 @@ static int read_dataset(FILE *fd)
|
|||
int npoints = xctx->graph_npoints[xctx->graph_datasets];
|
||||
if(xctx->graph_sim_type) {
|
||||
done_header = 1;
|
||||
read_binary_block(fd);
|
||||
dbg(1, "read_dataset(): read binary block, nvars=%d npoints=%d\n", xctx->graph_nvars, npoints);
|
||||
read_binary_block(fd);
|
||||
xctx->graph_datasets++;
|
||||
exit_status = 1;
|
||||
} else {
|
||||
|
|
@ -356,7 +356,11 @@ static int read_dataset(FILE *fd)
|
|||
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));
|
||||
sscanf(line, "No. of Data Rows : %d", &xctx->graph_npoints[xctx->graph_datasets]);
|
||||
n = sscanf(line, "No. of Data Rows : %d", &xctx->graph_npoints[xctx->graph_datasets]);
|
||||
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;
|
||||
|
|
@ -365,13 +369,21 @@ static int read_dataset(FILE *fd)
|
|||
done_points = 1;
|
||||
}
|
||||
else if(!strncmp(line, "No. Variables:", 14)) {
|
||||
sscanf(line, "No. Variables: %d", &xctx->graph_nvars);
|
||||
n = sscanf(line, "No. Variables: %d", &xctx->graph_nvars);
|
||||
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 */
|
||||
|
||||
}
|
||||
else if(!done_points && !strncmp(line, "No. Points:", 11)) {
|
||||
my_realloc(1415, &xctx->graph_npoints, (xctx->graph_datasets+1) * sizeof(int));
|
||||
sscanf(line, "No. Points: %d", &xctx->graph_npoints[xctx->graph_datasets]);
|
||||
n = sscanf(line, "No. Points: %d", &xctx->graph_npoints[xctx->graph_datasets]);
|
||||
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;
|
||||
|
|
@ -380,7 +392,11 @@ static int read_dataset(FILE *fd)
|
|||
if(!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 *));
|
||||
sscanf(line, "%d %s", &i, varname); /* read index and name of saved waveform */
|
||||
n = sscanf(line, "%d %s", &i, varname); /* read index and name of saved waveform */
|
||||
if(n < 2) {
|
||||
dbg(0, "read_dataset(): WAARNING: malformed raw file, aborting\n");
|
||||
return 1;
|
||||
}
|
||||
if(xctx->graph_sim_type == 3) { /* 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);
|
||||
|
|
@ -522,23 +538,38 @@ int read_rawfile(const char *f)
|
|||
/* given a node XXyy try XXyy , xxyy, XXYY, v(XXyy), v(xxyy), V(XXYY) */
|
||||
int get_raw_index(const char *node)
|
||||
{
|
||||
int simtype;
|
||||
char inode[512];
|
||||
char vnode[512];
|
||||
char lnode[512];
|
||||
char unode[512];
|
||||
Int_hashentry *entry;
|
||||
dbg(1, "get_raw_index(): node=%s, node=%s\n", node, node);
|
||||
|
||||
|
||||
dbg(1, "get_raw_index(): node=%s\n", node);
|
||||
if(xctx->graph_values) {
|
||||
entry = int_hash_lookup(xctx->graph_raw_table, node, 0, XLOOKUP);
|
||||
tcleval("sim_is_xyce");
|
||||
simtype = atoi( tclresult() );
|
||||
my_strncpy(inode, node, S(lnode));
|
||||
|
||||
if(simtype) { /* Xyce */
|
||||
char *ptr = inode;
|
||||
while(*ptr) {
|
||||
if(*ptr == '.') *ptr = ':';
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
entry = int_hash_lookup(xctx->graph_raw_table, inode, 0, XLOOKUP);
|
||||
if(!entry) {
|
||||
my_strncpy(lnode, node, S(lnode));
|
||||
my_strncpy(lnode, inode, S(lnode));
|
||||
strtolower(lnode);
|
||||
entry = int_hash_lookup(xctx->graph_raw_table, lnode, 0, XLOOKUP);
|
||||
if(!entry) {
|
||||
my_strncpy(unode, node, S(lnode));
|
||||
my_strncpy(unode, inode, S(lnode));
|
||||
strtoupper(lnode);
|
||||
entry = int_hash_lookup(xctx->graph_raw_table, lnode, 0, XLOOKUP);
|
||||
if(!entry) {
|
||||
my_snprintf(vnode, S(vnode), "v(%s)", node);
|
||||
my_snprintf(vnode, S(vnode), "v(%s)", inode);
|
||||
entry = int_hash_lookup(xctx->graph_raw_table, vnode, 0, XLOOKUP);
|
||||
if(!entry) {
|
||||
my_strncpy(lnode, vnode, S(lnode));
|
||||
|
|
|
|||
|
|
@ -2771,7 +2771,6 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
cmd_found = 1;
|
||||
if( set_netlist_dir(0, NULL) ) {
|
||||
tcleval("simulate");
|
||||
Tcl_ResetResult(interp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -239,7 +239,12 @@ function process( i,j, iprefix, saveinstr, savetype, saveanalysis)
|
|||
if(tolower($1) ~ /^\.(save|print)$/ && $0 ~/\?[0-9]/) {
|
||||
$0 = tolower($0)
|
||||
saveinstr = $1
|
||||
if($2 ~/^(dc|ac|tran|op)$/) saveanalysis=$2
|
||||
|
||||
attr=""
|
||||
if($0 !~/format=/ && xyce==1) {
|
||||
attr=" format=raw "
|
||||
}
|
||||
if($2 ~/^(dc|ac|tran|op|sens|hb|es|pce|noise|homotopy)$/) saveanalysis=$2
|
||||
else saveanalysis=""
|
||||
$1=""
|
||||
if(saveanalysis !="") $2=""
|
||||
|
|
@ -254,7 +259,7 @@ function process( i,j, iprefix, saveinstr, savetype, saveanalysis)
|
|||
sub(/\).*/,"", $i)
|
||||
num = split($i, name, ",")
|
||||
for(j=1; j<= num; j++) {
|
||||
print saveinstr " " saveanalysis " " savetype "(" name[j] ")"
|
||||
print saveinstr " " saveanalysis attr savetype "(" name[j] ")"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -236,23 +236,23 @@ proc execute_fileevent {id} {
|
|||
set details [dict get $options -errorcode]
|
||||
if {[lindex $details 0] eq "CHILDSTATUS"} {
|
||||
set status [lindex $details 2]
|
||||
viewdata "Failed: $execute(cmd,$id)\nstderr:\n$err\ndata:\n$execute(data,$id)" ro
|
||||
viewdata "Failed: $execute(cmd,$id)\nstderr:\n$err\ndata:\n$execute(data,$id)"
|
||||
} else {
|
||||
set status 1
|
||||
if {$execute(status,$id) } {
|
||||
viewdata "Completed: $execute(cmd,$id)\nstderr:\n$err\ndata:\n$execute(data,$id)" ro
|
||||
viewdata "Completed: $execute(cmd,$id)\nstderr:\n$err\ndata:\n$execute(data,$id)"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
set status 1
|
||||
if {$execute(status,$id) } {
|
||||
viewdata "Completed: $execute(cmd,$id)\nstderr:\n$err\ndata:\n$execute(data,$id)" ro
|
||||
viewdata "Completed: $execute(cmd,$id)\nstderr:\n$err\ndata:\n$execute(data,$id)"
|
||||
}
|
||||
}
|
||||
}
|
||||
if {$status == 0} {
|
||||
if {$execute(status,$id) } {
|
||||
viewdata "Completed: $execute(cmd,$id)\ndata:\n$execute(data,$id)" ro
|
||||
viewdata "Completed: $execute(cmd,$id)\ndata:\n$execute(data,$id)"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -737,12 +737,12 @@ proc set_sim_defaults {{reset {}}} {
|
|||
set_ne sim(spice,1,fg) 0
|
||||
set_ne sim(spice,1,st) 1
|
||||
|
||||
set_ne sim(spice,2,cmd) {Xyce "$N" -r "$n.raw"}
|
||||
set_ne sim(spice,2,cmd) {Xyce "$N"}
|
||||
set sim(spice,2,name) {Xyce batch}
|
||||
set_ne sim(spice,2,fg) 0
|
||||
set_ne sim(spice,2,st) 1
|
||||
|
||||
set_ne sim(spice,3,cmd) {mpirun /path/to/parallel/Xyce "$N" -r "$n.raw"}
|
||||
set_ne sim(spice,3,cmd) {mpirun /path/to/parallel/Xyce "$N"}
|
||||
set sim(spice,3,name) {Xyce parallel batch}
|
||||
set_ne sim(spice,3,fg) 0
|
||||
set_ne sim(spice,3,st) 1
|
||||
|
|
@ -1188,7 +1188,7 @@ proc simulate {{callback {}}} {
|
|||
if { ![info exists sim($tool,default)] } {
|
||||
if { [info exists has_x] } {alert_ "Warning: simulator for $tool is not configured"}
|
||||
puts "Warning: simulator for $tool is not configured"
|
||||
return
|
||||
return -1
|
||||
}
|
||||
set def $sim($tool,default)
|
||||
set fg $sim($tool,$def,fg)
|
||||
|
|
@ -1206,11 +1206,17 @@ proc simulate {{callback {}}} {
|
|||
}
|
||||
#eval exec {cmd /V /C "cd $netlist_dir&&$cmd}
|
||||
eval exec $cmd &
|
||||
return -1 ;# no execute ID on windows
|
||||
} else {
|
||||
set execute(callback) $callback
|
||||
$fg $st sh -c "cd $netlist_dir; $cmd"
|
||||
set id [$fg $st sh -c "cd $netlist_dir; $cmd"]
|
||||
puts "Simulation started: execution ID: $id"
|
||||
return $id
|
||||
}
|
||||
} else {
|
||||
return -1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
proc gaw_echoline {} {
|
||||
|
|
@ -1993,40 +1999,20 @@ proc get_shell { curpath } {
|
|||
execute 0 sh -c "cd $curpath && $terminal"
|
||||
}
|
||||
|
||||
proc edit_netlist {schname } {
|
||||
proc edit_netlist {netlist } {
|
||||
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 {} }
|
||||
if { [select_netlist_dir 0] ne "" } {
|
||||
# puts "edit_netlist: \"$editor $ftype ${schname}.v\" \"$netlist_dir\" bg"
|
||||
if { $netlist_type=="verilog" } {
|
||||
execute 0 sh -c "cd $netlist_dir && $editor $ftype \"${tmpname}.v\""
|
||||
} elseif { $netlist_type=="spice" } {
|
||||
if {$OS == "Windows"} {
|
||||
set cmd "$editor \"$netlist_dir/${tmpname}.spice\""
|
||||
set cmd "$editor \"$netlist_dir/${netlist}\""
|
||||
eval exec $cmd &
|
||||
} else {
|
||||
execute 0 sh -c "cd $netlist_dir && $editor $ftype \"${tmpname}.spice\""
|
||||
}
|
||||
} elseif { $netlist_type=="tedax" } {
|
||||
if {$OS == "Windows"} {
|
||||
set cmd "$editor \"$netlist_dir/${tmpname}.tdx\""
|
||||
eval exec $cmd &
|
||||
} else {
|
||||
execute 0 sh -c "cd $netlist_dir && $editor $ftype \"${tmpname}.tdx\""
|
||||
}
|
||||
} elseif { $netlist_type=="vhdl" } {
|
||||
if {$OS == "Windows"} {
|
||||
set cmd "$editor \"$netlist_dir/${tmpname}.vhdl\""
|
||||
eval exec $cmd &
|
||||
} else {
|
||||
execute 0 sh -c "cd $netlist_dir && $editor $ftype \"${tmpname}.vhdl\""
|
||||
}
|
||||
execute 0 sh -c "cd $netlist_dir && $editor $ftype \"${netlist}\""
|
||||
}
|
||||
}
|
||||
return {}
|
||||
|
|
@ -5365,7 +5351,7 @@ proc build_widgets { {topwin {} } } {
|
|||
}
|
||||
}
|
||||
$topwin.menubar.simulation.menu add command -label {Edit Netlist} \
|
||||
-command {edit_netlist [file tail [xschem get schname]]}
|
||||
-command {edit_netlist [xschem get netlist_name fallback]}
|
||||
$topwin.menubar.simulation.menu add command -label {Send highlighted nets to viewer} \
|
||||
-command {xschem create_plot_cmd} -accelerator Shift+J
|
||||
$topwin.menubar.simulation.menu add checkbutton -label "Hide graphs if no spice data loaded" \
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue