diff --git a/src/actions.c b/src/actions.c index ac50a14d..48ac0b73 100644 --- a/src/actions.c +++ b/src/actions.c @@ -1599,7 +1599,11 @@ void go_back(int confirm) /* 20171006 add confirm */ my_strncpy(filename, xctx->sch[xctx->currsch], S(filename)); load_schematic(1, filename, 1, 1); - if(from_embedded_sym) xctx->modified=save_modified; /* to force ask save embedded sym in parent schematic */ + /* if we are returning from a symbol created from a generator don't set modified flag on parent + * as these symbols can not be edited / saved as embedded + * xctx->sch_inst_number[xctx->currsch + 1] == -1 --> we came from an inst with no embed flag set */ + if(from_embedded_sym && xctx->sch_inst_number[xctx->currsch + 1] != -1) + xctx->modified=save_modified; /* to force ask save embedded sym in parent schematic */ if(xctx->hilight_nets) { if(prev_sch_type != CAD_SYMBOL_ATTRS) hilight_parent_pins(); diff --git a/src/hilight.c b/src/hilight.c index 1f36aa02..48adb13c 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -473,6 +473,12 @@ void hilight_parent_pins(void) prepare_netlist_structs(0); i=xctx->previous_instance[xctx->currsch]; inst_number = xctx->sch_inst_number[xctx->currsch+1]; + + /* may be set to -1 by descend_symbol to notify we are + * descending into a smbol from an instance with no embed flag set + * this is used when descending into symbols created from generators */ + if(inst_number == -1) inst_number = 1; + dbg(1, "hilight_parent_pins(): previous_instance=%d\n", xctx->previous_instance[xctx->currsch]); dbg(1, "hilight_parent_pins(): inst_number=%d\n", inst_number); @@ -522,6 +528,12 @@ void hilight_child_pins(void) prepare_netlist_structs(0); rects = (xctx->inst[i].ptr+ xctx->sym)->rects[PINLAYER]; inst_number = xctx->sch_inst_number[xctx->currsch]; + + /* may be set to -1 by descend_symbol to notify we are + * descending into a smbol from an instance with no embed flag set + * this is used when descending into symbols created from generators */ + if(inst_number == -1) inst_number = 1; + for(j=0;jinst[n].ptr+ xctx->sym)->type,"missing")) return; } else return; + /* build up current hierarchy path */ my_strdup(_ALLOC_ID_, &str, xctx->inst[n].instname); my_strdup(_ALLOC_ID_, &xctx->sch_path[xctx->currsch+1], xctx->sch_path[xctx->currsch]); my_strcat(_ALLOC_ID_, &xctx->sch_path[xctx->currsch+1], str); my_strcat(_ALLOC_ID_, &xctx->sch_path[xctx->currsch+1], "."); xctx->sch_path_hash[xctx->currsch+1] = 0; + my_free(_ALLOC_ID_, &str); + /* store hierarchy of inst attributes and sym templates for hierarchic parameter substitution */ my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].prop_ptr, xctx->inst[n].prop_ptr); my_strdup(_ALLOC_ID_, &xctx->hier_attr[xctx->currsch].templ, get_tok_value((xctx->inst[n].ptr+ xctx->sym)->prop_ptr, "template", 0)); - xctx->sch_inst_number[xctx->currsch+1] = 1; - my_free(_ALLOC_ID_, &str); - xctx->previous_instance[xctx->currsch]=n; + + if(!xctx->inst[n].embed) + /* use -1 to keep track we are descending into symbol from instance with no embed attr + * we use this info to avoid asking to save parent schematic when returning from a symbol + * created from a generator */ + xctx->sch_inst_number[xctx->currsch+1] = -1; + else + xctx->sch_inst_number[xctx->currsch+1] = 1; /* inst number we descend into. For symbol always 1 */ + xctx->previous_instance[xctx->currsch]=n; /* instance we are descending from */ + + /* store previous zoom area */ xctx->zoom_array[xctx->currsch].x=xctx->xorigin; xctx->zoom_array[xctx->currsch].y=xctx->yorigin; xctx->zoom_array[xctx->currsch].zoom=xctx->zoom; - ++xctx->currsch; + + ++xctx->currsch; /* increment level counter */ + if((xctx->inst[n].ptr+ xctx->sym)->flags & EMBEDDED || xctx->inst[n].embed) { /* save embedded symbol into a temporary file */ my_snprintf(name_embedded, S(name_embedded), diff --git a/src/xschem.tcl b/src/xschem.tcl index de66ea60..83443f4c 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -2361,7 +2361,10 @@ proc is_xschem_file {f} { } else { fconfigure $fd -translation binary while { [gets $fd line] >=0 } { - if { $nline == 0 && [regexp {^#!} $line] } { break } ;# this is a script. not an xschem file + if { $nline == 0 && [regexp {^#!} $line] } { + set ret GENERATOR + break + } ;# this is a script. not an xschem file if { [regexp {^[TKGVSE] \{} $line] } { incr score } if { [regexp {^[BL] +[0-9]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +\{} $line] } {incr score} if { [regexp {^N +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +[-0-9.eE]+ +\{} $line] } {incr score} @@ -2372,7 +2375,7 @@ proc is_xschem_file {f} { incr nline } if { $score > 4 } { set ret 1} ;# Heuristic decision :-) - if { $ret } { + if { $ret ne {0} && $ret ne {GENERATOR}} { if { $instances} { set ret SCHEMATIC } else { @@ -2618,7 +2621,7 @@ proc myload_getresult {loadfile confirm_overwrt} { } } set type [is_xschem_file "$fname"] - if { $type eq {0} } { + if { $type eq {0} || $type eq {GENERATOR} } { set answer [ alert_ "$fname does not seem to be an xschem file...\nContinue?" {} 0 1] if { $answer eq {0}} { @@ -2627,7 +2630,7 @@ proc myload_getresult {loadfile confirm_overwrt} { } else { return "$fname" } - } elseif { $type ne {SYMBOL} && ($myload_ext eq {*.sym}) } { + } elseif { $type ne {SYMBOL} && ($myload_ext eq {*.sym}) } { ;# SCHEMATIC set answer [ alert_ "$fname does not seem to be a SYMBOL file...\nContinue?" {} 0 1] if { $answer eq {0}} { @@ -2636,7 +2639,7 @@ proc myload_getresult {loadfile confirm_overwrt} { } else { return "$fname" } - } else { + } else { ;# SYMBOL return "$fname" } } else { @@ -2646,7 +2649,7 @@ proc myload_getresult {loadfile confirm_overwrt} { proc myload_display_preview {f} { set type [is_xschem_file $f] - if { $type ne {0} } { + if { $type ne {0} && $type ne {GENERATOR} } { ### update if { [winfo exists .load] } { .load.l.paneright.draw configure -background {}