[experimental] better wave labels positioning in graphs

This commit is contained in:
Stefan Frederik 2021-12-23 03:43:34 +01:00
parent 8a0fc1c1df
commit b11955a3aa
13 changed files with 155 additions and 78 deletions

View File

@ -402,7 +402,7 @@ int callback(const char *winpath, int event, int mx, int my, KeySym key,
break;
case Expose:
dbg(0, "callback: Expose, winpath=%s, %dx%d+%d+%d\n", winpath, button, aux, mx, my);
dbg(1, "callback: Expose, winpath=%s, %dx%d+%d+%d\n", winpath, button, aux, mx, my);
XCopyArea(display, xctx->save_pixmap, xctx->window, xctx->gctiled, mx,my,button,aux,mx,my);
{
XRectangle xr[1];

View File

@ -1682,7 +1682,9 @@ void draw_graph(int c, int i)
double txtsizelab, txtsizey, txtsizex, tmp;
struct int_hashentry *entry;
int sweep_idx = 0;
int n_nodes; /* number of variables to display in a single graph */
xRect *r = &xctx->rect[c][i];
/* container (embedding rectangle) coordinates */
rx1 = r->x1;
@ -1760,7 +1762,8 @@ void draw_graph(int c, int i)
* swap order of wy1 and wy2 since grap y orientation is opposite to xorg orientation */
if(wx1 <= 0 && wx2 >= 0) drawline(2, NOW, W_X(0), W_Y(wy2), W_X(0), W_Y(wy1), 0);
/* if simulation data is loaded and matches schematic draw data */
if(xctx->raw_schname && !strcmp(xctx->raw_schname, xctx->current_name) && xctx->values) {
if(xctx->raw_schname && (!strcmp(xctx->raw_schname, get_cell_w_ext(xctx->sch[0], 0)) ||
!strcmp(xctx->raw_schname, xctx->current_name) ) && xctx->values) {
char *saven, *savec, *saves, *nptr, *cptr, *sptr, *ntok, *ctok, *stok;
int wcnt = 0;
double *xarr = NULL, *yarr = NULL;
@ -1772,6 +1775,7 @@ void draw_graph(int c, int i)
nptr = node;
cptr = color;
sptr = sweep;
n_nodes = count_items(node, " \t");
/* process each node given in "node" attribute, get also associated color if any*/
while( (ntok = my_strtok_r(nptr, " ", &saven)) ) {
ctok = my_strtok_r(cptr, " ", &savec);
@ -1787,10 +1791,10 @@ void draw_graph(int c, int i)
/* draw sweep variable(s) on x-axis */
if(wcnt == 0 || (stok && stok[0])) {
draw_string(wave_color, NOW, xctx->names[sweep_idx], 2, 1, 0, 0,
rx1 + 2 + rw/6 * wcnt, ry2-1, txtsizelab, txtsizelab);
rx1 + 2 + rw/n_nodes * wcnt, ry2-1, txtsizelab, txtsizelab);
}
/* draw node labels in graph */
draw_string(wave_color, NOW, ntok, 0, 0, 0, 0, rx1 + rw/6 * wcnt, ry1, txtsizelab, txtsizelab);
draw_string(wave_color, NOW, ntok, 0, 0, 0, 0, rx1 + rw/n_nodes * wcnt, ry1, txtsizelab, txtsizelab);
/* clipping everything outside graph area */
/* quickly find index number of ntok variable to be plotted */
entry = int_hash_lookup(xctx->raw_table, ntok, 0, XLOOKUP);

View File

@ -264,26 +264,26 @@ size_t my_strncat(int id, char **str, size_t n, const char *append_str)
{
size_t s, a;
dbg(3,"my_strncat(%d,): str=%s append_str=%s\n", id, *str, append_str);
a = strlen(append_str)+1;
if(a>n+1) a=n+1;
a = strlen(append_str) + 1;
if(a > n + 1) a = n + 1;
if( *str != NULL)
{
s = strlen(*str);
if(append_str == NULL || append_str[0]=='\0') return s;
if(append_str == NULL || append_str[0] == '\0') return s;
my_realloc(id, str, s + a );
memcpy(*str+s, append_str, a);
*(*str+s+a) = '\0';
memcpy(*str + s, append_str, a);
*(*str + s + a - 1) = '\0';
dbg(3,"my_strncat(%d,): reallocated string %s\n", id, *str);
return s + a -1;
return s + a - 1;
}
else
{
if(append_str == NULL || append_str[0]=='\0') return 0;
if(append_str == NULL || append_str[0] == '\0') return 0;
*str = my_malloc(id, a );
memcpy(*str, append_str, a);
*(*str+a) = '\0';
*(*str + a - 1) = '\0';
dbg(3,"my_strncat(%d,): allocated string %s\n", id, *str);
return a -1;
return a - 1;
}
}

View File

@ -2579,6 +2579,9 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
if(!strcmp(argv[1],"test"))
{
cmd_found = 1;
if(argc > 2) {
dbg(0, "%s --> %d\n", argv[2], count_items(argv[2], " \t,;"));
}
Tcl_ResetResult(interp);
}

View File

@ -642,7 +642,7 @@ void new_prop_string(int i, const char *old_prop, int fast, int dis_uniq_names)
const char *tmp;
const char *tmp2;
int q,qq;
static int last[256]; /* safe to keep with multiple schematics, reset on 1st invocation */
static int last[1 << 8 * sizeof(char) ]; /* safe to keep with multiple schematics, reset on 1st invocation */
int old_name_len;
int new_name_len;
int n;
@ -945,18 +945,30 @@ const char *get_cell_w_ext(const char *str, int no_of_dir)
return get_trailing_path(str, no_of_dir, 0);
}
/* not used? */
int count_labels(char *s)
/* in a string with tokens separated by characters in 'sep'
* count number of tokens. Multiple separators and leading/trailing
* separators are allowed. */
int count_items(const char *s, const char *sep)
{
int i=1;
const char *ptr;
char table[1 << 8 * sizeof(unsigned char)];
int items = 0;
int state = 0; /* 1 if item is being processed */
int c;
if(s==NULL) return 1;
while( (c=(*s++)) ) {
if(c==',') i++;
memset(table, 0, sizeof(table));
ptr = sep;
while( (c = *(unsigned char *)ptr++) ) table[c] = 1;
ptr = s;
while( (c = *(unsigned char *)ptr++) ) {
if(!table[c]) { /* not a separator */
if(!state) items++;
state = 1;
} else {
state = 0;
}
}
return i;
return items;
}
void print_vhdl_element(FILE *fd, int inst)

View File

@ -930,6 +930,7 @@ extern int ps_draw(int what);
extern void svg_draw(void);
extern void set_viewport_size(int w, int h, double lw);
extern void print_image();
extern const char *get_trailing_path(const char *str, int no_of_dir, int skip_ext);
extern const char *skip_dir(const char *str);
extern const char *get_cell(const char *str, int no_of_dir);
extern const char *get_cell_w_ext(const char *str, int no_of_dir);
@ -1211,7 +1212,7 @@ extern void select_line(int c, int i, unsigned short select_mode, int fast);
extern void select_polygon(int c, int i, unsigned short select_mode, int fast );
extern const char *net_name(int i, int j, int *mult, int hash_prefix_unnamed_net, int erc);
extern int record_global_node(int what, FILE *fp, char *node);
extern int count_labels(char *s);
extern int count_items(const char *s, const char *sep);
extern int get_unnamed_node(int what, int mult, int node);
extern void node_hash_free(void);
extern void traverse_node_hash();

View File

@ -158,11 +158,11 @@ C {cmos_inv.sch} 140 -260 0 0 {name=Xinv WN=15u WP=45u LLN=3u LLP=3u}
C {cmos_inv.sym} 280 -190 0 0 {name=Xinv2 WN=15u WP=45u LLN=3u LLP=3u}
C {bus_keeper.sch} 1200 60 0 0 {name=Xkeeper WN_FB=3u WP_FB=5u}
C {lab_pin.sym} 700 -490 0 1 {name=p1 lab=ZZ}
C {launcher.sym} 65 -1015 0 0 {name=h5
descr="Select arrow and
Ctrl-Right-Click to load waveforms"
tclcommand="xschem raw_read $netlist_dir/[file rootname [xschem get current_name]].raw"}
C {lab_pin.sym} 540 -760 0 0 {name=p14 lab=A}
C {cmos_inv.sym} 580 -850 0 1 {name=Xinv3 WN=3u WP=5u LLN=3u LLP=3u}
C {lab_pin.sym} 620 -760 0 1 {name=p2 lab=Z}
C {cmos_inv.sym} 580 -760 0 0 {name=Xinv1 WN=3u WP=5u LLN=3u LLP=3u}
C {launcher.sym} 105 -1015 0 0 {name=h5
descr="Ctrl-Left-Click on arrow
to load waveforms"
tclcommand="xschem raw_read $netlist_dir/[file rootname [xschem get current_name]].raw"}

View File

@ -309,7 +309,7 @@ tclcommand="textwindow $netlist_dir/[file tail [file rootname [ xschem get schna
}
C {spice_probe.sym} 360 -1220 0 0 {name=p45 analysis=tran voltage=0.0000e+00}
C {spice_probe.sym} 360 -1060 0 0 {name=p46 analysis=tran voltage=0.0000e+00}
C {launcher.sym} 1105 -865 0 0 {name=h5
descr="Select arrow and
Ctrl-Right-Click to load waveforms"
C {launcher.sym} 1115 -875 0 0 {name=h5
descr="Ctrl-Left-Click on arrow
to load waveforms"
tclcommand="xschem raw_read $netlist_dir/[file rootname [xschem get current_name]].raw"}

View File

@ -42,8 +42,8 @@ B 2 1110 -950 1530 -800 {flags=1
y1 = 0
y2 = 20
divy = 10
x1=0
x2=200e-6
x1=3.388e-21
x2=0.0002
divx=8
node="v(led) v(sw)"
color="11 18"}
@ -51,16 +51,16 @@ B 2 1110 -790 1530 -660 {flags=1
y1 = 0
y2 = 20
divy = 10
x1=0
x2=200e-6
x1=3.388e-21
x2=0.0002
divx=8
node="v(panel)"}
B 2 1110 -650 1530 -520 {flags=1
y1 = 0
y2 = 4
divy = 8
x1=0
x2=200e-6
x1=3.388e-21
x2=0.0002
divx=8
node="i(vsw)" color=12}
B 18 45 -850 300 -665 {}
@ -89,7 +89,7 @@ T {2x10 1W white LED} 1230 -340 0 0 0.4 0.4 {layer=8}
T {IDEAL Diode} 690 -470 0 0 0.4 0.4 {layer=8}
T {2xseries 1W white LEDs} 1250 -230 0 0 0.4 0.4 {}
T {Select one or more graphs (and no other objects)
and use arrow keys to zoom / pan waveforms} 1120 -990 0 0 0.3 0.3 {}
and use arrow keys to zoom / pan waveforms} 1120 -1010 0 0 0.3 0.3 {}
N 80 -450 80 -430 {lab=SRC}
N 1050 -250 1140 -250 {lab=0}
N 1140 -290 1140 -250 {lab=0}
@ -217,7 +217,7 @@ C {spice_probe.sym} 1160 -480 0 0 {name=p1 analysis=tran}
C {spice_probe.sym} 360 -450 0 0 {name=p2 analysis=tran}
C {spice_probe.sym} 860 -550 0 1 {name=p3 analysis=tran}
C {spice_probe.sym} 100 -450 0 1 {name=p4 analysis=tran}
C {launcher.sym} 1165 -1025 0 0 {name=h3
descr="Select arrow and
Ctrl-Right-Click to load waveforms"
C {launcher.sym} 1185 -1055 0 0 {name=h5
descr="Ctrl-Left-Click on arrow
to load waveforms"
tclcommand="xschem raw_read $netlist_dir/[file rootname [xschem get current_name]].raw"}

View File

@ -1,15 +1,43 @@
v {xschem version=2.9.5 file_version=1.1}
v {xschem version=3.0.0 file_version=1.2 }
G {}
K {}
V {}
S {}
E {}
N 360 -480 500 -480 {lab=LDCPB}
N 240 -570 250 -570 {lab=LDCPB}
N 240 -570 240 -480 {lab=LDCPB}
N 200 -480 240 -480 {lab=LDCPB}
N 240 -680 240 -570 {lab=LDCPB}
N 240 -680 250 -680 {lab=LDCPB}
N 360 -320 420 -320 {lab=LDCPB}
B 2 580 -140 1200 -30 {flags=1
y1 = 0
y2 = 2
divy = 2
x1=1.4e-07
x2=1.8e-07
divx=8
node="v(ldcp) v(xctrl.ldcp_ref) v(xctrl.ldprechref)"
color=12\\ 5\\ 13}
B 2 580 -230 1200 -140 {flags=1
y1 = 0
y2 = 2
divy = 2
x1=1.4e-07
x2=1.8e-07
divx=8
node="v(ldcp) v(xctrl.ldcpb)"
color=12\\ 5\\ 8}
B 2 580 -320 1200 -230 {flags=1
y1 = 0
y2 = 2
divy = 2
x1=1.4e-07
x2=1.8e-07
divx=8
node="v(ldcp) v(xctrl.ldouti) v(xctrl.ldoutib)"
color=12\\ 5\\ 8}
N 370 -560 510 -560 {lab=LDCPB}
N 250 -650 260 -650 {lab=LDCPB}
N 250 -650 250 -560 {lab=LDCPB}
N 210 -560 250 -560 {lab=LDCPB}
N 250 -760 250 -650 {lab=LDCPB}
N 250 -760 260 -760 {lab=LDCPB}
N 370 -400 430 -400 {lab=LDCPB}
N 910 -850 910 -790 {lab=#net1}
N 810 -760 910 -790 {lab=#net1}
N 810 -760 810 -710 {lab=#net1}
@ -19,9 +47,9 @@ N 810 -830 810 -780 {lab=#net2}
N 1360 -130 1360 -80 {lab=VSS}
N 990 -850 1010 -850 {lab=LDOUTIB}
N 1080 -400 1120 -400 {lab=LDPRECHREF}
N 360 -480 360 -320 {lab=LDCPB}
N 410 -680 430 -680 {lab=#net3}
N 240 -480 360 -480 {lab=LDCPB}
N 370 -560 370 -400 {lab=LDCPB}
N 420 -760 440 -760 {lab=#net3}
N 250 -560 370 -560 {lab=LDCPB}
N 1360 -210 1360 -190 {lab=#net4}
N 1320 -240 1320 -160 {lab=LDOUTI}
N 1360 -390 1360 -370 {lab=LDYMSREF}
@ -41,37 +69,37 @@ C {ipin.sym} 210 -170 0 0 { name=p49 lab=LDEN_LAT }
C {ipin.sym} 210 -150 0 0 { name=p50 lab=LDCP }
C {ipin.sym} 210 -130 0 0 { name=p51 lab=VCC }
C {ipin.sym} 210 -110 0 0 { name=p52 lab=VSS }
C {lab_wire.sym} 260 -480 0 0 {name=l19 lab=LDCPB}
C {capa.sym} 270 -450 0 0 {name=c84 m=1 value=5f}
C {lab_pin.sym} 270 -420 0 0 {name=p1109 lab=VSS}
C {lab_pin.sym} 330 -570 0 1 {name=p1111 lab=LDCP_SA}
C {lvnand2.sym} 140 -480 0 0 {name=x392 m=1
C {lab_wire.sym} 270 -560 0 0 {name=l19 lab=LDCPB}
C {capa.sym} 280 -530 0 0 {name=c84 m=1 value=5f}
C {lab_pin.sym} 280 -500 0 0 {name=p1109 lab=VSS}
C {lab_pin.sym} 340 -650 0 1 {name=p1111 lab=LDCP_SA}
C {lvnand2.sym} 150 -560 0 0 {name=x392 m=1
+ wna=90u lna=2.4u wpa=60u lpa=2.4u
+ wnb=90u lnb=2.4u wpb=60u lpb=2.4u
+ VCCPIN=vcc VSSPIN=vss }
C {lab_pin.sym} 100 -500 0 0 {name=p1113 lab=LDCP}
C {lab_pin.sym} 100 -460 0 0 {name=p1114 lab=LDEN_LAT}
C {lab_pin.sym} 410 -810 0 1 {name=p1115 lab=LDCP_ADDLAT_B}
C {lvnot.sym} 290 -570 0 0 {name=x394 m=1
C {lab_pin.sym} 110 -580 0 0 {name=p1113 lab=LDCP}
C {lab_pin.sym} 110 -540 0 0 {name=p1114 lab=LDEN_LAT}
C {lab_pin.sym} 420 -890 0 1 {name=p1115 lab=LDCP_ADDLAT_B}
C {lvnot.sym} 300 -650 0 0 {name=x394 m=1
+ wn=8.4u lln=2.8u wp=40u lp=2.4u
+ VCCPIN=vcc VSSPIN=vss
}
C {lvnot.sym} 470 -680 0 0 {name=x395 m=10
C {lvnot.sym} 480 -760 0 0 {name=x395 m=10
+ wn=15u lln=2.4u wp=40u lp=2.4u
+ VCCPIN=vcc VSSPIN=vss}
C {lvnot.sym} 290 -680 0 0 {name=x396 m=1
C {lvnot.sym} 300 -760 0 0 {name=x396 m=1
+ wn=15u lln=2.4u wp=40u lp=2.4u
+ VCCPIN=vcc VSSPIN=vss}
C {lvnot.sym} 370 -680 0 0 {name=x397 m=4
C {lvnot.sym} 380 -760 0 0 {name=x397 m=4
+ wn=15u lln=2.4u wp=40u lp=2.4u
+ VCCPIN=vcc VSSPIN=vss}
C {lab_pin.sym} 510 -680 0 1 {name=p1116 lab=LDCP_ROWDEC}
C {lab_pin.sym} 580 -320 0 1 {name=p1117 lab=LDCP_COL_B}
C {lvnot.sym} 370 -810 0 0 {name=x405 m=1
C {lab_pin.sym} 520 -760 0 1 {name=p1116 lab=LDCP_ROWDEC}
C {lab_pin.sym} 590 -400 0 1 {name=p1117 lab=LDCP_COL_B}
C {lvnot.sym} 380 -890 0 0 {name=x405 m=1
+ wn=30u lln=2.4u wp=80u lp=2.4u
+ VCCPIN=vcc VSSPIN=vss}
C {lab_pin.sym} 330 -810 0 0 {name=p1118 lab=LDCP}
C {lab_pin.sym} 580 -480 0 1 {name=p7 lab=LDCP_REF}
C {lab_pin.sym} 340 -890 0 0 {name=p1118 lab=LDCP}
C {lab_pin.sym} 590 -560 0 1 {name=p7 lab=LDCP_REF}
C {lab_pin.sym} 990 -690 0 1 {name=p22 lab=LDOUTI}
C {lvnot.sym} 900 -520 0 0 {name=x7 m=1
+ wn=24u lln=2.4u wp=40u lp=2.4u
@ -110,13 +138,13 @@ C {lvnot.sym} 1380 -860 0 0 {name=x28 m=8
+ wn=13u lln=2.4u wp=40u lp=2.4u
+ VCCPIN=vcc VSSPIN=vss}
C {lab_pin.sym} 1010 -850 0 1 {name=p15 lab=LDOUTIB}
C {lvnot.sym} 540 -480 0 0 {name=x4 m=2
C {lvnot.sym} 550 -560 0 0 {name=x4 m=2
+ wn=13u lln=2.4u wp=40u lp=2.4u
+ VCCPIN=vcc VSSPIN=vss}
C {lvnot.sym} 540 -320 0 0 {name=x1 m=2
C {lvnot.sym} 550 -400 0 0 {name=x1 m=2
+ wn=20u lln=2.4u wp=44u lp=2.4u
+ VCCPIN=vcc VSSPIN=vss}
C {lvnot.sym} 460 -320 0 0 {name=x6 m=1
C {lvnot.sym} 470 -400 0 0 {name=x6 m=1
+ wn=8.4u lln=2.4u wp=16u lp=2.4u
+ VCCPIN=vcc VSSPIN=vss}
C {iopin.sym} 260 -110 0 0 { name=p20 lab=LDYMSREF }
@ -138,7 +166,7 @@ C {lab_pin.sym} 1580 -640 0 1 {name=p33 lab=LDQI}
C {lab_pin.sym} 1360 -390 0 1 {name=p12 lab=LDYMSREF}
C {rom2_sacell.sym} 1450 -510 0 0 {name=xsacell}
C {lab_pin.sym} 1320 -160 0 0 {name=p13 lab=LDOUTI}
C {spice_probe.sym} 580 -480 0 0 {name=p95 analysis=tran}
C {spice_probe.sym} 590 -560 0 0 {name=p95 analysis=tran}
C {spice_probe.sym} 1080 -400 0 0 {name=p19 analysis=tran}
C {spice_probe.sym} 990 -690 0 0 {name=p28 analysis=tran}
C {spice_probe.sym} 990 -850 0 0 {name=p31 analysis=tran}
@ -155,5 +183,5 @@ C {lab_pin.sym} 980 -420 0 0 {name=p8 lab=LDCPB}
C {nlv.sym} 1500 -160 0 0 {name=m2 model=cmosn w=4u l=2.4u m=1}
C {lab_pin.sym} 1480 -160 0 0 {name=p0 lab=LDOUTI}
C {nlv.sym} 1500 -240 0 0 {name=m0 model=cmosn w=4u l=2.4u m=1}
C {spice_probe.sym} 400 -480 0 0 {name=p25 analysis=tran}
C {spice_probe.sym} 410 -560 0 0 {name=p25 analysis=tran}
C {lab_pin.sym} 1300 -540 0 0 {name=p14 lab=LDCPB}

View File

@ -1,8 +1,36 @@
v {xschem version=2.9.5 file_version=1.1}
v {xschem version=3.0.0 file_version=1.2 }
G {}
K {}
V {}
S {}
E {}
B 2 380 -840 1060 -660 {flags=1
y1 = 0
y2 = 2
divy = 4
x1=2.6e-07
x2=3.4e-07
divx=8
node="v(xsa[0].ldqi) v(xsa[0].ldqib) v(xsa[0].ldsali)"
color="12\\ 5\\ 8\\ 11"}
B 2 380 -940 1060 -850 {flags=1
y1 = 0
y2 = 2
divy = 2
x1=2.6e-07
x2=3.4e-07
divx=8
node="v(ldcp) v(ldprech)"
color=12\\ 5\\ 8}
B 2 380 -650 1060 -540 {flags=1
y1 = 0
y2 = 2
divy = 2
x1=2.6e-07
x2=3.4e-07
divx=8
node="v(xsa[0].ldqiii) v(xsa[0].ldqii) v(xsa[0].ldsali)"
color=12\\ 5\\ 8}
T {Was:
60/24} 1420 -310 0 0 0.4 0.4 {}
T {was: LDCP_B} 510 -410 0 0 0.4 0.4 {}

View File

@ -1,5 +1,6 @@
v {xschem version=2.9.7 file_version=1.2}
v {xschem version=3.0.0 file_version=1.2 }
G {}
K {}
V {}
S {}
E {}

View File

@ -280,7 +280,7 @@ C {lab_pin.sym} 1670 -740 0 0 {name=l2 lab=LDWL[8:0]}
C {spice_probe.sym} 1670 -740 0 0 {name=p46 analysis=tran}
C {lab_pin.sym} 1670 -790 0 0 {name=l4 lab=LDBL[0,16,32,1,17,33,2,18,34]}
C {spice_probe.sym} 1670 -790 0 0 {name=p91 analysis=tran}
C {launcher.sym} 1935 -1115 0 0 {name=h2
descr="Select arrow and
Ctrl-Right-Click to load waveforms"
C {launcher.sym} 1925 -1115 0 0 {name=h5
descr="Ctrl-Left-Click on arrow
to load waveforms"
tclcommand="xschem raw_read $netlist_dir/[file rootname [xschem get current_name]].raw"}