sichere Breakpoints bei TRNOISE

This commit is contained in:
h_vogt 2010-12-12 12:27:51 +00:00
parent 5dbaff0226
commit b1e1c03430
2 changed files with 36 additions and 35 deletions

View File

@ -1,3 +1,7 @@
2010-12-12 Holger Vogt
* vsrcacct.c: Patch von R. Larice für sichere Breakpoints
bei TRNOISE
2010-12-11 Robert Larice 2010-12-11 Robert Larice
* src/include/bool.h : * src/include/bool.h :
Change bool from `unsigned char' to `int' Change bool from `unsigned char' to `int'

View File

@ -193,44 +193,41 @@ VNoi1 1 0 DC 0 TRNOISE(0n 0.5n 1 10n) : generate 1/f noise
0, time step, exponent < 2, rms value 0, time step, exponent < 2, rms value
*/ */
case TRNOISE: { case TRNOISE: {
double NA, NT, TS, time, basetime = 0.; double NA, NT, NALPHA, NAMP, TS;
#define NSAMETIME(a,b) (fabs((a)-(b))<= NTIMETOL * TS) NA = here->VSRCcoeffs[0]; // input is rms value
#define NTIMETOL 1e-7 NT = here->VSRCcoeffs[1]; // time step
NA = here->VSRCcoeffs[0]; // input is rms value NALPHA = here->VSRCfunctionOrder > 2
NT = here->VSRCcoeffs[1]; // time step ? here->VSRCcoeffs[2] : 0.0;
if (NT == 0.) // no further breakpoint if value not given NAMP = here->VSRCfunctionOrder > 3
break; && here->VSRCcoeffs[3] != 0.0
// TS = NT > ckt->CKTstep ? NT : ckt->CKTstep; && here->VSRCcoeffs[2] != 0.0
TS = NT; ? here->VSRCcoeffs[3] : 0.0;
time = ckt->CKTtime;
if(time >= TS) { if ((NT == 0.) || ((NA == 0.) && (NAMP == 0.))) // no further breakpoint if value not given
/* repeating signal - figure out where we are break;
in period */ TS = NT;
basetime = TS * floor(time*1.000000000001/TS);
// basetime = TS * floor(time/TS); if(ckt->CKTbreak) {
// basetime = TS * here->VSRCncount;
time -= basetime; int n = (int) floor(ckt->CKTtime / TS + 0.5);
} volatile double nearest = n * TS;
if(ckt->CKTbreak && NSAMETIME(time,0)) {
/* set next breakpoint */ if(AlmostEqualUlps(nearest, ckt->CKTtime, 3)) {
// error = CKTsetBreak(ckt, TS * ((double)here->VSRCncount + 1.)); /* carefull calculate `next'
error = CKTsetBreak(ckt, basetime + TS); * make sure it is really identical
if(error) return(error); * with the next calculated `nearest' value
} */
/* else if (ckt->CKTbreak && NSAMETIME(time,TS)) { volatile double next = (n+1) * TS;
// set next breakpoint error = CKTsetBreak(ckt, next);
error = CKTsetBreak(ckt, basetime + TS + TS); if(error)
if(error) return(error); return(error);
} */ }
if (ckt->CKTtime == 0.) { }
// printf("VSRC: free fft tables\n"); }
fftFree(); break;
}
}
break;
} }
} }
bkptset: ; bkptset: ;