Jspice3
noievals.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3f2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1987 Gary W. Ng
5  1993 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 /*
9  * NevalSrc (noise, lnNoise, ckt, type, node1, node2, param)
10  * This routine evaluates the noise due to different physical
11  * phenomena. This includes the "shot" noise associated with dc
12  * currents in semiconductors and the "thermal" noise associated with
13  * resistance. Although semiconductors also display "flicker" (1/f)
14  * noise, the lack of a unified model requires us to handle it on a
15  * "case by case" basis. What we CAN provide, though, is the noise
16  * gain associated with the 1/f source.
17  */
18 
19 
20 #include "spice.h"
21 #include <math.h>
22 #include "cktdefs.h"
23 #include "noisedef.h"
24 #include "const.h"
25 #include "util.h"
26 
27 
28 void
29 NevalSrc(noise, lnNoise, ckt, type, node1, node2, param)
30 
31 double *noise;
32 double *lnNoise;
33 CKTcircuit *ckt;
34 int type;
35 int node1;
36 int node2;
37 double param;
38 {
39  double realVal;
40  double imagVal;
41  double gain;
42 
43  realVal = *(ckt->CKTrhs + node1) - *(ckt->CKTrhs + node2);
44  imagVal = *(ckt->CKTirhs + node1) - *(ckt->CKTirhs + node2);
45  gain = realVal*realVal + imagVal*imagVal;
46 
47  switch (type) {
48 
49  case SHOTNOISE:
50  /* param is the dc current in a semiconductor */
51  *noise = gain * 2 * CHARGE * FABS(param);
52  *lnNoise = log( MAX(*noise,N_MINLOG) );
53  break;
54 
55  case THERMNOISE:
56  /* param is the conductance of a resistor */
57  *noise = gain * 4 * CONSTboltz * ckt->CKTtemp * param;
58  *lnNoise = log( MAX(*noise,N_MINLOG) );
59  break;
60 
61  case N_GAIN:
62  *noise = gain;
63  break;
64  }
65 }
#define N_GAIN
Definition: noisedef.h:90
double * CKTirhs
Definition: cktdefs.h:100
#define MAX(a, b)
Definition: spdefs.h:135
double CKTtemp
Definition: cktdefs.h:80
#define CHARGE
Definition: const.h:10
#define N_MINLOG
Definition: noisedef.h:95
#define CONSTboltz
Definition: const.h:12
Definition: types.c:18
#define SHOTNOISE
Definition: noisedef.h:88
#define FABS(a)
Definition: util.h:41
#define THERMNOISE
Definition: noisedef.h:89
void NevalSrc(double *noise, double *lnNoise, CKTcircuit *ckt, int type, int node1, int node2, double param)
Definition: noievals.c:29
double * CKTrhs
Definition: cktdefs.h:97