From d706e45987e5624e07c9abf62b293731c7b9d951 Mon Sep 17 00:00:00 2001 From: Stefan Schippers Date: Wed, 30 Sep 2020 23:55:07 +0200 Subject: [PATCH] set max width of .c files <=130 chars; Fix netlist regression: if no "lab=value" is given in instance attributes get lab from symbol "template=" string. This was commented out recently and now reverted back. "View->Enable show net names on symbol pins" global menu added: if unset no symbol pin net names will be shown regardless of instance/symbol "net_name=true" and pin @#n:net_name attributes. --- src/actions.c | 4 ++-- src/callback.c | 3 ++- src/draw.c | 3 ++- src/globals.c | 1 + src/hilight.c | 6 ++++-- src/move.c | 5 ++++- src/netlist.c | 10 ++++------ src/save.c | 5 +++-- src/scheduler.c | 12 +++++++++++- src/select.c | 8 ++++++-- src/svgdraw.c | 26 ++++++++++++++++---------- src/token.c | 23 ++++++++++++++--------- src/vhdl_netlist.c | 6 +++--- src/xinit.c | 4 +++- src/xschem.h | 1 + src/xschem.tcl | 8 ++++++++ 16 files changed, 84 insertions(+), 41 deletions(-) diff --git a/src/actions.c b/src/actions.c index 6e20b0da..6db1e40a 100644 --- a/src/actions.c +++ b/src/actions.c @@ -960,7 +960,6 @@ int place_symbol(int pos, const char *symbol_name, double x, double y, int rot, * to translate @#n:net_name texts */ prepared_netlist_structs=0; prepared_hilight_structs=0; - symbol_bbox(n, &inst_ptr[n].x1, &inst_ptr[n].y1, &inst_ptr[n].x2, &inst_ptr[n].y2); if(draw_sym & 3) bbox(ADD, inst_ptr[n].x1, inst_ptr[n].y1, inst_ptr[n].x2, inst_ptr[n].y2); @@ -2274,7 +2273,8 @@ void place_text(int draw_text, double mx, double my) #endif save_draw=draw_window; /* 20181009 */ draw_window=1; - if(draw_text) draw_string(textlayer, NOW, textelement[lasttext].txt_ptr, 0, 0, textelement[lasttext].hcenter, textelement[lasttext].vcenter, + if(draw_text) draw_string(textlayer, NOW, textelement[lasttext].txt_ptr, 0, 0, + textelement[lasttext].hcenter, textelement[lasttext].vcenter, textelement[lasttext].x0,textelement[lasttext].y0, textelement[lasttext].xscale, textelement[lasttext].yscale); draw_window = save_draw; diff --git a/src/callback.c b/src/callback.c index f4d5dddd..b2216866 100644 --- a/src/callback.c +++ b/src/callback.c @@ -754,7 +754,8 @@ int callback(int event, int mx, int my, KeySym key, if(key=='s' && (state == ControlMask) ) /* save 20121201 */ { if(semaphore >= 2) break; - if(!strcmp(schematic[currentsch],"") || strstr(schematic[currentsch], "untitled")) { /* check if unnamed schematic, use saveas in this case */ + /* check if unnamed schematic, use saveas in this case */ + if(!strcmp(schematic[currentsch],"") || strstr(schematic[currentsch], "untitled")) { saveas(NULL, SCHEMATIC); } else { save(1); diff --git a/src/draw.c b/src/draw.c index 517349ad..8e5da86e 100644 --- a/src/draw.c +++ b/src/draw.c @@ -1773,7 +1773,8 @@ void draw(void) #ifndef __unix__ /* place holder for Windows to show that these XLib functions are not supported in Windows. */ -int XSetClipRectangles(register Display* dpy, GC gc, int clip_x_origin, int clip_y_origin, XRectangle* rectangles, int n, int ordering) +int XSetClipRectangles(register Display* dpy, GC gc, int clip_x_origin, int clip_y_origin, + XRectangle* rectangles, int n, int ordering) { return 0; } diff --git a/src/globals.c b/src/globals.c index 9a44b243..0da2a925 100644 --- a/src/globals.c +++ b/src/globals.c @@ -269,6 +269,7 @@ size_t get_tok_value_size; size_t get_tok_size; int batch_mode = 0; /* no tcl console if set; batch mode */ int hide_symbols = 0; /* draw only a bounding box for component instances and @symname, @name texts */ +int show_pin_net_names = 0; #ifdef HAS_CAIRO cairo_surface_t *sfc, *save_sfc; diff --git a/src/hilight.c b/src/hilight.c index a3a46550..8e513f92 100644 --- a/src/hilight.c +++ b/src/hilight.c @@ -149,7 +149,8 @@ void create_plot_cmd(int viewer) char *t=NULL, *p=NULL; my_strdup(241, &t, tok); my_strdup2(245, &p, (entry->path)+1); - Tcl_VarEval(interp, "puts $gaw_fd {copyvar v(", strtolower(p), strtolower(t), ") p0 #", color_str, "}\nvwait gaw_fd\n", NULL); + Tcl_VarEval(interp, "puts $gaw_fd {copyvar v(", strtolower(p), strtolower(t), + ") p0 #", color_str, "}\nvwait gaw_fd\n", NULL); my_free(759, &p); my_free(760, &t); } @@ -688,7 +689,8 @@ void send_net_to_gaw(char *node) for(k=1; k<=tok_mult; k++) { my_strdup(246, &t, find_nth(expanded_tok, ',', k)); my_strdup2(254, &p, sch_path[currentsch]+1); - Tcl_VarEval(interp, "puts $gaw_fd {copyvar v(", strtolower(p), strtolower(t), ") p0 #", color_str, "}\nvwait gaw_fd\n", NULL); + Tcl_VarEval(interp, "puts $gaw_fd {copyvar v(", strtolower(p), strtolower(t), + ") p0 #", color_str, "}\nvwait gaw_fd\n", NULL); my_free(774, &p); my_free(775, &t); } diff --git a/src/move.c b/src/move.c index 7122f3c6..ba4539cf 100644 --- a/src/move.c +++ b/src/move.c @@ -517,8 +517,10 @@ void copy_objects(int what) set_modify(1); push_undo(); /* 20150327 push_undo */ prepared_hash_instances=0; /* 20171224 */ prepared_hash_wires=0; /* 20171224 */ + /* prepared_netlist_structs=0; prepared_hilight_structs=0; + */ for(k=0;k0 && prepared_netlist_structs) return; /* 20160413 */ else if (!for_netlist && prepared_hilight_structs) return; /* 20171210 */ else delete_netlist_structs(); - if (for_netlist>0) { my_snprintf(nn, S(nn), "-----------%s", schematic[currentsch]); statusmsg(nn,2); @@ -712,13 +711,10 @@ void prepare_netlist_structs(int for_netlist) my_strdup(262, &inst_ptr[i].node[0], get_tok_value(inst_ptr[i].prop_ptr,"lab",1)); - /* taking node lab from sym template has no sense */ - #if 0 if (!(inst_ptr[i].node[0])) { my_strdup(65, &inst_ptr[i].node[0], get_tok_value((inst_ptr[i].ptr+instdef)->templ, "lab",1)); dbg(1, "no lab attr on instance, pick from symbol: %s\n", inst_ptr[i].node[0]); } - #endif /* handle global nodes (global=1 set as symbol property) 28032003 */ if (!strcmp(type,"label") && global_node && !strcmp(global_node, "true")) { dbg(1, "prepare_netlist_structs(): global node: %s\n",inst_ptr[i].node[0]); @@ -1146,7 +1142,8 @@ int sym_vs_sch_pins() ) ) { char str[2048]; - my_snprintf(str, S(str), "Symbol %s: Unmatched subcircuit schematic pin direction: %s", instdef[i].name, lab); + my_snprintf(str, S(str), "Symbol %s: Unmatched subcircuit schematic pin direction: %s", + instdef[i].name, lab); statusmsg(str,2); my_snprintf(str, S(str), " %s <--> %s", type, pin_dir); statusmsg(str,2); @@ -1218,7 +1215,8 @@ int sym_vs_sch_pins() if(!pin_match) { char str[2048]; /* fprintf(errfp, " unmatched sch / sym pin: %s\n", lab); */ - my_snprintf(str, S(str), "Symbol %s: symbol pin: %s not in schematic", instdef[i].name, pin_name ? pin_name : ""); + my_snprintf(str, S(str), "Symbol %s: symbol pin: %s not in schematic", + instdef[i].name, pin_name ? pin_name : ""); statusmsg(str,2); for(k = 0; k < lastinst; k++) { if(!strcmp(inst_ptr[k].name, instdef[i].name)) { diff --git a/src/save.c b/src/save.c index f8723a65..b89c554b 100644 --- a/src/save.c +++ b/src/save.c @@ -467,7 +467,8 @@ static void load_text(FILE *fd) textelement[i].font=NULL; textelement[i].sel=0; load_ascii_string(&textelement[i].prop_ptr,fd); - if( textelement[i].prop_ptr) my_strdup(318, &textelement[i].font, get_tok_value(textelement[i].prop_ptr, "font", 0));/*20171206 */ + if( textelement[i].prop_ptr) + my_strdup(318, &textelement[i].font, get_tok_value(textelement[i].prop_ptr, "font", 0)); str = get_tok_value(textelement[i].prop_ptr, "hcenter", 0); textelement[i].hcenter = strcmp(str, "true") ? 0 : 1; @@ -1802,7 +1803,7 @@ int load_sym_def(const char *name, FILE *embed_fd) &tt[i].flip, &tt[i].xscale, &tt[i].yscale); if (level>0) { const char* tmp = translate2(lcc, level, tt[i].txt_ptr); - rot = lcc[level].rot; flip = lcc[level].flip; /* >>>>> */ + rot = lcc[level].rot; flip = lcc[level].flip; if (tmp) my_strdup(651, &tt[i].txt_ptr, tmp); ROTATION(0.0, 0.0, tt[i].x0, tt[i].y0, rx1, ry1); tt[i].x0 = lcc[level].x0 + rx1; tt[i].y0 = lcc[level].y0 + ry1; diff --git a/src/scheduler.c b/src/scheduler.c index cb47352a..dfe00d69 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -580,7 +580,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg my_strdup(371, &ptr,subst_token(inst_ptr[inst].prop_ptr, "name", name) ); hash_all_names(inst); new_prop_string(inst, ptr,0, disable_unique_names); /* set new prop_ptr */ - my_strdup2(372, &inst_ptr[inst].instname, get_tok_value(inst_ptr[inst].prop_ptr, "name",0)); /* 20150409 */ + my_strdup2(372, &inst_ptr[inst].instname, get_tok_value(inst_ptr[inst].prop_ptr, "name",0)); type=instdef[inst_ptr[inst].ptr].type; /* 20150409 */ cond= !type || (strcmp(type,"label") && strcmp(type,"ipin") && strcmp(type,"show_label") && @@ -1601,6 +1601,12 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg else Tcl_AppendResult(interp, "0",NULL); } + else if(!strcmp(argv[2],"show_pin_net_names")) { + if( show_pin_net_names != 0 ) + Tcl_AppendResult(interp, "1",NULL); + else + Tcl_AppendResult(interp, "0",NULL); + } else if(!strcmp(argv[2],"flat_netlist")) { if( flat_netlist != 0 ) Tcl_AppendResult(interp, "1",NULL); @@ -1853,6 +1859,10 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg int s = atoi(argv[3]); hide_symbols=s; } + else if(!strcmp(argv[2],"show_pin_net_names")) { /* 20171204 */ + int s = atoi(argv[3]); + show_pin_net_names=s; + } else if(!strcmp(argv[2],"user_top_netl_name")) { /* 20171204 */ my_strncpy(user_top_netl_name, argv[3], S(user_top_netl_name)); } diff --git a/src/select.c b/src/select.c index bceb5a8a..9cd2d0bb 100644 --- a/src/select.c +++ b/src/select.c @@ -251,8 +251,10 @@ void delete(void) j = 0; prepared_hash_instances=0; + prepared_netlist_structs=0; prepared_hilight_structs=0; + /* first calculate bbox, because symbol_bbox() needs translate (@#0:net_name) which needs prepare_netlist_structs * which needs a consistent inst_ptr[] data structure */ for(i=0;i\n", - xx, yy, rr, svg_stroke.red, svg_stroke.green, svg_stroke.blue, svg_stroke.red, svg_stroke.green, svg_stroke.blue, svg_linew/4); + fprintf(fd, + "\n", + xx, yy, rr, svg_stroke.red, svg_stroke.green, svg_stroke.blue, + svg_stroke.red, svg_stroke.green, svg_stroke.blue, svg_linew/4); } } @@ -512,14 +514,16 @@ void svg_draw(void) if(dark_colorscheme) { /* black background */ - fprintf(fd,"\n", - 0.0, 0.0, dx, dy, 0, 0, 0, - 0, 0, 0, svg_linew); + fprintf(fd, + "\n", + 0.0, 0.0, dx, dy, 0, 0, 0, 0, 0, 0, svg_linew); } else { /* white background */ - fprintf(fd,"\n", - 0.0, 0.0, dx, dy, 255, 255, 255, - 255, 255, 255, svg_linew); + fprintf(fd, + "\n", + 0.0, 0.0, dx, dy, 255, 255, 255, 255, 255, 255, svg_linew); } svg_drawgrid(); @@ -545,10 +549,12 @@ void svg_draw(void) } for(i=0;iboxptr[PINLAYER][pin_number].prop_ptr,"spice_ignore",0), "true")) { + const char *si; + si = get_tok_value((inst_ptr[inst].ptr+instdef)->boxptr[PINLAYER][pin_number].prop_ptr,"spice_ignore",0); + if(strcmp(si, "true")) { str_ptr = net_name(inst,pin_number, &mult, 0); fprintf(fd, "@%d %s ", mult, str_ptr); } @@ -1748,7 +1751,8 @@ void print_tedax_element(FILE *fd, int inst) if( state==XBEGIN && (c=='$' || c=='@') && !escape) state=XTOKEN; /* 20171029 added !escape, !quote */ - else if( state==XTOKEN && (space || c == '$' || c == '@' || c == '\\') && token_pos > 1 && !escape && !quote) state=XSEPARATOR; + else if( state==XTOKEN && (space || c == '$' || + c == '@' || c == '\\') && token_pos > 1 && !escape && !quote) state=XSEPARATOR; if(token_pos>=sizetok) { @@ -2092,7 +2096,8 @@ const char *net_name(int i, int j, int *mult, int hash_prefix_unnamed_net) { *mult=1; - my_snprintf(errstr, S(errstr), "Warning: unconnected pin, Inst idx: %d, Pin idx: %d Inst:%s\n", i, j, inst_ptr[i].instname ) ; + my_snprintf(errstr, S(errstr), "Warning: unconnected pin, Inst idx: %d, Pin idx: %d Inst:%s\n", + i, j, inst_ptr[i].instname ) ; statusmsg(errstr,2); if(!netlist_count) { inst_ptr[i].flags |=4; @@ -2396,7 +2401,9 @@ void print_verilog_primitive(FILE *fd, int inst) /* netlist switch level primiti else if(token[0]=='@' && token[1]=='#') { pin_number = atoi(token+2); if(pin_number < no_of_pins) { - if(strcmp(get_tok_value((inst_ptr[inst].ptr+instdef)->boxptr[PINLAYER][pin_number].prop_ptr,"verilog_ignore",0), "true")) { + const char *vi; + vi = get_tok_value((inst_ptr[inst].ptr+instdef)->boxptr[PINLAYER][pin_number].prop_ptr,"verilog_ignore",0); + if(strcmp(vi, "true")) { str_ptr = net_name(inst,pin_number, &mult, 0); fprintf(fd, "----pin(%s) ", str_ptr); } @@ -2546,8 +2553,6 @@ const char *translate(int inst, char* s) if(!spiceprefix && !strcmp(token, "@spiceprefix")) { value = NULL; get_tok_size = 0; - } else if(!strcmp(token, "@lab")) { /* don't get '@lab' value from symbol template, makes no sense */ - value = get_tok_value(inst_ptr[inst].prop_ptr, token+1, 2); } else { value = get_tok_value(inst_ptr[inst].prop_ptr, token+1, 2); if(!get_tok_size) value=get_tok_value((inst_ptr[inst].ptr+instdef)->templ, token+1, 2); @@ -2617,8 +2622,8 @@ const char *translate(int inst, char* s) /* @#n:net_name attribute (n = pin number or name) will translate to net name attached to pin * if 'net_name=true' attribute is set in instance or symbol */ if(!pinnumber[0] && !strcmp(pin_attr, "net_name")) { - if(!strcmp(get_tok_value(inst_ptr[inst].prop_ptr, "net_name", 0), "true") || - !strcmp(get_tok_value( (inst_ptr[inst].ptr + instdef)->prop_ptr, "net_name", 0), "true")) { + if( show_pin_net_names && (!strcmp(get_tok_value(inst_ptr[inst].prop_ptr, "net_name", 0), "true") || + !strcmp(get_tok_value( (inst_ptr[inst].ptr + instdef)->prop_ptr, "net_name", 0), "true")) ) { prepare_netlist_structs(0); my_strdup2(1175, &pinnumber, inst_ptr[inst].node && inst_ptr[inst].node[n] ? inst_ptr[inst].node[n] : ""); } diff --git a/src/vhdl_netlist.c b/src/vhdl_netlist.c index 6019bb66..bd16255d 100644 --- a/src/vhdl_netlist.c +++ b/src/vhdl_netlist.c @@ -244,9 +244,9 @@ void global_vhdl_netlist(int global) /* netlister driver */ for(j=0;j