Skip to content

Commit

Permalink
Fixed jjpulse.cir example to work when delay not broken.
Browse files Browse the repository at this point in the history
  • Loading branch information
wrcad committed Dec 4, 2018
1 parent 9901f0e commit c178582
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
8 changes: 3 additions & 5 deletions wrspice/examples/JJexamples/jjpulse.cir
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*.noexec
*.options Lval=2.6p Rnval=3 Cval=160f Ibval=180
.options Lval=2.6p Rnval=4.9 Cval=68f Ibval=160

* Needed for best resolution
.options steptype=nousertp

.control
Expand Down Expand Up @@ -123,12 +121,12 @@ x5 6 10 jtl
vx 20 0 1.5*v(10)
rx 20 1 1
ry 10 0 1
.tran .1p 300p
.tran .1p 350p
* use v(5) to measure pulse width
.plot tran v(1) v(5)

.measure tran t1 trig v(5) val=.3m rise=3
.measure tran t2 trig v(5) val=.3m rise=4
.measure tran t1 trig v(5) val=.5m rise=3
.measure tran t2 trig v(5) val=.5m rise=4
.measure tran pw trig t1 td=20p targ t2 td=20p pw v(5) max v(5)

* Below,
Expand Down
6 changes: 6 additions & 0 deletions wrspice/notes/note-4.3
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,9 @@ top.

updates to measure syntax
new command "measure"
todo:
why jjpulse.cir example is foobar when delay is working DONE, example fixed
use expression parse in sTpoint parser, save as parse tree
use sTpoint in stop command
.stop, .iplot syntax elements
integrate these as margin/MC analysis tests
32 changes: 16 additions & 16 deletions wrspice/src/fte/measure.cc
Original file line number Diff line number Diff line change
Expand Up @@ -710,13 +710,13 @@ sTpoint::check_found(sFtCirc *circuit, bool *err, bool end)
return (true);

sDataVec *xs = circuit->runplot()->scale();
int indx = chk_trig(t_delay, xs);
if (indx < 0)
int ix = chk_trig(t_delay, xs);
if (ix < 0)
return (false);

double fval = t_delay;
if (t_type == TPnum)
fval = xs->realval(indx);
fval = xs->realval(ix);
else if (t_type == TPmref) {
}
else if (t_type == TPexp1) {
Expand All @@ -738,40 +738,40 @@ sTpoint::check_found(sFtCirc *circuit, bool *err, bool end)
}
int r = 0, f = 0, c = 0;
bool foundit = false;
for ( ; indx < dvl->length(); indx++) {
if (indx && value(dvl, indx-1) <= value(dvr, indx-1) &&
value(dvr, indx) < value(dvl, indx)) {
for ( ; ix < dvl->length(); ix++) {
if (ix && value(dvl, ix-1) <= value(dvr, ix-1) &&
value(dvr, ix) < value(dvl, ix)) {
r++;
c++;
}
else if (indx && value(dvl, indx-1) > value(dvr, indx-1) &&
value(dvr, indx) >= value(dvl, indx)) {
else if (ix && value(dvl, ix-1) > value(dvr, ix-1) &&
value(dvr, ix) >= value(dvl, ix)) {
f++;
c++;
}
else
continue;
if (r >= t_rises && f >= t_falls && c >= t_crosses) {
double d = value(dvr, indx) - value(dvr, indx-1) -
(value(dvl, indx) - value(dvl, indx-1));
double d = value(dvr, ix) - value(dvr, ix-1) -
(value(dvl, ix) - value(dvl, ix-1));
if (d != 0.0) {
fval = xs->realval(indx-1) +
(xs->realval(indx) - xs->realval(indx-1))*
(value(dvl, indx-1) - value(dvr, indx-1))/d;
fval = xs->realval(ix-1) +
(xs->realval(ix) - xs->realval(ix-1))*
(value(dvl, ix-1) - value(dvr, ix-1))/d;
}
else
fval = xs->realval(indx);
fval = xs->realval(ix);
foundit = true;
if (end)
indx--;
ix--;
break;
}
}
if (!foundit)
return (false);
}

t_indx = indx;
t_indx = ix;
t_found = fval;
t_found_flag = true;
return (true);
Expand Down

0 comments on commit c178582

Please sign in to comment.