diff --git a/src/draw.c b/src/draw.c index 51bc1feb..0f231233 100644 --- a/src/draw.c +++ b/src/draw.c @@ -1876,7 +1876,8 @@ static void draw_graph_bus_points(const char *ntok, int n_bits, int *idx_arr, double deltag = wy2 - wy1; double s1 = DIG_NWAVES; /* 1/DIG_NWAVES waveforms fit in graph if unscaled vertically */ double s2 = DIG_SPACE; /* (DIG_NWAVES - DIG_SPACE) spacing between traces */ - double c = (n_nodes - wcnt) * s1 * deltag - wy1 * s2; + double c = (n_nodes - wcnt) * s1 * deltag - wy1 * s2; /* trace baseline */ + double c1 = c + (wy2 - wy1) * 0.5 * s2; /* trace y-center, used for clipping */ double x1 = W_X(xctx->graph_values[sweep_idx][first]); double x2 = W_X(xctx->graph_values[sweep_idx][last-1]); double ylow = DW_Y(c + wy2 * s2); /* swapped as xschem Y coordinates are top-bottom */ @@ -1887,37 +1888,39 @@ static void draw_graph_bus_points(const char *ntok, int n_bits, int *idx_arr, double labsize = 0.015 * ydelta; double charwidth = labsize * 38.0; double x_size = 1.5 * xctx->zoom; - drawline(wave_col, NOW, x1, ylow, x2, ylow, 0); - drawline(wave_col, NOW, x1, yhigh, x2, yhigh, 0); - for(p = first ; p <= last; p++) { - /* calculate value of bus by adding all binary bits */ - /* hex_digits = */ - get_bus_value(n_bits, idx_arr, p, busval, wy1, wy2); - xval = W_X(xctx->graph_values[sweep_idx][p]); - /* used to draw bus value before 1st transition */ - if(p == first) { - my_strncpy(old_busval, busval, strlen(busval)+1); - xval_old = xval; - } - if(p > first && strcmp(busval, old_busval)) { - /* draw transition ('X') */ - drawline(BACKLAYER, NOW, xval-x_size, yhigh, xval+x_size, yhigh, 0); - drawline(BACKLAYER, NOW, xval-x_size, ylow, xval+x_size, ylow, 0); - drawline(wave_col, NOW, xval-x_size, ylow, xval+x_size, yhigh, 0); - drawline(wave_col, NOW, xval-x_size, yhigh, xval+x_size, ylow, 0); - /* draw hex bus value if there is enough room */ - if( fabs(xval - xval_old) > strlen(old_busval) * charwidth) { - draw_string(wave_col, NOW, old_busval, 2, 0, 1, 0, (xval + xval_old) * 0.5, - yhigh, labsize, labsize); + if(c1 >= ypos1 && c1 <=ypos2) { + drawline(wave_col, NOW, x1, ylow, x2, ylow, 0); + drawline(wave_col, NOW, x1, yhigh, x2, yhigh, 0); + for(p = first ; p <= last; p++) { + /* calculate value of bus by adding all binary bits */ + /* hex_digits = */ + get_bus_value(n_bits, idx_arr, p, busval, wy1, wy2); + xval = W_X(xctx->graph_values[sweep_idx][p]); + /* used to draw bus value before 1st transition */ + if(p == first) { + my_strncpy(old_busval, busval, strlen(busval)+1); + xval_old = xval; } - my_strncpy(old_busval, busval, strlen(busval)+1); - xval_old = xval; - } /* if(p > first && busval != old_busval) */ - } /* for(p = first ; p < last; p++) */ - /* draw hex bus value after last transition */ - if( fabs(xval - xval_old) > strlen(old_busval) * charwidth) { - draw_string(wave_col, NOW, old_busval, 2, 0, 1, 0, (xval + xval_old) * 0.5, - yhigh, labsize, labsize); + if(p > first && strcmp(busval, old_busval)) { + /* draw transition ('X') */ + drawline(BACKLAYER, NOW, xval-x_size, yhigh, xval+x_size, yhigh, 0); + drawline(BACKLAYER, NOW, xval-x_size, ylow, xval+x_size, ylow, 0); + drawline(wave_col, NOW, xval-x_size, ylow, xval+x_size, yhigh, 0); + drawline(wave_col, NOW, xval-x_size, yhigh, xval+x_size, ylow, 0); + /* draw hex bus value if there is enough room */ + if( fabs(xval - xval_old) > strlen(old_busval) * charwidth) { + draw_string(wave_col, NOW, old_busval, 2, 0, 1, 0, (xval + xval_old) * 0.5, + yhigh, labsize, labsize); + } + my_strncpy(old_busval, busval, strlen(busval)+1); + xval_old = xval; + } /* if(p > first && busval != old_busval) */ + } /* for(p = first ; p < last; p++) */ + /* draw hex bus value after last transition */ + if( fabs(xval - xval_old) > strlen(old_busval) * charwidth) { + draw_string(wave_col, NOW, old_busval, 2, 0, 1, 0, (xval + xval_old) * 0.5, + yhigh, labsize, labsize); + } } } @@ -1933,14 +1936,15 @@ static void draw_graph_points(int v, int first, int last, double deltag = wy2 - wy1; double s1; double s2; - double c; + double c, c1; if(digital) { s1 = DIG_NWAVES; /* 1/DIG_NWAVES waveforms fit in graph if unscaled vertically */ s2 = DIG_SPACE; /* (DIG_NWAVES - DIG_SPACE) spacing between traces */ - c = (n_nodes - wcnt) * s1 * deltag - wy1 * s2; + c = (n_nodes - wcnt) * s1 * deltag - wy1 * s2; /* trace baseline */ + c1 = c + (wy2 - wy1) * 0.5 * s2; /* trace y-center, used for clipping */ } - if( !digital || (c >= ypos1 && c <= ypos2) ) { + if( !digital || (c1 >= ypos1 && c1 <= ypos2) ) { for(p = first ; p <= last; p++) { yy = xctx->graph_values[v][p]; if(digital) { diff --git a/src/xschem.h b/src/xschem.h index ac4618f3..f0051c35 100644 --- a/src/xschem.h +++ b/src/xschem.h @@ -338,7 +338,7 @@ do { \ /* set do double if you need more precision at the expense of memory */ #define SPICE_DATA float #define DIG_NWAVES 0.1 /* inverse number: by default 10 digital traces per graph */ -#define DIG_SPACE 0.08 /* trace extends from 0 to DIG_SPACE, so we have DIG_WAVES-DIG_SPACE +#define DIG_SPACE 0.07 /* trace extends from 0 to DIG_SPACE, so we have DIG_WAVES-DIG_SPACE * spacing between traces */ typedef struct diff --git a/xschem_library/rom8k/rom8k.sch b/xschem_library/rom8k/rom8k.sch index b3740abd..8a836a90 100644 --- a/xschem_library/rom8k/rom8k.sch +++ b/xschem_library/rom8k/rom8k.sch @@ -32,8 +32,8 @@ y1 = -0.0039 y2 = 0.87 divy = 3 subdivy=1 -x1=1.5328e-07 -x2=1.84945e-07 divx=10 +x1=1.52536e-07 +x2=1.84201e-07 divx=10 node=" ldbl[0] ldbl[16] ldbl[32] ldbl[1] ldbl[17] ldbl[33] @@ -47,8 +47,8 @@ y1 = -0.021 y2 = 1.5 subdivy=1 divy = 4 -x1=1.5328e-07 -x2=1.84945e-07 +x1=1.52536e-07 +x2=1.84201e-07 divx=10 subdivx=4 node="ldcp ldyms[4] ldyms[5] ldyms[6] ldymsref" @@ -61,8 +61,8 @@ y2 = 1.6 divy = 3 subdivy=0 subdivx = 1 -x1=1.5328e-07 -x2=1.84945e-07 divx=10 +x1=1.52536e-07 +x2=1.84201e-07 divx=10 node=" ldwl[0] ldwl[1] ldwl[2] ldwl[3] ldwl[4] ldwl[5] ldwl[6] ldwl[16] @@ -74,8 +74,8 @@ B 2 1840 -120 2890 -20 {flags=3 y1 = -0.021 y2 = 0.9 divy = 1 -x1=1.5328e-07 -x2=1.84945e-07 divx=10 +x1=1.52536e-07 +x2=1.84201e-07 divx=10 node="ldymsref" color=3 unitx=n subdivy=4 } @@ -83,11 +83,11 @@ B 2 1840 -880 2890 -420 {flags=3 digital=1 y1 = 0 y2 = 1.6 -ypos1=0.0890868 -ypos2=2.14223 +ypos1=-0.0272427 +ypos2=2.11513 divy = 1 -x1=2e-12 -x2=4.8e-07 +x1=1.52536e-07 +x2=1.84201e-07 divx=12 subdivx=4 node=" @@ -103,7 +103,7 @@ LDL2X,ldl2x[3],ldl2x[2],ldl2x[1],ldl2x[0] LDL1X,ldl1x[15],ldl1x[14],ldl1x[13],ldl1x[12],ldl1x[11],ldl1x[10],ldl1x[9],ldl1x[8],ldl1x[7],ldl1x[6],ldl1x[5],ldl1x[4],ldl1x[3],ldl1x[2],ldl1x[1],ldl1x[0] LDY1,ldy1[3],ldy1[2],ldy1[1],ldy1[0] " -color="3 15 4 15 3 15 4 3 4 15 4 15 4 15 4 15 4 15 4 15 4 15" +color="18 15 4 15 18 15 4 18 4 15 4 15 4 15 4 15 4 15 4 15 4 15" unitx=n ypos1=-2.20115 ypos2=2.79884 } @@ -111,8 +111,8 @@ B 2 1840 -1280 2890 -1090 {flags=3 y1 = -0.022 y2 = 1.6 divy = 4 -x1=1.5328e-07 -x2=1.84945e-07 +x1=1.52536e-07 +x2=1.84201e-07 divx=8 unitx=n node="xsa[0].ldqib xsa[5].ldqib xsa[0].ldsali xctrl.ldq_b"