From a83768273186dd73ef50a2b40704b48e7efb0ce6 Mon Sep 17 00:00:00 2001 From: Stefan Frederik Date: Sat, 19 Dec 2020 03:22:38 +0100 Subject: [PATCH] caching "lab" and "highlight" attributes for speed --- src/actions.c | 51 ++++----------- src/callback.c | 2 +- src/draw.c | 6 +- src/editprop.c | 21 +++--- src/hilight.c | 146 +++++++++++++----------------------------- src/in_memory_undo.c | 7 +- src/move.c | 3 +- src/netlist.c | 11 +--- src/paste.c | 56 ++-------------- src/psprint.c | 4 +- src/save.c | 28 +++++--- src/scheduler.c | 17 ++++- src/select.c | 1 + src/spice_netlist.c | 8 +-- src/svgdraw.c | 4 +- src/tedax_netlist.c | 4 +- src/token.c | 4 +- src/verilog_netlist.c | 16 ++--- src/vhdl_netlist.c | 12 ++-- src/xschem.h | 16 +++-- 20 files changed, 154 insertions(+), 263 deletions(-) diff --git a/src/actions.c b/src/actions.c index cfbe1891..32966324 100644 --- a/src/actions.c +++ b/src/actions.c @@ -531,6 +531,7 @@ void clear_drawing(void) my_free(693, &xctx->inst[i].prop_ptr); my_free(694, &xctx->inst[i].name); my_free(695, &xctx->inst[i].instname); + my_free(874, &xctx->inst[i].lab); delete_inst_node(i); } xctx->instances = 0; @@ -838,6 +839,7 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, short rot xctx->inst[n].ptr = i; xctx->inst[n].name=NULL; xctx->inst[n].instname=NULL; + xctx->inst[n].lab=NULL; dbg(1, "place_symbol(): entering my_strdup: name=%s\n",name); /* 03-02-2000 */ my_strdup(12, &xctx->inst[n].name ,name); dbg(1, "place_symbol(): done my_strdup: name=%s\n",name); /* 03-02-2000 */ @@ -864,11 +866,11 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, short rot dbg(1, "place_symbol(): done set_inst_prop()\n"); /* 03-02-2000 */ my_strdup2(13, &xctx->inst[n].instname, get_tok_value(xctx->inst[n].prop_ptr,"name",0) ); - + if(!strcmp(get_tok_value(xctx->inst[n].prop_ptr,"highlight",0), "true")) xctx->inst[n].flags |= 4; type = xctx->sym[xctx->inst[n].ptr].type; cond= !type || !IS_LABEL_SH_OR_PIN(type); if(cond) xctx->inst[n].flags|=2; - else xctx->inst[n].flags &=~2; + else my_strdup(145, &xctx->inst[n].lab, get_tok_value(xctx->inst[n].prop_ptr,"lab",0)); if(first_call && (draw_sym & 3) ) bbox(START, 0.0 , 0.0 , 0.0 , 0.0); @@ -996,10 +998,7 @@ void descend_schematic(int instnumber) const char *str; char filename[PATH_MAX]; int inst_mult, inst_number; - int i, save_ok = 0; - int hilight_connected_inst; - char *type; - struct hilight_hashentry *entry; + int save_ok = 0; rebuild_selected_array(); @@ -1106,36 +1105,7 @@ void descend_schematic(int instnumber) if(xctx->hilight_nets) { prepare_netlist_structs(0); - - - for(i = 0; i < xctx->instances; i++) { - type = (xctx->inst[i].ptr+ xctx->sym)->type; - hilight_connected_inst = - !strcmp(get_tok_value(xctx->inst[i].prop_ptr, "highlight", 0), "true") || - !strcmp(get_tok_value((xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "highlight", 0), "true"); - if(hilight_connected_inst && type && !IS_LABEL_SH_OR_PIN(type)) { - int rects, j; - if( (rects = (xctx->inst[i].ptr+ xctx->sym)->rects[PINLAYER]) > 0 ) { - dbg(2, "draw_hilight_net(): hilight_connected_inst inst=%d, node=%s\n", i, xctx->inst[i].node[0]); - for(j=0;jinst[i].node && xctx->inst[i].node[j]) { - entry=bus_hilight_lookup(xctx->inst[i].node[j], 0, XLOOKUP); - if(entry) { - xctx->inst[i].flags |= 4; - xctx->inst[i].color=get_color(entry->value); - break; - } - } - } - } - } else if( type && IS_LABEL_SH_OR_PIN(type) ) { - entry=bus_hilight_lookup( get_tok_value(xctx->inst[i].prop_ptr,"lab",0) , 0, XLOOKUP); - if(entry) xctx->inst[i].color=get_color(entry->value); - } - } - - - + propagate_hilights(1); if(enable_drill) drill_hilight(); } dbg(1, "descend_schematic(): before zoom(): prep_hash_inst=%d\n", xctx->prep_hash_inst); @@ -1184,7 +1154,10 @@ void go_back(int confirm) /* 20171006 add confirm */ load_schematic(1, filename, 1); if(from_embedded_sym) xctx->modified=save_modified; /* to force ask save embedded sym in parent schematic */ - hilight_parent_pins(); + if(xctx->hilight_nets) { + hilight_parent_pins(); + propagate_hilights(1); + } if(enable_drill) drill_hilight(); xctx->xorigin=xctx->zoom_array[xctx->currsch].x; xctx->yorigin=xctx->zoom_array[xctx->currsch].y; @@ -1353,10 +1326,10 @@ void calc_drawing_bbox(xRect *boundbox, int selected) } } else if( type && IS_LABEL_OR_PIN(type)) { - entry=bus_hilight_lookup( get_tok_value(xctx->inst[i].prop_ptr,"lab",0) , 0, XLOOKUP ); + entry=bus_hilight_lookup(xctx->inst[i].lab, 0, XLOOKUP ); if(entry) found = 1; } - else if( (xctx->inst[i].flags & 4) ) { + else if( (xctx->inst[i].color) ) { found = 1; } if(!found) continue; diff --git a/src/callback.c b/src/callback.c index 19ea052c..e752aec1 100644 --- a/src/callback.c +++ b/src/callback.c @@ -1054,7 +1054,7 @@ int callback(int event, int mx, int my, KeySym key, { int mult; remove_symbol(2); - link_symbols_to_instances(); + link_symbols_to_instances(0); expandlabel("/RST", &mult); expandlabel("/CCC[3:0]", &mult); expandlabel("CCC[AA:BB:DD]", &mult); diff --git a/src/draw.c b/src/draw.c index 8ba95257..b6083d1a 100644 --- a/src/draw.c +++ b/src/draw.c @@ -584,11 +584,11 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1); textlayer = c; - if( !(c == PINLAYER && (xctx->inst[n].flags & 4))) { + if( !(c == PINLAYER && (xctx->inst[n].color))) { textlayer = symptr->text[j].layer; if(textlayer < 0 || textlayer >= cadlayers) textlayer = c; } - if((c == PINLAYER && xctx->inst[n].flags & 4) || enable_layer[textlayer]) { + if((c == PINLAYER && xctx->inst[n].color) || enable_layer[textlayer]) { #if HAS_CAIRO==1 textfont = symptr->text[j].font; if((textfont && textfont[0]) || symptr->text[j].flags) { @@ -1663,7 +1663,7 @@ void draw(void) bus_hilight_lookup(xctx->inst[i].node[0], 0, XLOOKUP ) ) || ( - !IS_LABEL_SH_OR_PIN(type) && (xctx->inst[i].flags & 4) + !IS_LABEL_SH_OR_PIN(type) && (xctx->inst[i].color) ) ) ) diff --git a/src/editprop.c b/src/editprop.c index 8f1c9a99..6fc954f2 100644 --- a/src/editprop.c +++ b/src/editprop.c @@ -378,10 +378,10 @@ char *strtoupper(char* s) { void set_inst_prop(int i) { - char *ptr = NULL; + char *ptr; char *tmp = NULL; - my_strdup(104, &ptr, (xctx->inst[i].ptr+ xctx->sym)->templ); + ptr = (xctx->inst[i].ptr+ xctx->sym)->templ; dbg(1, "set_inst_prop(): i=%d, name=%s, prop_ptr = %s, template=%s\n", i, xctx->inst[i].name, xctx->inst[i].prop_ptr, ptr); my_strdup(69, &xctx->inst[i].prop_ptr, ptr); @@ -391,7 +391,6 @@ void set_inst_prop(int i) new_prop_string(i, tmp, 0, dis_uniq_names); my_free(724, &tmp); } - my_free(330, &ptr); } void edit_rect_property(void) @@ -962,7 +961,7 @@ void update_symbol(const char *result, int x) may be out of sync wrt disk version */ if(copy_cell) { remove_symbols(); - link_symbols_to_instances(); + link_symbols_to_instances(0); } /* symbol reference changed? --> sym_number >=0, set prefix to 1st char to use for inst name (from symbol template) */ @@ -1033,17 +1032,19 @@ void update_symbol(const char *result, int x) dbg(1, "update_symbol(): name=%s, inst[i].prop_ptr=%s\n", name, xctx->inst[i].prop_ptr); my_strdup(89, &ptr,subst_token(xctx->inst[i].prop_ptr, "name", name) ); /* set name of current inst */ - if(!pushed) { push_undo(); pushed=1;} if(!k) hash_all_names(i); new_prop_string(i, ptr, k, dis_uniq_names); /* set new prop_ptr */ - - type=xctx->sym[xctx->inst[i].ptr].type; - cond= !type || !IS_LABEL_SH_OR_PIN(type); - if(cond) xctx->inst[i].flags|=2; /* bit 1: flag for different textlayer for pin/labels */ - else xctx->inst[i].flags &=~2; } my_strdup2(90, &xctx->inst[i].instname, get_tok_value(xctx->inst[i].prop_ptr, "name",0)); + + type=xctx->sym[xctx->inst[i].ptr].type; + cond= !type || !IS_LABEL_SH_OR_PIN(type); + if(cond) xctx->inst[i].flags |= 2; /* bit 1: flag for different textlayer for pin/labels */ + else { + xctx->inst[i].flags &= ~2; + my_strdup(880, &xctx->inst[i].lab, get_tok_value(xctx->inst[i].prop_ptr, "lab",0)); + } } /* end for(k=0;klastsel;k++) */ /* new symbol bbox after prop changes (may change due to text length) */ if(xctx->modified) { diff --git a/src/hilight.c b/src/hilight.c index 11163ef1..b6d0d1ca 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -291,7 +291,6 @@ void delete_hilight_net(void) xctx->hilight_nets=0; for(i=0;iinstances;i++) { - xctx->inst[i].flags &= ~4 ; xctx->inst[i].color = 0 ; } dbg(1, "delete_hilight_net(): clearing\n"); @@ -343,11 +342,9 @@ void hilight_net_pin_mismatches(void) void hilight_parent_pins(void) { - int hilight_connected_inst; int rects, i, j, k; struct hilight_hashentry *entry; const char *pin_name; - char *type; char *pin_node = NULL; char *net_node=NULL; int mult, net_mult, inst_number; @@ -387,31 +384,6 @@ void hilight_parent_pins(void) } } } - for(i = 0; i < xctx->instances; i++) { - type = (xctx->inst[i].ptr+ xctx->sym)->type; - hilight_connected_inst = - !strcmp(get_tok_value(xctx->inst[i].prop_ptr, "highlight", 0), "true") || - !strcmp(get_tok_value((xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "highlight", 0), "true"); - if(hilight_connected_inst && type && !IS_LABEL_SH_OR_PIN(type)) { - int rects, j; - if( (rects = (xctx->inst[i].ptr+ xctx->sym)->rects[PINLAYER]) > 0 ) { - dbg(2, "draw_hilight_net(): hilight_connected_inst inst=%d, node=%s\n", i, xctx->inst[i].node[0]); - for(j=0;jinst[i].node && xctx->inst[i].node[j]) { - entry=bus_hilight_lookup(xctx->inst[i].node[j], 0, XLOOKUP); - if(entry) { - xctx->inst[i].flags |= 4; - xctx->inst[i].color=get_color(entry->value); - break; - } - } - } - } - } else if( type && IS_LABEL_SH_OR_PIN(type) ) { - entry=bus_hilight_lookup( get_tok_value(xctx->inst[i].prop_ptr,"lab",0) , 0, XLOOKUP); - if(entry) xctx->inst[i].color=get_color(entry->value); - } - } my_free(767, &pin_node); my_free(768, &net_node); } @@ -552,7 +524,6 @@ int search(const char *tok, const char *val, int sub, int sel, int what) else { dbg(1, "search(): setting hilight flag on inst %d\n",i); xctx->hilight_nets=1; - xctx->inst[i].flags |= 4; xctx->inst[i].color = hilight_layer; if(what==NOW) for(c=0;cinstances; i++) { + type = (xctx->inst[i].ptr+ xctx->sym)->type; + hilight_connected_inst = (xctx->inst[i].flags & 4) || ((xctx->inst[i].ptr+ xctx->sym)->flags & 4); + if(hilight_connected_inst && type && !IS_LABEL_SH_OR_PIN(type)) { + int rects, j, clear; + if( (rects = (xctx->inst[i].ptr+ xctx->sym)->rects[PINLAYER]) > 0 ) { + dbg(2, "draw_hilight_net(): hilight_connected_inst inst=%d, node=%s\n", i, xctx->inst[i].node[0]); + clear = 1; + for(j=0;jinst[i].node && xctx->inst[i].node[j]) { + entry=bus_hilight_lookup(xctx->inst[i].node[j], 0, XLOOKUP); + if(entry) { + if(set) { + xctx->inst[i].color=get_color(entry->value); + } else { + clear = 0; + } + break; + } + } + } + if(clear && !set) { + xctx->inst[i].color=0; + } + } + } else if( type && IS_LABEL_SH_OR_PIN(type) ) { + entry=bus_hilight_lookup( xctx->inst[i].lab, 0, XLOOKUP); + if(entry && set) xctx->inst[i].color = get_color(entry->value); + else if(!entry && !set) xctx->inst[i].color = 0; + } + } +} void hilight_net(int to_waveform) { int i, n; char *type; int sim_is_xyce; - int hilight_connected_inst; - struct hilight_hashentry *entry; prepare_netlist_structs(0); dbg(1, "hilight_net(): entering\n"); @@ -865,7 +872,6 @@ void hilight_net(int to_waveform) } else { dbg(1, "hilight_net(): setting hilight flag on inst %d\n",n); xctx->hilight_nets=1; - xctx->inst[n].flags |= 4; xctx->inst[n].color = get_color(xctx->hilight_color); if(incr_hilight) xctx->hilight_color++; } @@ -877,33 +883,7 @@ void hilight_net(int to_waveform) break; } } - - for(i = 0; i < xctx->instances; i++) { - type = (xctx->inst[i].ptr+ xctx->sym)->type; - hilight_connected_inst = - !strcmp(get_tok_value(xctx->inst[i].prop_ptr, "highlight", 0), "true") || - !strcmp(get_tok_value((xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "highlight", 0), "true"); - if(hilight_connected_inst && type && !IS_LABEL_SH_OR_PIN(type)) { - int rects, j; - if( (rects = (xctx->inst[i].ptr+ xctx->sym)->rects[PINLAYER]) > 0 ) { - dbg(2, "draw_hilight_net(): hilight_connected_inst inst=%d, node=%s\n", i, xctx->inst[i].node[0]); - for(j=0;jinst[i].node && xctx->inst[i].node[j]) { - entry=bus_hilight_lookup(xctx->inst[i].node[j], 0, XLOOKUP); - if(entry) { - xctx->inst[i].flags |= 4; - xctx->inst[i].color=get_color(entry->value); - break; - } - } - } - } - } else if( type && IS_LABEL_SH_OR_PIN(type) ) { - entry=bus_hilight_lookup( get_tok_value(xctx->inst[i].prop_ptr,"lab",0) , 0, XLOOKUP); - if(entry) xctx->inst[i].color=get_color(entry->value); - } - } - + propagate_hilights(1); if(!incr_hilight) xctx->hilight_color++; if(enable_drill) { drill_hilight(); @@ -914,10 +894,8 @@ void hilight_net(int to_waveform) void unhilight_net(void) { - int i,n, clear; + int i,n; char *type; - int hilight_connected_inst; - struct hilight_hashentry *entry; prepare_netlist_structs(0); dbg(1, "unhilight_net(): entering\n"); @@ -939,45 +917,13 @@ void unhilight_net(void) bus_hilight_lookup(xctx->inst[n].node[0], xctx->hilight_color, XDELETE); } else { } - xctx->inst[n].flags &= ~4; xctx->inst[n].color = 0; break; default: break; } } - - - for(i = 0; i < xctx->instances; i++) { - type = (xctx->inst[i].ptr+ xctx->sym)->type; - hilight_connected_inst = - !strcmp(get_tok_value(xctx->inst[i].prop_ptr, "highlight", 0), "true") || - !strcmp(get_tok_value((xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "highlight", 0), "true"); - if(hilight_connected_inst && type && !IS_LABEL_SH_OR_PIN(type)) { - int rects, j; - if( (rects = (xctx->inst[i].ptr+ xctx->sym)->rects[PINLAYER]) > 0 ) { - dbg(2, "draw_hilight_net(): hilight_connected_inst inst=%d, node=%s\n", i, xctx->inst[i].node[0]); - for(j=0;jinst[i].node && xctx->inst[i].node[j]) { - entry=bus_hilight_lookup(xctx->inst[i].node[j], 0, XLOOKUP); - if(entry) { - clear = 0; - break; - } - } - } - if(clear) { - xctx->inst[i].flags &= ~4; - xctx->inst[i].color=0; - } - } - } else if( type && IS_LABEL_SH_OR_PIN(type) ) { - entry=bus_hilight_lookup( get_tok_value(xctx->inst[i].prop_ptr,"lab",0) , 0, XLOOKUP); - if(!entry) xctx->inst[i].color=0; - } - } - + propagate_hilights(0); unselect_all(); } @@ -1014,10 +960,8 @@ void select_hilight_net(void) for(i=0;iinstances;i++) { type = (xctx->inst[i].ptr+ xctx->sym)->type; - hilight_connected_inst = - !strcmp(get_tok_value((xctx->inst[i].ptr+ xctx->sym)->prop_ptr, "highlight", 0), "true") || - !strcmp(get_tok_value(xctx->inst[i].prop_ptr, "highlight", 0), "true"); - if( xctx->inst[i].flags & 4) { + hilight_connected_inst = (xctx->inst[i].flags & 4) || ((xctx->inst[i].ptr+ xctx->sym)->flags & 4); + if( xctx->inst[i].color) { dbg(1, "select_hilight_net(): instance %d flags &4 true\n", i); xctx->inst[i].sel = SELECTED; } @@ -1036,8 +980,8 @@ void select_hilight_net(void) } } } else if( type && IS_LABEL_SH_OR_PIN(type) ) { - entry=bus_hilight_lookup( get_tok_value(xctx->inst[i].prop_ptr,"lab",0) , 0, XLOOKUP); - if(entry) xctx->inst[i].sel = SELECTED; + entry=bus_hilight_lookup(xctx->inst[i].lab , 0, XLOOKUP); + if(entry) xctx->inst[i].sel = SELECTED; } } xctx->need_reb_sel_arr = 1; diff --git a/src/in_memory_undo.c b/src/in_memory_undo.c index c7e8a079..fd506d71 100644 --- a/src/in_memory_undo.c +++ b/src/in_memory_undo.c @@ -152,6 +152,7 @@ void free_instances(int slot) my_free(800, &uslot[slot].iptr[i].name); my_free(801, &uslot[slot].iptr[i].prop_ptr); my_free(802, &uslot[slot].iptr[i].instname); + my_free(104, &uslot[slot].iptr[i].lab); } my_free(803, &uslot[slot].iptr); uslot[slot].instances = 0; @@ -278,7 +279,9 @@ void push_undo(void) uslot[slot].iptr[i].prop_ptr = NULL; uslot[slot].iptr[i].name = NULL; uslot[slot].iptr[i].instname = NULL; + uslot[slot].iptr[i].lab = NULL; uslot[slot].iptr[i].node = NULL; + my_strdup(330, &uslot[slot].iptr[i].lab, xctx->inst[i].lab); my_strdup2(191, &uslot[slot].iptr[i].instname, xctx->inst[i].instname); my_strdup(192, &uslot[slot].iptr[i].prop_ptr, xctx->inst[i].prop_ptr); my_strdup(193, &uslot[slot].iptr[i].name, xctx->inst[i].name); @@ -393,9 +396,11 @@ void pop_undo(int redo) xctx->inst[i].prop_ptr=NULL; xctx->inst[i].name=NULL; xctx->inst[i].instname=NULL; + xctx->inst[i].lab=NULL; my_strdup(214, &xctx->inst[i].prop_ptr, uslot[slot].iptr[i].prop_ptr); my_strdup(215, &xctx->inst[i].name, uslot[slot].iptr[i].name); my_strdup2(216, &xctx->inst[i].instname, uslot[slot].iptr[i].instname); + my_strdup(766, &xctx->inst[i].lab, uslot[slot].iptr[i].lab); } /* texts */ @@ -421,7 +426,7 @@ void pop_undo(int redo) my_strdup(222, &xctx->wire[i].prop_ptr, uslot[slot].wptr[i].prop_ptr); } - link_symbols_to_instances(); + link_symbols_to_instances(0); set_modify(1); xctx->prep_hash_inst=0; xctx->prep_hash_wires=0; diff --git a/src/move.c b/src/move.c index 61945bb1..08aa0c7b 100644 --- a/src/move.c +++ b/src/move.c @@ -892,14 +892,15 @@ void copy_objects(int what) xctx->inst[xctx->instances] = xctx->inst[n]; xctx->inst[xctx->instances].prop_ptr=NULL; xctx->inst[xctx->instances].instname=NULL; + xctx->inst[xctx->instances].lab=NULL; xctx->inst[xctx->instances].node=NULL; xctx->inst[xctx->instances].name=NULL; my_strdup(232, &xctx->inst[xctx->instances].name, xctx->inst[n].name); my_strdup(233, &xctx->inst[xctx->instances].prop_ptr, xctx->inst[n].prop_ptr); my_strdup2(234, &xctx->inst[xctx->instances].instname, get_tok_value(xctx->inst[n].prop_ptr, "name",0)); + my_strdup(312, &xctx->inst[xctx->instances].lab, xctx->inst[n].lab); xctx->inst[n].sel=0; xctx->inst[xctx->instances].flags = xctx->inst[n].flags; - xctx->inst[xctx->instances].flags &= ~4; /* do not propagate hilight */ xctx->inst[xctx->instances].color = 0; xctx->inst[xctx->instances].x0 = xctx->rx1+xctx->deltax; xctx->inst[xctx->instances].y0 = xctx->ry1+xctx->deltay; diff --git a/src/netlist.c b/src/netlist.c index 8df4d29c..c414c1d6 100644 --- a/src/netlist.c +++ b/src/netlist.c @@ -276,7 +276,6 @@ void hash_inst_pin(int what, int i, int j) xctx->inst[i].name, j, prop_ptr); statusmsg(str,2); if(!netlist_count) { - xctx->inst[i].flags |=4; xctx->inst[i].color = PINLAYER; xctx->hilight_nets=1; } @@ -699,7 +698,6 @@ void prepare_netlist_structs(int for_netlist) strcmp(type, "use")) { my_snprintf(str, S(str), "instance: %d (%s): no name attribute set", i, inst[i].name); statusmsg(str,2); - inst[i].flags |=4; inst[i].color = PINLAYER; xctx->hilight_nets=1; } @@ -708,7 +706,6 @@ void prepare_netlist_structs(int for_netlist) char str[2048]; my_snprintf(str, S(str), "Symbol: %s: no type attribute set", inst[i].name); statusmsg(str,2); - inst[i].flags |=4; inst[i].color = PINLAYER; xctx->hilight_nets=1; } @@ -755,7 +752,7 @@ void prepare_netlist_structs(int for_netlist) my_strdup(261, &class,get_tok_value(inst[i].prop_ptr,"class",0)); } - my_strdup(262, &inst[i].node[0], get_tok_value(inst[i].prop_ptr,"lab",0)); + my_strdup(262, &inst[i].node[0], inst[i].lab); if (!(inst[i].node[0])) { my_strdup(65, &inst[i].node[0], get_tok_value((inst[i].ptr+ xctx->sym)->templ, "lab",0)); @@ -771,8 +768,6 @@ void prepare_netlist_structs(int for_netlist) bus_hash_lookup(inst[i].node[0], /* insert node in hash table */ dir, XINSERT, port, sig_type, verilog_type, value, class); - dbg(2, "prepare_netlist_structs(): name=%s\n", - get_tok_value( inst[i].prop_ptr, "lab",0)); dbg(2, "prepare_netlist_structs(): pin=%s\n", get_tok_value( (inst[i].ptr+ xctx->sym)->rect[PINLAYER][0].prop_ptr, "name",0)); dbg(2, "prepare_netlist_structs(): dir=%s\n", @@ -1187,7 +1182,6 @@ int sym_vs_sch_pins() statusmsg(str,2); for(j = 0; j < xctx->instances; j++) { if(!strcmp(xctx->inst[j].name, xctx->sym[i].name)) { - xctx->inst[j].flags |=4; xctx->inst[i].color = PINLAYER; xctx->hilight_nets=1; } @@ -1204,7 +1198,6 @@ int sym_vs_sch_pins() statusmsg(str,2); for(j = 0; j < xctx->instances; j++) { if(!strcmp(xctx->inst[j].name, xctx->sym[i].name)) { - xctx->inst[j].flags |=4; xctx->inst[i].color = PINLAYER; xctx->hilight_nets=1; } @@ -1238,7 +1231,6 @@ int sym_vs_sch_pins() statusmsg(str,2); for(j = 0; j < xctx->instances; j++) { if(!strcmp(xctx->inst[j].name, xctx->sym[i].name)) { - xctx->inst[j].flags |=4; xctx->inst[i].color = PINLAYER; xctx->hilight_nets=1; } @@ -1262,7 +1254,6 @@ int sym_vs_sch_pins() statusmsg(str,2); for(k = 0; k < xctx->instances; k++) { if(!strcmp(xctx->inst[k].name, xctx->sym[i].name)) { - xctx->inst[k].flags |=4; xctx->inst[i].color = PINLAYER; xctx->hilight_nets=1; } diff --git a/src/paste.c b/src/paste.c index 7ab2cb1a..80147bcd 100644 --- a/src/paste.c +++ b/src/paste.c @@ -213,9 +213,11 @@ void merge_inst(int k,FILE *fd) } ptr[i].sel=0; ptr[i].flags=0; + ptr[i].color=0; ptr[i].ptr=-1; ptr[i].prop_ptr=NULL; ptr[i].instname=NULL; + ptr[i].lab=NULL; /* assigned in link_symbols_to_instances */ ptr[i].node=NULL; load_ascii_string(&prop_ptr,fd); if(!k) hash_all_names(i); @@ -223,61 +225,13 @@ void merge_inst(int k,FILE *fd) /* the final tmp argument is zero for the 1st call and used in */ /* new_prop_string() for cleaning some internal caches. */ my_strdup2(306, &xctx->inst[i].instname, get_tok_value(xctx->inst[i].prop_ptr, "name", 0)); + if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"highlight",0), "true")) xctx->inst[i].flags |= 4; + my_free(871, &prop_ptr); xctx->instances++; set_modify(1); } - - - - -void match_merged_inst(int old) -{ - int i,missing,symbol; - int cond; - char *type; - missing = 0; - for(i=old;iinstances;i++) - { - symbol = match_symbol(xctx->inst[i].name); - if(symbol == -1) - { - dbg(1, "match_merged_inst(): missing symbol, skipping...\n"); - my_free(872, &xctx->inst[i].prop_ptr); /* 06052001 remove properties */ - my_free(873, &xctx->inst[i].name); /* 06052001 remove symname */ - my_free(874, &xctx->inst[i].instname); - missing++; - continue; - } - xctx->inst[i].ptr = symbol; - if(missing) - { - - xctx->inst[i-missing] = xctx->inst[i]; - xctx->inst[i].prop_ptr=NULL; - /* delete_inst_node(i); */ /* probably not needed */ - xctx->inst[i].ptr=-1; /*04112003 was 0 */ - xctx->inst[i].flags=0; - xctx->inst[i].color=0; - xctx->inst[i].name=NULL; - xctx->inst[i].instname=NULL; - } - } - xctx->instances -= missing; - for(i=old;iinstances;i++) - { - if(xctx->inst[i].ptr<0) continue; - select_element(i,SELECTED,1, 0); - symbol_bbox(i, &xctx->inst[i].x1, &xctx->inst[i].y1, - &xctx->inst[i].x2, &xctx->inst[i].y2); - type=xctx->sym[xctx->inst[i].ptr].type; - cond= !type || !IS_LABEL_SH_OR_PIN(type); - if(cond) xctx->inst[i].flags|=2; - else xctx->inst[i].flags &=~2; - } -} - /* merge selection if selection_load=1, otherwise ask for filename */ /* selection_load: */ /* 0: ask filename to merge */ @@ -391,7 +345,7 @@ void merge_file(int selection_load, const char ext[]) xctx->mousey_snap = 0.; } my_free(875, &aux_ptr); - match_merged_inst(old); + link_symbols_to_instances(old); fclose(fd); xctx->ui_state |= STARTMERGE; dbg(1, "merge_file(): loaded file:wire=%d inst=%d ui_state=%ld\n", diff --git a/src/psprint.c b/src/psprint.c index 71b51a29..e7fae6c3 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -511,7 +511,7 @@ static void ps_draw_symbol(int n,int layer, short tmp_flip, short rot, double xo txtptr= translate(n, text.txt_ptr); ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1); textlayer = layer; - if( !(layer == PINLAYER && (xctx->inst[n].flags & 4))) { + if( !(layer == PINLAYER && (xctx->inst[n].color))) { textlayer = (xctx->inst[n].ptr+ xctx->sym)->text[j].layer; if(textlayer < 0 || textlayer >= cadlayers) textlayer = layer; } @@ -530,7 +530,7 @@ static void ps_draw_symbol(int n,int layer, short tmp_flip, short rot, double xo if( symptr->text[j].flags & TEXT_OBLIQUE) my_snprintf(ps_font_family, S(ps_font_family), "%s-Oblique", ps_font_name); - if((layer == PINLAYER && xctx->inst[n].flags & 4) || enable_layer[textlayer]) { + if((layer == PINLAYER && xctx->inst[n].color) || enable_layer[textlayer]) { if(text_ps) { ps_draw_string(textlayer, txtptr, (text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3, diff --git a/src/save.c b/src/save.c index ef134e6d..a267abd7 100644 --- a/src/save.c +++ b/src/save.c @@ -557,10 +557,13 @@ static void load_inst(int k, FILE *fd) xctx->inst[i].ptr=-1; /*04112003 was 0 */ xctx->inst[i].prop_ptr=NULL; xctx->inst[i].instname=NULL; + xctx->inst[i].lab=NULL; /* assigned in link_symbols_to_instances */ xctx->inst[i].node=NULL; load_ascii_string(&prop_ptr,fd); my_strdup(319, &xctx->inst[i].prop_ptr, prop_ptr); my_strdup2(320, &xctx->inst[i].instname, get_tok_value(xctx->inst[i].prop_ptr, "name", 0)); + if(!strcmp(get_tok_value(xctx->inst[i].prop_ptr,"highlight",0), "true")) xctx->inst[i].flags |= 4; + dbg(2, "load_inst(): n=%d name=%s prop=%s\n", i, xctx->inst[i].name? xctx->inst[i].name:"", xctx->inst[i].prop_ptr? xctx->inst[i].prop_ptr:""); xctx->instances++; @@ -949,29 +952,31 @@ int save_schematic(const char *schname) /* 20171020 added return value */ return 0; } -void link_symbols_to_instances(void) /* 20150326 separated from load_schematic() */ +void link_symbols_to_instances(int from) { int i; - char *type=NULL; /* 20150407 added static */ + char *type=NULL; int cond; - for(i=0;iinstances;i++) + for(i = from; i < xctx->instances; i++) { dbg(2, "link_symbols_to_instances(): inst=%d\n", i); dbg(2, "link_symbols_to_instances(): matching inst %d name=%s \n",i, xctx->inst[i].name); dbg(2, "link_symbols_to_instances(): -------\n"); xctx->inst[i].ptr = match_symbol(xctx->inst[i].name); } - for(i=0;iinstances;i++) { - symbol_bbox(i, &xctx->inst[i].x1, &xctx->inst[i].y1, - &xctx->inst[i].x2, &xctx->inst[i].y2); + for(i = from; i < xctx->instances; i++) { + symbol_bbox(i, &xctx->inst[i].x1, &xctx->inst[i].y1, &xctx->inst[i].x2, &xctx->inst[i].y2); type=xctx->sym[xctx->inst[i].ptr].type; cond= !type || !IS_LABEL_SH_OR_PIN(type); if(cond) xctx->inst[i].flags|=2; /* ordinary symbol */ - else xctx->inst[i].flags &=~2; /* label or pin */ + else { + xctx->inst[i].flags &=~2; /* label or pin */ + my_strdup(1216, &xctx->inst[i].lab, get_tok_value(xctx->inst[i].prop_ptr,"lab",0)); + } } - } + /* ALWAYS use absolute pathname for filename!!! */ void load_schematic(int load_symbols, const char *filename, int reset_undo) /* 20150327 added reset_undo */ { @@ -1011,7 +1016,7 @@ void load_schematic(int load_symbols, const char *filename, int reset_undo) /* 2 fclose(fd); /* 20150326 moved before load symbols */ set_modify(0); dbg(2, "load_schematic(): loaded file:wire=%d inst=%d\n",xctx->wires , xctx->instances); - if(load_symbols) link_symbols_to_instances(); + if(load_symbols) link_symbols_to_instances(0); if(reset_undo) { Tcl_VarEval(interp, "is_xschem_file ", xctx->sch[xctx->currsch], NULL); if(!strcmp(tclresult(), "SYMBOL")) { @@ -1230,7 +1235,7 @@ void pop_undo(int redo) fclose(fd); #endif dbg(2, "pop_undo(): loaded file:wire=%d inst=%d\n",xctx->wires , xctx->instances); - link_symbols_to_instances(); + link_symbols_to_instances(0); set_modify(1); xctx->prep_hash_inst=0; xctx->prep_hash_wires=0; @@ -1634,6 +1639,8 @@ int load_sym_def(const char *name, FILE *embed_fd) get_tok_value(symbol[symbols].prop_ptr, "template", 0)); my_strdup2(515, &symbol[symbols].type, get_tok_value(symbol[symbols].prop_ptr, "type",0)); + if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"highlight",0), "true")) symbol[symbols].flags |= 4; + } else { load_ascii_string(&aux_ptr, lcc[level].fd); @@ -1647,6 +1654,7 @@ int load_sym_def(const char *name, FILE *embed_fd) get_tok_value(symbol[symbols].prop_ptr, "template", 0)); my_strdup2(342, &symbol[symbols].type, get_tok_value(symbol[symbols].prop_ptr, "type",0)); + if(!strcmp(get_tok_value(symbol[symbols].prop_ptr,"highlight",0), "true")) symbol[symbols].flags |= 4; } else { load_ascii_string(&aux_ptr, lcc[level].fd); diff --git a/src/scheduler.c b/src/scheduler.c index 4a3838d9..9da478ff 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1819,7 +1819,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg type=xctx->sym[xctx->inst[inst].ptr].type; cond= !type || !IS_LABEL_SH_OR_PIN(type); if(cond) xctx->inst[inst].flags|=2; - else xctx->inst[inst].flags &=~2; + else { + xctx->inst[inst].flags &=~2; + my_strdup(1215, &xctx->inst[inst].lab, get_tok_value(xctx->inst[inst].prop_ptr, "lab", 0)); + } my_free(922, &ptr); } my_free(923, &name); @@ -2237,6 +2240,8 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg Tcl_SetResult(interp, "xschem setprop: instance not found", TCL_STATIC); return TCL_ERROR; } else { + char *type; + int cond; if(!fast) { bbox(START,0.0,0.0,0.0,0.0); symbol_bbox(inst, &xctx->inst[inst].x1, &xctx->inst[inst].y1, &xctx->inst[inst].x2, &xctx->inst[inst].y2); @@ -2254,7 +2259,15 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg new_prop_string(inst, subst_token(xctx->inst[inst].prop_ptr, argv[3], NULL),fast, dis_uniq_names); } my_strdup2(367, &xctx->inst[inst].instname, get_tok_value(xctx->inst[inst].prop_ptr, "name",0)); - + + type=xctx->sym[xctx->inst[inst].ptr].type; + cond= !type || !IS_LABEL_SH_OR_PIN(type); + if(cond) xctx->inst[inst].flags|=2; + else { + xctx->inst[inst].flags &=~2; + my_strdup(1215, &xctx->inst[inst].lab, get_tok_value(xctx->inst[inst].prop_ptr, "lab", 0)); + } + if(!fast) { /* new symbol bbox after prop changes (may change due to text length) */ symbol_bbox(inst, &xctx->inst[inst].x1, &xctx->inst[inst].y1, &xctx->inst[inst].x2, &xctx->inst[inst].y2); diff --git a/src/select.c b/src/select.c index 3f115aeb..6264275e 100644 --- a/src/select.c +++ b/src/select.c @@ -311,6 +311,7 @@ void delete(void) delete_inst_node(i); my_free(939, &xctx->inst[i].name); my_free(940, &xctx->inst[i].instname); + my_free(878, &xctx->inst[i].lab); j++; continue; } diff --git a/src/spice_netlist.c b/src/spice_netlist.c index 27400761..0f7794e2 100644 --- a/src/spice_netlist.c +++ b/src/spice_netlist.c @@ -100,9 +100,7 @@ void global_spice_netlist(int global) /* netlister driver */ continue; } if( type && IS_PIN(type)) { - str_tmp = expandlabel ( get_tok_value(xctx->inst[i].prop_ptr,"lab",0) ,&multip); - dbg(1, "global_spice_netlist(): |%s|\n", - get_tok_value(xctx->inst[i].prop_ptr,"lab",0)); + str_tmp = expandlabel ( (xctx->inst[i].lab ? xctx->inst[i].lab : ""), &multip); /*must handle invalid node names */ fprintf(fd, " %s", str_tmp ? str_tmp : "(NULL)" ); } @@ -158,7 +156,7 @@ void global_spice_netlist(int global) /* netlister driver */ /* preserve current level instance flags before descending hierarchy for netlisting, restore later */ stored_flags = my_calloc(146, xctx->instances, sizeof(unsigned int)); - for(i=0;iinstances;i++) stored_flags[i] = xctx->inst[i].flags & 4; + for(i=0;iinstances;i++) stored_flags[i] = xctx->inst[i].color; if(global) { @@ -205,7 +203,7 @@ void global_spice_netlist(int global) /* netlister driver */ /* symbol vs schematic pin check, we do it here since now we have ALL symbols loaded */ sym_vs_sch_pins(); /* restore hilight flags from errors found analyzing top level before descending hierarchy */ - for(i=0;iinstances; i++) xctx->inst[i].flags |= stored_flags[i]; + for(i=0;iinstances; i++) xctx->inst[i].color = stored_flags[i]; draw_hilight_net(1); } my_free(945, &stored_flags); diff --git a/src/svgdraw.c b/src/svgdraw.c index 684051e7..aff7203b 100644 --- a/src/svgdraw.c +++ b/src/svgdraw.c @@ -495,7 +495,7 @@ static void svg_draw_symbol(int n,int layer,short tmp_flip, short rot, txtptr= translate(n, text.txt_ptr); ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1); textlayer = layer; - if( !(layer == PINLAYER && (xctx->inst[n].flags & 4))) { + if( !(layer == PINLAYER && (xctx->inst[n].color))) { textlayer = (xctx->inst[n].ptr+ xctx->sym)->text[j].layer; if(textlayer < 0 || textlayer >= cadlayers) textlayer = layer; } @@ -516,7 +516,7 @@ static void svg_draw_symbol(int n,int layer,short tmp_flip, short rot, if( symptr->text[j].flags & TEXT_OBLIQUE) my_snprintf(svg_font_style, S(svg_font_style), "oblique"); - if((layer == PINLAYER && xctx->inst[n].flags & 4) || enable_layer[textlayer]) { + if((layer == PINLAYER && xctx->inst[n].color) || enable_layer[textlayer]) { if(text_svg) svg_draw_string(textlayer, txtptr, (text.rot + ( (flip && (text.rot & 1) ) ? rot+2 : rot) ) & 0x3, diff --git a/src/tedax_netlist.c b/src/tedax_netlist.c index a8a64f5c..d1092843 100644 --- a/src/tedax_netlist.c +++ b/src/tedax_netlist.c @@ -83,7 +83,7 @@ void global_tedax_netlist(int global) /* netlister driver */ /* preserve current level instance flags before descending hierarchy for netlisting, restore later */ stored_flags = my_calloc(149, xctx->instances, sizeof(unsigned int)); - for(i=0;iinstances;i++) stored_flags[i] = xctx->inst[i].flags & 4; + for(i=0;iinstances;i++) stored_flags[i] = xctx->inst[i].color; if(global) /* was if(global) ... 20180901 no hierarchical tEDAx netlist for now */ { @@ -117,7 +117,7 @@ void global_tedax_netlist(int global) /* netlister driver */ sym_vs_sch_pins(); /* restore hilight flags from errors found analyzing top level before descending hierarchy */ - for(i=0;iinstances; i++) xctx->inst[i].flags |= stored_flags[i]; + for(i=0;iinstances; i++) xctx->inst[i].color = stored_flags[i]; draw_hilight_net(1); } my_free(965, &stored_flags); diff --git a/src/token.c b/src/token.c index 0a74796a..6b0daee4 100644 --- a/src/token.c +++ b/src/token.c @@ -210,7 +210,6 @@ void check_unique_names(int rename) if(comma_pos) *comma_pos = '\0'; dbg(1, "check_unique_names(): checking %s\n", start); if( (entry = inst_hash_lookup(table, start, i, XINSERT_NOREPLACE, strlen(start)) ) && entry->value != i) { - xctx->inst[i].flags |=4; xctx->inst[i].color = PINLAYER; xctx->hilight_nets=1; if(rename == 1) { @@ -230,7 +229,7 @@ void check_unique_names(int rename) comma_pos++; } } /* for(j...) */ - if( (xctx->inst[i].flags & 4) && rename) { + if( xctx->inst[i].color && rename) { my_strdup(511, &tmp, xctx->inst[i].prop_ptr); new_prop_string(i, tmp, newpropcnt++, !rename); my_strdup2(512, &xctx->inst[i].instname, get_tok_value(xctx->inst[i].prop_ptr, "name", 0)); @@ -2327,7 +2326,6 @@ const char *net_name(int i, int j, int *multip, int hash_prefix_unnamed_net, int i, j, xctx->inst[i].instname ) ; statusmsg(errstr,2); if(!netlist_count) { - xctx->inst[i].flags |=4; xctx->inst[i].color = PINLAYER; xctx->hilight_nets=1; } diff --git a/src/verilog_netlist.c b/src/verilog_netlist.c index a33c752e..e167183b 100644 --- a/src/verilog_netlist.c +++ b/src/verilog_netlist.c @@ -112,7 +112,7 @@ void global_verilog_netlist(int global) /* netlister driver */ { if(tmp) fprintf(fd, " ,\n"); tmp++; - str_tmp = get_tok_value(xctx->inst[i].prop_ptr,"lab",0); + str_tmp = xctx->inst[i].lab ? xctx->inst[i].lab : ""; fprintf(fd, " %s", str_tmp ? str_tmp : "(NULL)"); } } @@ -130,7 +130,7 @@ void global_verilog_netlist(int global) /* netlister driver */ { if(tmp) fprintf(fd, " ,\n"); tmp++; - str_tmp = get_tok_value(xctx->inst[i].prop_ptr,"lab",0); + str_tmp = xctx->inst[i].lab ? xctx->inst[i].lab : ""; fprintf(fd, " %s", str_tmp ? str_tmp : "(NULL)"); } } @@ -148,7 +148,7 @@ void global_verilog_netlist(int global) /* netlister driver */ { if(tmp) fprintf(fd, " ,\n"); tmp++; - str_tmp = get_tok_value(xctx->inst[i].prop_ptr,"lab",0); + str_tmp = xctx->inst[i].lab ? xctx->inst[i].lab : ""; fprintf(fd, " %s", str_tmp ? str_tmp : ""); } } @@ -181,7 +181,7 @@ void global_verilog_netlist(int global) /* netlister driver */ my_strdup(550, &port_value,get_tok_value(xctx->inst[i].prop_ptr,"value",0)); my_strdup(551, &sig_type,get_tok_value(xctx->inst[i].prop_ptr,"verilog_type",0)); if(!sig_type || sig_type[0]=='\0') my_strdup(552, &sig_type,"wire"); /* 20070720 changed reg to wire */ - str_tmp = get_tok_value(xctx->inst[i].prop_ptr,"lab",0); + str_tmp = xctx->inst[i].lab ? xctx->inst[i].lab : ""; fprintf(fd, " output %s ;\n", str_tmp ? str_tmp : "(NULL)"); fprintf(fd, " %s %s ", sig_type, str_tmp ? str_tmp : "(NULL)"); @@ -204,7 +204,7 @@ void global_verilog_netlist(int global) /* netlister driver */ my_strdup(554, &port_value,get_tok_value(xctx->inst[i].prop_ptr,"value",0)); my_strdup(555, &sig_type,get_tok_value(xctx->inst[i].prop_ptr,"verilog_type",0)); if(!sig_type || sig_type[0]=='\0') my_strdup(556, &sig_type,"wire"); - str_tmp = get_tok_value(xctx->inst[i].prop_ptr,"lab",0); + str_tmp = xctx->inst[i].lab ? xctx->inst[i].lab : ""; fprintf(fd, " inout %s ;\n", str_tmp ? str_tmp : "(NULL)"); fprintf(fd, " %s %s ", sig_type, str_tmp ? str_tmp : "(NULL)"); @@ -227,7 +227,7 @@ void global_verilog_netlist(int global) /* netlister driver */ my_strdup(558, &port_value,get_tok_value(xctx->inst[i].prop_ptr,"value",0)); my_strdup(559, &sig_type,get_tok_value(xctx->inst[i].prop_ptr,"verilog_type",0)); if(!sig_type || sig_type[0]=='\0') my_strdup(560, &sig_type,"wire"); - str_tmp = get_tok_value(xctx->inst[i].prop_ptr,"lab",0); + str_tmp = xctx->inst[i].lab ? xctx->inst[i].lab : ""; fprintf(fd, " input %s ;\n", str_tmp ? str_tmp : ""); fprintf(fd, " %s %s ", sig_type, str_tmp ? str_tmp : ""); @@ -271,7 +271,7 @@ void global_verilog_netlist(int global) /* netlister driver */ /* preserve current level instance flags before descending hierarchy for netlisting, restore later */ stored_flags = my_calloc(150, xctx->instances, sizeof(unsigned int)); - for(i=0;iinstances;i++) stored_flags[i] = xctx->inst[i].flags & 4; + for(i=0;iinstances;i++) stored_flags[i] = xctx->inst[i].color; if(global) { @@ -318,7 +318,7 @@ void global_verilog_netlist(int global) /* netlister driver */ sym_vs_sch_pins(); /* restore hilight flags from errors found analyzing top level before descending hierarchy */ - for(i=0;iinstances; i++) xctx->inst[i].flags |= stored_flags[i]; + for(i=0;iinstances; i++) xctx->inst[i].color = stored_flags[i]; draw_hilight_net(1); } diff --git a/src/vhdl_netlist.c b/src/vhdl_netlist.c index 76c7b1f6..325413f0 100644 --- a/src/vhdl_netlist.c +++ b/src/vhdl_netlist.c @@ -140,7 +140,7 @@ void global_vhdl_netlist(int global) /* netlister driver */ /* if( type && (strcmp(type,"generic"))==0) */ /* { */ /* my_strdup(576, &port_value,get_tok_value(xctx->inst[i].prop_ptr,"value", 0)); */ - /* str_tmp = get_tok_value(xctx->inst[i].prop_ptr,"lab",0); */ + /* str_tmp = xctx->inst[i].lab ? xctx->inst[i].lab : ""; */ /* if(!tmp) fprintf(fd,"generic (\n"); */ /* if(tmp) fprintf(fd," ;\n"); */ /* fprintf(fd, " %s : %s", str_tmp ? str_tmp : "(NULL)", sig_type ); */ @@ -169,7 +169,7 @@ void global_vhdl_netlist(int global) /* netlister driver */ my_strdup(579, &type,(xctx->inst[i].ptr+ xctx->sym)->type); if( type && (strcmp(type,"opin"))==0) { - str_tmp = get_tok_value(xctx->inst[i].prop_ptr,"lab",0); + str_tmp = xctx->inst[i].lab ? xctx->inst[i].lab : ""; if(!tmp) fprintf(fd,"port(\n"); if(tmp) fprintf(fd," ;\n"); fprintf(fd, " %s : out %s", str_tmp ? str_tmp : "(NULL)", sig_type ); @@ -190,7 +190,7 @@ void global_vhdl_netlist(int global) /* netlister driver */ my_strdup(582, &type,(xctx->inst[i].ptr+ xctx->sym)->type); if( type && (strcmp(type,"iopin"))==0) { - str_tmp = get_tok_value(xctx->inst[i].prop_ptr,"lab",0); + str_tmp = xctx->inst[i].lab ? xctx->inst[i].lab : ""; if(!tmp) fprintf(fd,"port(\n"); if(tmp) fprintf(fd," ;\n"); fprintf(fd, " %s : inout %s", str_tmp ? str_tmp : "(NULL)", sig_type ); @@ -211,7 +211,7 @@ void global_vhdl_netlist(int global) /* netlister driver */ my_strdup(585, &type,(xctx->inst[i].ptr+ xctx->sym)->type); if( type && (strcmp(type,"ipin"))==0) { - str_tmp = get_tok_value(xctx->inst[i].prop_ptr,"lab",0); + str_tmp = xctx->inst[i].lab ? xctx->inst[i].lab : ""; if(!tmp) fprintf(fd,"port(\n"); if(tmp) fprintf(fd," ;\n"); fprintf(fd, " %s : in %s", str_tmp ? str_tmp : "", sig_type ); @@ -324,7 +324,7 @@ void global_vhdl_netlist(int global) /* netlister driver */ /* preserve current level instance flags before descending hierarchy for netlisting, restore later */ stored_flags = my_calloc(151, xctx->instances, sizeof(unsigned int)); - for(i=0;iinstances;i++) stored_flags[i] = xctx->inst[i].flags & 4; + for(i=0;iinstances;i++) stored_flags[i] = xctx->inst[i].color; if(global) { @@ -371,7 +371,7 @@ void global_vhdl_netlist(int global) /* netlister driver */ sym_vs_sch_pins(); /* restore hilight flags from errors found analyzing top level before descending hierarchy */ - for(i=0;iinstances; i++) xctx->inst[i].flags |= stored_flags[i]; + for(i=0;iinstances; i++) xctx->inst[i].color = stored_flags[i]; draw_hilight_net(1); } diff --git a/src/xschem.h b/src/xschem.h index b01bab92..cdf70c5f 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -436,7 +436,9 @@ typedef struct char *prop_ptr; char *type; char *templ; - short flags; /* currently only used for embedded symbols (EMBEDDED) */ + short flags; /* bit 0: embedded flag + * bit 1: **free** + * bit 2: highight if connected wire highlighted */ } xSymbol; typedef struct @@ -456,12 +458,13 @@ typedef struct short rot; short flip; short sel; - short color; - short flags; /* bit 0: skip field, bit 1: flag for different textlayer for pin/labels - * bit 2 : hilight flag. - */ + short color; /* hilight color */ + short flags; /* bit 0: skip field, + * bit 1: flag for different textlayer for pin/labels , 1: ordinary symbol, 0: label/pin/show + * bit 2: highlight if connected net/label is highlighted */ char *prop_ptr; char **node; + char *lab; /* lab attribute if any (pin/label) */ char *instname; /* 20150409 instance name (example: I23) */ } xInstance; @@ -965,7 +968,7 @@ extern void pop_undo(int redo); extern void delete_undo(void); extern void clear_undo(void); extern void load_schematic(int load_symbol, const char *abs_name, int reset_undo); -extern void link_symbols_to_instances(void); +extern void link_symbols_to_instances(int from); extern void load_ascii_string(char **ptr, FILE *fd); extern void read_xschem_file(FILE *fd); extern char *read_line(FILE *fp, int dbg_level); @@ -1097,6 +1100,7 @@ extern void print_verilog_param(FILE *fd, int symbol); extern void hilight_net(int to_waveform); extern int hilight_netname(const char *name); extern void unhilight_net(); +extern void propagate_hilights(int set); extern void draw_hilight_net(int on_window); extern void display_hilights(char **str); extern void redraw_hilights(void);