From c090773afe52f91c9fe8fb486280f77802f5a945 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Tue, 5 Dec 2023 13:13:59 +0100 Subject: [PATCH] Opening sub-schematic in new window/tab will inherit raw file loaded and annotation. ngspice::ngspice_data is preserved on context switches now --- doc/xschem_man/developer_info.html | 5 +++++ src/scheduler.c | 3 +++ src/xschem.tcl | 24 ++++++++++++++++++------ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/doc/xschem_man/developer_info.html b/doc/xschem_man/developer_info.html index d211b8b9..3a603e1f 100644 --- a/doc/xschem_man/developer_info.html +++ b/doc/xschem_man/developer_info.html @@ -533,6 +533,9 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" + + + @@ -1074,6 +1077,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" xschem raw_query loaded: return hierarchy level where raw file was loaded or -1 if no raw loaded xschem raw_query rawfile: return raw filename + xschem raw_query sim_type: return raw loaded simulation type (ac, op, tran, ...) xschem raw_query index node: get index of simulation variable 'node'. Example: raw_query index v(led) --> 46 xschem raw_query values node [dset] : print all simulation @@ -1445,6 +1449,7 @@ C {verilog_timescale.sym} 1050 -100 0 0 {name=s1 timestep="1ns" precision="1ns" + diff --git a/src/scheduler.c b/src/scheduler.c index 17f7393b..70a36cbb 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -3254,6 +3254,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg * xschem raw_query loaded: return hierarchy level * where raw file was loaded or -1 if no raw loaded * xschem raw_query rawfile: return raw filename + * xschem raw_query sim_type: return raw loaded simulation type (ac, op, tran, ...) * xschem raw_query index node: get index of simulation variable 'node'. * Example: raw_query index v(led) --> 46 * xschem raw_query values node [dset] : print all simulation @@ -3326,6 +3327,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg } } else if(argc > 2 && !strcmp(argv[2], "rawfile")) { Tcl_SetResult(interp, raw->rawfile, TCL_VOLATILE); + } else if(argc > 2 && !strcmp(argv[2], "sim_type")) { + Tcl_SetResult(interp, raw->sim_type, TCL_VOLATILE); } else if(argc > 2 && !strcmp(argv[2], "vars")) { Tcl_SetResult(interp, my_itoa(raw->nvars), TCL_VOLATILE); } else if(argc > 2 && !strcmp(argv[2], "list")) { diff --git a/src/xschem.tcl b/src/xschem.tcl index 5b18e9d1..64d481f9 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -2956,11 +2956,19 @@ proc open_sub_schematic {{inst {}} {inst_number 0}} { if {[lsearch -exact $instlist $inst] == -1} {return 0} } # open a new top level in another window / tab - set schname [xschem get_sch_from_sym $inst] + set rawfile [xschem raw_query rawfile] + set sim_type [xschem raw_query sim_type] set res [xschem schematic_in_new_window force] # if successfull descend into indicated sub-schematic if {$res} { xschem new_schematic switch [xschem get last_created_window] + if { $rawfile ne {}} { + if {$sim_type eq {op}} { + xschem annotate_op $rawfile + } else { + xschem raw_read $rawfile $sim_type + } + } xschem select instance $inst fast xschem descend return 1 @@ -6454,7 +6462,7 @@ set tctx::global_list { ## EXCEPTIONS, not to be saved/restored: ## execute set tctx::global_array_list { - replace_key dircolor sim enable_layer + replace_key dircolor sim enable_layer ngspice::ngspice_data } proc delete_ctx {context} { @@ -6465,7 +6473,8 @@ proc delete_ctx {context} { # puts "delete_ctx $tctx::tctx" array unset $tctx::tctx foreach tctx::i $tctx::global_array_list { - if { [array exists ${tctx::tctx}_$tctx::i] } { + regsub {::} $tctx::i {__} arr_name + if { [array exists ${tctx::tctx}_$arr_name] } { array unset ${tctx::tctx}_$tctx::i } } @@ -6491,8 +6500,10 @@ proc restore_ctx {context} { } } foreach tctx::i $tctx::global_array_list { - if { [array exists tctx::${tctx::tctx}_$tctx::i] } { - array set $tctx::i [array get [subst tctx::${tctx::tctx}_$tctx::i]] + unset -nocomplain $tctx::i + regsub {::} $tctx::i {__} arr_name + if { [array exists tctx::${tctx::tctx}_$arr_name] } { + array set $tctx::i [array get [subst tctx::${tctx::tctx}_$arr_name]] } } } @@ -6519,7 +6530,8 @@ proc save_ctx {context} { } foreach tctx::i $tctx::global_array_list { if { [array exists $tctx::i] } { - array set [subst tctx::${tctx::tctx}_$tctx::i] [array get $tctx::i] + regsub {::} $tctx::i {__} arr_name + array set [subst tctx::${tctx::tctx}_$arr_name] [array get $tctx::i] } } }