From 40fd937d51add79710b04122122e5536555bde24 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Wed, 29 Jan 2025 16:22:44 +0100 Subject: [PATCH] shorted_instance(): fixed a bug: lvs_ignore active disallows evaluation of spice_ignore flags; ps_draw_symbol(): draw in grey or red ignored or shorted devices --- src/actions.c | 2 +- src/draw.c | 59 ++----------- src/netlist.c | 3 +- src/psprint.c | 238 +++++++++++++++++++++++++++++++++----------------- 4 files changed, 169 insertions(+), 133 deletions(-) diff --git a/src/actions.c b/src/actions.c index 5601e43b..7bcc6d42 100644 --- a/src/actions.c +++ b/src/actions.c @@ -898,7 +898,7 @@ int set_text_flags(xText *t) t->flags = 0; t->hcenter = 0; t->vcenter = 0; - t->layer = -1; + t->layer = -1; /* -1 means default TEXTLAYER is to be used */ if(t->prop_ptr) { my_strdup(_ALLOC_ID_, &t->font, get_tok_value(t->prop_ptr, "font", 0)); str = get_tok_value(t->prop_ptr, "hcenter", 0); diff --git a/src/draw.c b/src/draw.c index 731f9c25..b6c5fe6e 100644 --- a/src/draw.c +++ b/src/draw.c @@ -490,63 +490,23 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, xPoly *polygon; xText text; register xSymbol *symptr; - double angle; char *type; int lvs_ignore = 0; #if HAS_CAIRO==1 const char *textfont; #endif + type = xctx->sym[xctx->inst[n].ptr].type; lvs_ignore=tclgetboolvar("lvs_ignore"); + if(!has_x) return; if(xctx->inst[n].ptr == -1) return; if(layer == 0) { - char *type = xctx->sym[xctx->inst[n].ptr].type; - xctx->inst[n].flags &= ~IGNORE_INST; /* clear bit */ if( type && strcmp(type, "launcher") && strcmp(type, "logo") && strcmp(type, "probe") && strcmp(type, "architecture") && strcmp(type, "noconn")) { - if( - ( - xctx->netlist_type == CAD_SPICE_NETLIST && - ( - (xctx->inst[n].flags & SPICE_IGNORE) || - (xctx->sym[xctx->inst[n].ptr].flags & SPICE_IGNORE) - ) - ) || - - ( - xctx->netlist_type == CAD_VERILOG_NETLIST && - ( - (xctx->inst[n].flags & VERILOG_IGNORE) || - (xctx->sym[xctx->inst[n].ptr].flags & VERILOG_IGNORE) - ) - ) || - - ( - xctx->netlist_type == CAD_VHDL_NETLIST && - ( - (xctx->inst[n].flags & VHDL_IGNORE) || - (xctx->sym[xctx->inst[n].ptr].flags & VHDL_IGNORE) - ) - ) || - - ( - xctx->netlist_type == CAD_TEDAX_NETLIST && - ( - (xctx->inst[n].flags & TEDAX_IGNORE) || - (xctx->sym[xctx->inst[n].ptr].flags & TEDAX_IGNORE) - ) - ) || - ( - lvs_ignore && - ( - (xctx->inst[n].flags & LVS_IGNORE_OPEN) || - (xctx->sym[xctx->inst[n].ptr].flags & LVS_IGNORE_OPEN) - ) - ) - ) { - xctx->inst[n].flags |= IGNORE_INST; /* *_IGNORE_INST in current netlisting mode as evaluated above */ + if(skip_instance(n, 1, lvs_ignore)) { + xctx->inst[n].flags |= IGNORE_INST; } } } @@ -560,8 +520,6 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, what = NOW; disabled = 1; } - - if(!has_x) return; if( (xctx->inst[n].flags & HIDE_INST) || (xctx->hide_symbols==1 && (xctx->inst[n].ptr+ xctx->sym)->prop_ptr && !strcmp( (xctx->inst[n].ptr+ xctx->sym)->type, "subcircuit") ) || @@ -570,7 +528,6 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, } else { hide = 0; } - type = (xctx->inst[n].ptr+ xctx->sym)->type; if(layer==0) { x1=X_TO_SCREEN(xctx->inst[n].x1+xoffset); /* 20150729 added xoffset, yoffset */ x2=X_TO_SCREEN(xctx->inst[n].x2+xoffset); @@ -611,7 +568,6 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, dbg(2, "draw_symbol(): skipping inst %d\n", n); return; } - flip = xctx->inst[n].flip; if(tmp_flip) flip = !flip; rot = (xctx->inst[n].rot + rot ) & 0x3; @@ -657,6 +613,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, for(j=0;j< symptr->arcs[layer]; ++j) { int dash; + double angle; arc = &(symptr->arc[layer])[j]; dash = (disabled == 1) ? 3 : arc->dash; if(flip) { @@ -671,7 +628,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, } } /* if(!hide) */ - if( (!hide && xctx->enable_layer[layer]) || + if( (!hide && xctx->enable_layer[layer]) || (hide && layer == PINLAYER && xctx->enable_layer[layer]) ) { for(j=0;j< symptr->rects[layer]; ++j) { @@ -714,7 +671,7 @@ void draw_symbol(int what,int c, int n,int layer,short tmp_flip, short rot, ellipse_a, ellipse_b); } } - } + } /* if( (!hide && xctx->enable_layer[layer]) || ... */ draw_texts: @@ -814,7 +771,6 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,short tmp_flip, short rot xArc *arc; xText text; register xSymbol *symptr; - double angle; #if HAS_CAIRO==1 int customfont; @@ -919,6 +875,7 @@ void draw_temp_symbol(int what, GC gc, int n,int layer,short tmp_flip, short rot } for(j=0;j< symptr->arcs[layer]; ++j) { + double angle; arc = &(symptr->arc[layer])[j]; if(flip) { angle = 270.*rot+180.-arc->b-arc->a; diff --git a/src/netlist.c b/src/netlist.c index c39947e5..49500d2a 100644 --- a/src/netlist.c +++ b/src/netlist.c @@ -1040,7 +1040,8 @@ int shorted_instance(int i, int lvs_ignore) if(inst[i].ptr < 0) shorted = 0; else if(lvs_ignore) { if((inst[i].flags & LVS_IGNORE_SHORT) || (sym[inst[i].ptr].flags & LVS_IGNORE_SHORT) ) shorted = 1; - } else if(xctx->netlist_type == CAD_SPICE_NETLIST) { + } + if(xctx->netlist_type == CAD_SPICE_NETLIST) { if((inst[i].flags & SPICE_SHORT) || (sym[inst[i].ptr].flags & SPICE_SHORT) ) shorted = 1; } else if(xctx->netlist_type == CAD_VERILOG_NETLIST) { if((inst[i].flags & VERILOG_SHORT) || (sym[inst[i].ptr].flags & VERILOG_SHORT) ) shorted = 1; diff --git a/src/psprint.c b/src/psprint.c index 07daae01..e488fee3 100644 --- a/src/psprint.c +++ b/src/psprint.c @@ -859,27 +859,54 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho double xoffset, double yoffset) /* draws current layer only, should be called within */ { /* a "for(i=0;isym[xctx->inst[n].ptr].type; + lvs_ignore=tclgetboolvar("lvs_ignore"); if(xctx->inst[n].ptr == -1) return; - if( (layer != PINLAYER && !xctx->enable_layer[layer]) ) return; - if( (xctx->hide_symbols==1 && (xctx->inst[n].ptr+ xctx->sym)->prop_ptr && - !strcmp( (xctx->inst[n].ptr+ xctx->sym)->type, "subcircuit") ) || (xctx->hide_symbols == 2) ) { + if(layer == 0) { + xctx->inst[n].flags &= ~IGNORE_INST; /* clear bit */ + if( type && strcmp(type, "launcher") && strcmp(type, "logo") && + strcmp(type, "probe") && + strcmp(type, "architecture") && strcmp(type, "noconn")) { + if(skip_instance(n, 1, lvs_ignore)) { + xctx->inst[n].flags |= IGNORE_INST; + } + } + } + + if(shorted_instance(n, lvs_ignore)) { + c = PINLAYER; + what = NOW; + disabled = 2; + } + else if(xctx->inst[n].flags & IGNORE_INST) { + c = GRIDLAYER; + what = NOW; + disabled = 1; + } + if(xctx->inst[n].color != -10000) c = get_color(xctx->inst[n].color); + set_ps_colors(c); + if( (xctx->inst[n].flags & HIDE_INST) || + ((xctx->hide_symbols==1 && (xctx->inst[n].ptr+ xctx->sym)->prop_ptr && + !strcmp( (xctx->inst[n].ptr+ xctx->sym)->type, "subcircuit") )) || + (xctx->hide_symbols == 2) ) { hide = 1; } else { hide = 0; } - if(layer==0) { x1=X_TO_PS(xctx->inst[n].x1); @@ -891,8 +918,34 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho xctx->inst[n].flags|=1; return; } - else xctx->inst[n].flags&=~1; - + #if 0 + else if( + xctx->hilight_nets && /* if highlights... */ + c == 0 && /* we are not drawing highlighted inst */ + /* otherwise c > layer... */ + type && /* ... and type... */ + ( + ( /* ... and inst is hilighted ... */ + IS_LABEL_SH_OR_PIN(type) && xctx->inst[n].node && xctx->inst[n].node[0] && + bus_hilight_hash_lookup(xctx->inst[n].node[0], 0, XLOOKUP ) + ) || (/* !IS_LABEL_SH_OR_PIN(type) && */ (xctx->inst[n].color != -10000)) )) { + xctx->inst[n].flags|=1; /* ... then SKIP instance now and for following layers */ + return; + } + #endif + else if((xctx->inst[n].x2 - xctx->inst[n].x1) * xctx->mooz < 3 && + (xctx->inst[n].y2 - xctx->inst[n].y1) * xctx->mooz < 3) { + drawrect(c, NOW, xctx->inst[n].xx1, xctx->inst[n].yy1, xctx->inst[n].xx2, xctx->inst[n].yy2, 0, -1, -1); + xctx->inst[n].flags|=1; + return; + } + else { + xctx->inst[n].flags&=~1; + } + if(hide) { + int color = (disabled==1) ? GRIDLAYER : (disabled == 2) ? PINLAYER : SYMLAYER; + drawrect(color, NOW, xctx->inst[n].xx1, xctx->inst[n].yy1, xctx->inst[n].xx2, xctx->inst[n].yy2, 2, -1, -1); + } /* pdfmarks, only if doing hierarchy print and if symbol has a subcircuit */ if(what != 7) { char fname[PATH_MAX]; @@ -912,7 +965,7 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho } else if(xctx->inst[n].flags&1) { - dbg(1, "draw_symbol(): skippinginst %d\n", n); + dbg(1, "draw_symbol(): skipping inst %d\n", n); return; } flip = xctx->inst[n].flip; @@ -922,61 +975,81 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho x0=xctx->inst[n].x0 + xoffset; y0=xctx->inst[n].y0 + yoffset; symptr = (xctx->inst[n].ptr+ xctx->sym); - for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->lines[layer]; ++j) - { - line = ((xctx->inst[n].ptr+ xctx->sym)->line[layer])[j]; - ROTATION(rot, flip, 0.0,0.0,line.x1,line.y1,x1,y1); - ROTATION(rot, flip, 0.0,0.0,line.x2,line.y2,x2,y2); - ORDER(x1,y1,x2,y2); - ps_drawline(c, x0+x1, y0+y1, x0+x2, y0+y2, line.dash); - } - for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->polygons[layer]; ++j) - { - polygon = &((xctx->inst[n].ptr+ xctx->sym)->poly[layer])[j]; - { /* scope block so we declare some auxiliary arrays for coord transforms. 20171115 */ - int k, bezier; - double *x = my_malloc(_ALLOC_ID_, sizeof(double) * polygon->points); - double *y = my_malloc(_ALLOC_ID_, sizeof(double) * polygon->points); - for(k=0;kpoints; ++k) { - ROTATION(rot, flip, 0.0,0.0,polygon->x[k],polygon->y[k],x[k],y[k]); - x[k]+= x0; - y[k] += y0; - } - bezier = !strboolcmp(get_tok_value(polygon->prop_ptr, "bezier", 0), "true"); - ps_drawpolygon(c, NOW, x, y, polygon->points, polygon->fill, polygon->dash, bezier); - my_free(_ALLOC_ID_, &x); - my_free(_ALLOC_ID_, &y); - } - } - if((xctx->inst[n].ptr+ xctx->sym)->arcs[layer]) fprintf(fd, "NP\n"); /* newpath */ - for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->arcs[layer]; ++j) - { - double angle; - arc = ((xctx->inst[n].ptr+ xctx->sym)->arc[layer])[j]; - if(flip) { - angle = 270.*rot+180.-arc.b-arc.a; - } else { - angle = arc.a+rot*270.; + if( (layer != PINLAYER && !xctx->enable_layer[layer]) ) goto draw_texts; + + if(!hide) { + for(j=0;j< symptr->lines[layer]; ++j) + { + int dash; + line = &(symptr->line[layer])[j]; + dash = (disabled == 1) ? 3 : line->dash; + ROTATION(rot, flip, 0.0,0.0,line->x1,line->y1,x1,y1); + ROTATION(rot, flip, 0.0,0.0,line->x2,line->y2,x2,y2); + ORDER(x1,y1,x2,y2); + ps_drawline(c, x0+x1, y0+y1, x0+x2, y0+y2, dash); } - angle = fmod(angle, 360.); - if(angle<0.) angle+=360.; - ROTATION(rot, flip, 0.0,0.0,arc.x,arc.y,x1,y1); - ps_drawarc(c, arc.fill, x0+x1, y0+y1, arc.r, angle, arc.b, arc.dash); - } - if( xctx->enable_layer[layer] ) for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->rects[layer]; ++j) - { - rect = ((xctx->inst[n].ptr+ xctx->sym)->rect[layer])[j]; - ROTATION(rot, flip, 0.0,0.0,rect.x1,rect.y1,x1,y1); - ROTATION(rot, flip, 0.0,0.0,rect.x2,rect.y2,x2,y2); - RECTORDER(x1,y1,x2,y2); - if (rect.flags & 1024) /* image */ - { - ps_embedded_image(&rect, x0 + x1, y0 + y1, x0 + x2, y0 + y2, rot, flip); - continue; - } - ps_filledrect(c, x0+x1, y0+y1, x0+x2, y0+y2, rect.dash, rect.fill); - } + for(j=0;j< symptr->polygons[layer]; ++j) + { + int dash; + int bezier; + polygon = &(symptr->poly[layer])[j]; + bezier = !strboolcmp(get_tok_value(polygon->prop_ptr, "bezier", 0), "true"); + dash = (disabled == 1) ? 3 : polygon->dash; + { /* scope block so we declare some auxiliary arrays for coord transforms. 20171115 */ + int k; + double *x = my_malloc(_ALLOC_ID_, sizeof(double) * polygon->points); + double *y = my_malloc(_ALLOC_ID_, sizeof(double) * polygon->points); + for(k=0;kpoints; ++k) { + ROTATION(rot, flip, 0.0,0.0,polygon->x[k],polygon->y[k],x[k],y[k]); + x[k]+= x0; + y[k] += y0; + } + ps_drawpolygon(c, NOW, x, y, polygon->points, polygon->fill, dash, bezier); + my_free(_ALLOC_ID_, &x); + my_free(_ALLOC_ID_, &y); + } + } + if(symptr->arcs[layer]) fprintf(fd, "NP\n"); /* newpath */ + for(j=0;j< symptr->arcs[layer]; ++j) + { + int dash; + double angle; + arc = &(symptr->arc[layer])[j]; + dash = (disabled == 1) ? 3 : arc->dash; + if(flip) { + angle = 270.*rot+180.-arc->b-arc->a; + } else { + angle = arc->a+rot*270.; + } + angle = fmod(angle, 360.); + if(angle<0.) angle+=360.; + ROTATION(rot, flip, 0.0,0.0,arc->x,arc->y,x1,y1); + ps_drawarc(c, arc->fill, x0+x1, y0+y1, arc->r, angle, arc->b, dash); + } + } /* if(!hide) */ + + if( (!hide && xctx->enable_layer[layer]) || + (hide && layer == PINLAYER && xctx->enable_layer[layer]) ) { + for(j=0;j< (xctx->inst[n].ptr+ xctx->sym)->rects[layer]; ++j) + { + int dash; + rect = &(symptr->rect[layer])[j]; + dash = (disabled == 1) ? 3 : rect->dash; + ROTATION(rot, flip, 0.0,0.0,rect->x1,rect->y1,x1,y1); + ROTATION(rot, flip, 0.0,0.0,rect->x2,rect->y2,x2,y2); + RECTORDER(x1,y1,x2,y2); + if (layer == GRIDLAYER && rect->flags & 1024) /* image */ + { + ps_embedded_image(rect, x0 + x1, y0 + y1, x0 + x2, y0 + y2, rot, flip); + continue; + } + ps_filledrect(c, x0+x1, y0+y1, x0+x2, y0+y2, dash, rect->fill); + } + } /* if( (!hide && xctx->enable_layer[layer]) || ... */ + + draw_texts: + if( !(xctx->inst[n].flags & HIDE_SYMBOL_TEXTS) && ( @@ -991,18 +1064,25 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho double xscale, yscale; get_sym_text_size(n, j, &xscale, &yscale); - text = (xctx->inst[n].ptr+ xctx->sym)->text[j]; + text = symptr->text[j]; /* if(xscale*FONTWIDTH* xctx->mooz<1) continue; */ if(!xctx->show_hidden_texts && (text.flags & (HIDE_TEXT | HIDE_TEXT_INSTANTIATED))) continue; if( hide && text.txt_ptr && strcmp(text.txt_ptr, "@symname") && strcmp(text.txt_ptr, "@name") ) continue; txtptr= translate(n, text.txt_ptr); ROTATION(rot, flip, 0.0,0.0,text.x0,text.y0,x1,y1); textlayer = c; - /* do not allow custom text color on PINLAYER hilighted instances */ - if( !(xctx->inst[n].color == -PINLAYER)) { - textlayer = (xctx->inst[n].ptr+ xctx->sym)->text[j].layer; - if(textlayer < 0 || textlayer >= cadlayers) textlayer = c; + /* do not allow custom text color on hilighted instances */ + if(disabled == 1) textlayer = GRIDLAYER; + else if(disabled == 2) textlayer = PINLAYER; + else if( xctx->inst[n].color == -10000) { + int lay; + get_sym_text_layer(n, j, &lay); + if(lay != -1) textlayer = lay; + else textlayer = symptr->text[j].layer; } + if(textlayer < 0 || textlayer >= cadlayers) textlayer = c; + if(textlayer != c) set_ps_colors(textlayer); + /* display PINLAYER colored instance texts even if PINLAYER disabled */ if(xctx->inst[n].color == -PINLAYER || xctx->enable_layer[textlayer]) { my_snprintf(ps_font_family, S(ps_font_name), "Helvetica"); @@ -1035,6 +1115,7 @@ static void ps_draw_symbol(int c, int n,int layer, int what, short tmp_flip, sho x0+x1, y0+y1, xscale, yscale); } } + if(textlayer != c) set_ps_colors(c); } } } @@ -1329,10 +1410,7 @@ void create_ps(char **psfile, int what, int fullzoom, int eps) /* bring outside previous for(c=0...) loop since ps_embedded_graph() calls ps_draw_symbol() */ for(c=0;cinstances; ++i) { - int color = c; - if(xctx->inst[i].color != -10000) color = get_color(xctx->inst[i].color); - set_ps_colors(color); - ps_draw_symbol(color, i,c,what,0,0,0.0,0.0); + ps_draw_symbol(c, i,c,what,0,0,0.0,0.0); } } prepare_netlist_structs(0); /* NEEDED: data was cleared by trim_wires() */