merge TRRANDOM vsrc -> isrc
This commit is contained in:
parent
49211d2153
commit
2a693e2d80
12
ChangeLog
12
ChangeLog
|
|
@ -1,3 +1,15 @@
|
||||||
|
2011-02-28 Robert Larice
|
||||||
|
* src/spicelib/devices/isrc/isrc.c ,
|
||||||
|
* src/spicelib/devices/isrc/isrcacct.c ,
|
||||||
|
* src/spicelib/devices/isrc/isrcask.c ,
|
||||||
|
* src/spicelib/devices/isrc/isrcdefs.h ,
|
||||||
|
* src/spicelib/devices/isrc/isrcload.c ,
|
||||||
|
* src/spicelib/devices/isrc/isrcpar.c ,
|
||||||
|
* src/spicelib/devices/vsrc/vsrc.c ,
|
||||||
|
* src/spicelib/devices/vsrc/vsrcload.c :
|
||||||
|
merge TRRANDOM vsrc -> isrc
|
||||||
|
see commit from 11-01-16
|
||||||
|
|
||||||
2011-02-27 Robert Larice
|
2011-02-27 Robert Larice
|
||||||
* src/spicelib/devices/isrc/* ,
|
* src/spicelib/devices/isrc/* ,
|
||||||
* src/spicelib/devices/vsrc/* :
|
* src/spicelib/devices/vsrc/* :
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ IFparm ISRCpTable[] = { /* parameters */
|
||||||
IOP ("sffm", ISRC_SFFM, IF_REALVEC,"Single freq. FM description"),
|
IOP ("sffm", ISRC_SFFM, IF_REALVEC,"Single freq. FM description"),
|
||||||
IOP ("am", ISRC_AM, IF_REALVEC,"Amplitude modulation description"),
|
IOP ("am", ISRC_AM, IF_REALVEC,"Amplitude modulation description"),
|
||||||
IOP ("trnoise", ISRC_TRNOISE, IF_REALVEC,"Transient noise description"),
|
IOP ("trnoise", ISRC_TRNOISE, IF_REALVEC,"Transient noise description"),
|
||||||
|
IOP ("trrandom", ISRC_TRRANDOM, IF_REALVEC,"random source description"),
|
||||||
|
|
||||||
OPU ("pos_node",ISRC_POS_NODE, IF_INTEGER,"Positive node of source"),
|
OPU ("pos_node",ISRC_POS_NODE, IF_INTEGER,"Positive node of source"),
|
||||||
OPU ("neg_node",ISRC_NEG_NODE, IF_INTEGER,"Negative node of source"),
|
OPU ("neg_node",ISRC_NEG_NODE, IF_INTEGER,"Negative node of source"),
|
||||||
OPU ("function",ISRC_FCN_TYPE, IF_INTEGER,"Function of the source"),
|
OPU ("function",ISRC_FCN_TYPE, IF_INTEGER,"Function of the source"),
|
||||||
|
|
|
||||||
|
|
@ -263,6 +263,35 @@ ISRCaccept(CKTcircuit *ckt, GENmodel *inModel)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TRRANDOM: {
|
||||||
|
struct trrandom_state *state = here -> ISRCtrrandom_state;
|
||||||
|
double TS = state -> TS;
|
||||||
|
double TD = state -> TD;
|
||||||
|
|
||||||
|
double time = ckt->CKTtime - TD;
|
||||||
|
|
||||||
|
if (time < 0) break;
|
||||||
|
|
||||||
|
if(ckt->CKTbreak) {
|
||||||
|
|
||||||
|
int n = (int) floor(time / TS + 0.5);
|
||||||
|
volatile double nearest = n * TS;
|
||||||
|
|
||||||
|
if(AlmostEqualUlps(nearest, time, 3)) {
|
||||||
|
/* carefully calculate `next'
|
||||||
|
* make sure it is really identical
|
||||||
|
* with the next calculated `nearest' value
|
||||||
|
*/
|
||||||
|
volatile double next = (n+1) * TS + TD;
|
||||||
|
error = CKTsetBreak(ckt, next);
|
||||||
|
if(error)
|
||||||
|
return(error);
|
||||||
|
state->value = trrandom_state_get(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
} // switch
|
} // switch
|
||||||
} // if ... else
|
} // if ... else
|
||||||
bkptset: ;
|
bkptset: ;
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ ISRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *
|
||||||
case ISRC_SFFM:
|
case ISRC_SFFM:
|
||||||
case ISRC_AM:
|
case ISRC_AM:
|
||||||
case ISRC_TRNOISE:
|
case ISRC_TRNOISE:
|
||||||
|
case ISRC_TRRANDOM:
|
||||||
case ISRC_FCN_COEFFS:
|
case ISRC_FCN_COEFFS:
|
||||||
temp = value->v.numValue = here->ISRCfunctionOrder;
|
temp = value->v.numValue = here->ISRCfunctionOrder;
|
||||||
v = value->v.vec.rVec = TMALLOC(double, here->ISRCfunctionOrder);
|
v = value->v.vec.rVec = TMALLOC(double, here->ISRCfunctionOrder);
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ typedef struct sISRCinstance {
|
||||||
double ISRCdF2phase; /* distortion f2 phase */
|
double ISRCdF2phase; /* distortion f2 phase */
|
||||||
|
|
||||||
struct trnoise_state *ISRCtrnoise_state; /* transient noise */
|
struct trnoise_state *ISRCtrnoise_state; /* transient noise */
|
||||||
|
struct trrandom_state *ISRCtrrandom_state; /* transient random source */
|
||||||
|
|
||||||
/* gtri - begin - add member to hold current source value */
|
/* gtri - begin - add member to hold current source value */
|
||||||
#ifdef XSPICE
|
#ifdef XSPICE
|
||||||
|
|
@ -89,6 +90,7 @@ typedef struct sISRCmodel {
|
||||||
#define PWL 5
|
#define PWL 5
|
||||||
#define AM 6
|
#define AM 6
|
||||||
#define TRNOISE 7
|
#define TRNOISE 7
|
||||||
|
#define TRRANDOM 8
|
||||||
#endif /*PULSE*/
|
#endif /*PULSE*/
|
||||||
|
|
||||||
/* device parameters */
|
/* device parameters */
|
||||||
|
|
@ -121,6 +123,8 @@ typedef struct sISRCmodel {
|
||||||
#endif
|
#endif
|
||||||
/* gtri - end - add define for current source value */
|
/* gtri - end - add define for current source value */
|
||||||
#define ISRC_TRNOISE 25
|
#define ISRC_TRNOISE 25
|
||||||
|
#define ISRC_TRRANDOM 26
|
||||||
|
|
||||||
/* model parameters */
|
/* model parameters */
|
||||||
|
|
||||||
/* device questions */
|
/* device questions */
|
||||||
|
|
|
||||||
|
|
@ -354,6 +354,15 @@ INoi1 1 0 DC 0 TRNOISE(0n 0.5n 1 10n) : generate 1/f noise
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TRRANDOM: {
|
||||||
|
struct trrandom_state *state = here -> ISRCtrrandom_state;
|
||||||
|
value = state -> value;
|
||||||
|
/* DC value */
|
||||||
|
if(here -> ISRCdcGiven)
|
||||||
|
value += here->ISRCdcValue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
} // switch
|
} // switch
|
||||||
} // else (line 48)
|
} // else (line 48)
|
||||||
loadDone:
|
loadDone:
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,32 @@ ISRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
||||||
|
|
||||||
here->ISRCtrnoise_state =
|
here->ISRCtrnoise_state =
|
||||||
trnoise_state_init(NA, TS, NALPHA, NAMP, RTSAM, RTSCAPT, RTSEMT);
|
trnoise_state_init(NA, TS, NALPHA, NAMP, RTSAM, RTSCAPT, RTSEMT);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ISRC_TRRANDOM: {
|
||||||
|
double TD = 0.0, TS;
|
||||||
|
int rndtype = 1;
|
||||||
|
double PARAM1 = 1.0;
|
||||||
|
double PARAM2 = 0.0;
|
||||||
|
|
||||||
|
here->ISRCfunctionType = TRRANDOM;
|
||||||
|
here->ISRCfuncTGiven = TRUE;
|
||||||
|
copy_coeffs(here, value);
|
||||||
|
|
||||||
|
rndtype = (int)here->ISRCcoeffs[0]; // type of random function
|
||||||
|
TS = here->ISRCcoeffs[1]; // time step
|
||||||
|
if (here->ISRCfunctionOrder > 2)
|
||||||
|
TD = here->ISRCcoeffs[2]; // delay
|
||||||
|
|
||||||
|
if (here->ISRCfunctionOrder > 3)
|
||||||
|
PARAM1 = here->ISRCcoeffs[3]; // first parameter
|
||||||
|
|
||||||
|
if (here->ISRCfunctionOrder > 4)
|
||||||
|
PARAM2 = here->ISRCcoeffs[4]; // second parameter
|
||||||
|
|
||||||
|
here->ISRCtrrandom_state =
|
||||||
|
trrandom_state_init(rndtype, TS, TD, PARAM1, PARAM2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ IFparm VSRCpTable[] = { /* parameters */
|
||||||
IOP ("sffm", VSRC_SFFM, IF_REALVEC,"Single freq. FM description"),
|
IOP ("sffm", VSRC_SFFM, IF_REALVEC,"Single freq. FM description"),
|
||||||
IOP ("am", VSRC_AM, IF_REALVEC,"Amplitude modulation description"),
|
IOP ("am", VSRC_AM, IF_REALVEC,"Amplitude modulation description"),
|
||||||
IOP ("trnoise", VSRC_TRNOISE, IF_REALVEC,"Transient noise description"),
|
IOP ("trnoise", VSRC_TRNOISE, IF_REALVEC,"Transient noise description"),
|
||||||
IOP ("trrandom", VSRC_TRRANDOM, IF_REALVEC,"random voltage description"),
|
IOP ("trrandom", VSRC_TRRANDOM, IF_REALVEC,"random source description"),
|
||||||
|
|
||||||
OPU ("pos_node",VSRC_POS_NODE, IF_INTEGER,"Positive node of source"),
|
OPU ("pos_node",VSRC_POS_NODE, IF_INTEGER,"Positive node of source"),
|
||||||
OPU ("neg_node",VSRC_NEG_NODE, IF_INTEGER,"Negative node of source"),
|
OPU ("neg_node",VSRC_NEG_NODE, IF_INTEGER,"Negative node of source"),
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,7 @@ VNoi3 3 0 DC 0 TRNOISE(0 0 0 0 15m 22u 50u) : generate RTS noise
|
||||||
value += RTSAM;
|
value += RTSAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DC value */
|
/* DC value */
|
||||||
if(here -> VSRCdcGiven)
|
if(here -> VSRCdcGiven)
|
||||||
value += here->VSRCdcValue;
|
value += here->VSRCdcValue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue