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.

This commit is contained in:
Stefan Schippers 2020-09-30 23:55:07 +02:00
parent d0b659c455
commit d706e45987
16 changed files with 84 additions and 41 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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;k<cadlayers;k++)
{
@ -928,9 +930,10 @@ void move_objects(int what, int merge, double dx, double dy)
set_modify(1);
prepared_hash_instances=0; /* 20171224 */
prepared_hash_wires=0; /* 20171224 */
/*
prepared_netlist_structs=0;
prepared_hilight_structs=0;
*/
if( !(ui_state & (STARTMERGE | PLACE_SYMBOL)) ) {
dbg(1, "move_objects(): push undo state\n");
push_undo(); /* 20150327 push_undo */

View File

@ -631,7 +631,6 @@ void prepare_netlist_structs(int for_netlist)
if (for_netlist>0 && 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 : "<NULL>");
my_snprintf(str, S(str), "Symbol %s: symbol pin: %s not in schematic",
instdef[i].name, pin_name ? pin_name : "<NULL>");
statusmsg(str,2);
for(k = 0; k < lastinst; k++) {
if(!strcmp(inst_ptr[k].name, instdef[i].name)) {

View File

@ -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;

View File

@ -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));
}

View File

@ -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<lastinst;i++)
@ -355,6 +357,10 @@ void bbox(int what,double x1,double y1, double x2, double y2)
static int savew, saveh, savex1, savex2, savey1, savey2;
static int sem=0;
/* for close zooms draw whole viewing area,
this updates whole viewing area so all symbol pin @#n:net_name
attributes will be updated when that net label or pin "lab" attribute is changed. */
if(what == SET && (X_TO_XSCHEM(areax2) - X_TO_XSCHEM(areax1) < ITERATOR_THRESHOLD)) what = END;
/* fprintf(errfp, "bbox: what=%d\n", what); */
switch(what)
{
@ -484,8 +490,6 @@ void unselect_all(void)
}
}
}
/* prepared_hilight_structs = 0; */
for(i=0;i<lastinst;i++)
{
if(inst_ptr[i].sel == SELECTED)

View File

@ -143,8 +143,10 @@ static void svg_drawcircle(int gc, int fillarc, double x,double y,double r,doubl
if( rectclip(areax1,areay1,areax2,areay2,&x1,&y1,&x2,&y2) )
{
fprintf(fd, "<circle cx=\"%g\" cy=\"%g\" r=\"%g\" stroke=\"rgb(%d,%d,%d)\" fill=\"rgb(%d,%d,%d)\" stroke-width=\"%g\"/>\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,
"<circle cx=\"%g\" cy=\"%g\" r=\"%g\" stroke=\"rgb(%d,%d,%d)\" fill=\"rgb(%d,%d,%d)\" stroke-width=\"%g\"/>\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,"<rect x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" fill=\"rgb(%d,%d,%d)\" stroke=\"rgb(%d,%d,%d)\" stroke-width=\"%g\" />\n",
0.0, 0.0, dx, dy, 0, 0, 0,
0, 0, 0, svg_linew);
fprintf(fd,
"<rect x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" fill=\"rgb(%d,%d,%d)\" "
"stroke=\"rgb(%d,%d,%d)\" stroke-width=\"%g\" />\n",
0.0, 0.0, dx, dy, 0, 0, 0, 0, 0, 0, svg_linew);
} else {
/* white background */
fprintf(fd,"<rect x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" fill=\"rgb(%d,%d,%d)\" stroke=\"rgb(%d,%d,%d)\" stroke-width=\"%g\" />\n",
0.0, 0.0, dx, dy, 255, 255, 255,
255, 255, 255, svg_linew);
fprintf(fd,
"<rect x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" fill=\"rgb(%d,%d,%d)\" "
"stroke=\"rgb(%d,%d,%d)\" stroke-width=\"%g\" />\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;i<lastarc[c];i++)
{
svg_drawarc(c, arc[c][i].fill, arc[c][i].x, arc[c][i].y, arc[c][i].r, arc[c][i].a, arc[c][i].b, arc[c][i].dash);
svg_drawarc(c, arc[c][i].fill, arc[c][i].x, arc[c][i].y, arc[c][i].r,
arc[c][i].a, arc[c][i].b, arc[c][i].dash);
}
for(i=0;i<lastpolygon[c];i++) {
svg_drawpolygon(c, NOW, polygon[c][i].x, polygon[c][i].y, polygon[c][i].points, polygon[c][i].fill, polygon[c][i].dash);
svg_drawpolygon(c, NOW, polygon[c][i].x, polygon[c][i].y, polygon[c][i].points,
polygon[c][i].fill, polygon[c][i].dash);
}
for(i=0;i<lastinst;i++) {
svg_draw_symbol(i,c,0,0,0.0,0.0);

View File

@ -79,7 +79,8 @@ int name_strcmp(char *s, char *d) /* compare strings up to '\0' or'[' */
* 1,XDELETE : delete token entry, return NULL
* 2,XLOOKUP : lookup only
*/
static struct inst_hashentry *inst_hash_lookup(struct inst_hashentry **table, char *token, int value, int remove, size_t token_size)
static struct inst_hashentry *inst_hash_lookup(struct inst_hashentry **table, char *token,
int value, int remove, size_t token_size)
{
unsigned int hashcode;
unsigned int index;
@ -1591,7 +1592,9 @@ void print_spice_element(FILE *fd, int inst)
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,"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] : "<UNCONN>");
}

View File

@ -244,9 +244,9 @@ void global_vhdl_netlist(int global) /* netlister driver */
for(j=0;j<lastinstdef;j++)
{
if( strcmp(get_tok_value(instdef[j].prop_ptr,"vhdl_primitive",0),"true")==0 ) continue;
if( strcmp(get_tok_value(instdef[j].prop_ptr,"vhdl_ignore",0),"true")==0 ) continue; /* 20070726 */
/* if(get_tok_value(instdef[j].prop_ptr,"vhdl_format",2)[0] != '\0') continue; */
if(!instdef[j].type || (strcmp(instdef[j].type,"primitive")!=0 && strcmp(instdef[j].type,"subcircuit")!=0)) continue; /*20080611 */
if( strcmp(get_tok_value(instdef[j].prop_ptr,"vhdl_ignore",0),"true")==0 ) continue;
if(!instdef[j].type || (strcmp(instdef[j].type,"primitive")!=0 &&
strcmp(instdef[j].type,"subcircuit")!=0)) continue;
if((
strcmp(instdef[j].type,"subcircuit")==0 ||
strcmp(instdef[j].type,"primitive")==0

View File

@ -1104,6 +1104,7 @@ int Tcl_AppInit(Tcl_Interp *inter)
split_files=atoi(tclgetvar("split_files"));
netlist_show=atoi(tclgetvar("netlist_show"));
unzoom_nodrift=atoi(tclgetvar("unzoom_nodrift"));
show_pin_net_names = atoi(tclgetvar("show_pin_net_names"));
if(color_ps==-1)
color_ps=atoi(tclgetvar("color_ps"));
@ -1271,7 +1272,8 @@ int Tcl_AppInit(Tcl_Interp *inter)
#else
format = XRenderFindStandardFormat(display, PictStandardRGB24);
sfc = cairo_xlib_surface_create_with_xrender_format (display, window, DefaultScreenOfDisplay(display), format, 1, 1);
save_sfc = cairo_xlib_surface_create_with_xrender_format (display, save_pixmap, DefaultScreenOfDisplay(display), format, 1, 1);
save_sfc = cairo_xlib_surface_create_with_xrender_format(
display, save_pixmap, DefaultScreenOfDisplay(display), format, 1, 1);
#endif
#else
sfc = cairo_xlib_surface_create(display, window, visual, wattr.width, wattr.height);

View File

@ -680,6 +680,7 @@ extern size_t get_tok_value_size;
extern size_t get_tok_size;
extern int batch_mode; /* no TCL console */
extern int hide_symbols; /* draw only a bounding box for component instances and @symname, @name texts */
extern int show_pin_net_names;
/* FUNCTIONS */
extern void enable_layers(void);

View File

@ -3129,6 +3129,9 @@ set_ne xschem_listen_port {}
# hide instance details (show only bbox)
set_ne hide_symbols 0
# show net names if symbol has attributes like @#n:net_name (where n = pin number or pin name)
# and net_name=true global attribute set on symbol or instance.
set_ne show_pin_net_names 0
# gaw tcp {host port}
set_ne gaw_tcp_address {localhost 2020}
@ -3629,6 +3632,11 @@ font configure Underline-Font -underline true -size 24
-command {
if { $toolbar_visible } { toolbar_show } else { toolbar_hide }
}
.menubar.zoom.menu add checkbutton -label "Enable show net names on symbol pins" -variable show_pin_net_names \
-command {
xschem set show_pin_net_names $show_pin_net_names
xschem redraw
}
.menubar.zoom.menu add checkbutton -label "Horizontal Toolbar" -variable toolbar_horiz \
-command {
if { $toolbar_visible } {