noisean, introduce a .control variable "sqrnoise" to deliver noise data in squared representation
use "set srqrnoise" (and "unset sqrnoise") to control this.
This commit is contained in:
parent
8d6726f0f4
commit
7d92eae124
|
|
@ -39,6 +39,10 @@ static struct type types[NUMTYPES] = {
|
||||||
{ "current", "A" } ,
|
{ "current", "A" } ,
|
||||||
{ "voltage-density", "V/sqrt(Hz)" } ,
|
{ "voltage-density", "V/sqrt(Hz)" } ,
|
||||||
{ "current-density", "A/sqrt(Hz)" } ,
|
{ "current-density", "A/sqrt(Hz)" } ,
|
||||||
|
{ "voltage^2-density", "(V^2)/Hz" } ,
|
||||||
|
{ "current^2-density", "(A^2)/Hz" } ,
|
||||||
|
{ "voltage^2", "(V^2)" } ,
|
||||||
|
{ "current^2", "(A^2)" } ,
|
||||||
{ "pole", NULL } ,
|
{ "pole", NULL } ,
|
||||||
{ "zero", NULL } ,
|
{ "zero", NULL } ,
|
||||||
{ "s-param", NULL } ,
|
{ "s-param", NULL } ,
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ typedef struct {
|
||||||
char *squared_value;
|
char *squared_value;
|
||||||
runDesc *NplotPtr; /* the plot pointer */
|
runDesc *NplotPtr; /* the plot pointer */
|
||||||
IFuid *namelist; /* list of plot names */
|
IFuid *namelist; /* list of plot names */
|
||||||
|
unsigned squared : 1;
|
||||||
} Ndata;
|
} Ndata;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ enum simulation_types {
|
||||||
SV_CURRENT,
|
SV_CURRENT,
|
||||||
SV_VOLTAGE_DENSITY,
|
SV_VOLTAGE_DENSITY,
|
||||||
SV_CURRENT_DENSITY,
|
SV_CURRENT_DENSITY,
|
||||||
|
SV_SQR_VOLTAGE_DENSITY,
|
||||||
|
SV_SQR_CURRENT_DENSITY,
|
||||||
|
SV_SQR_VOLTAGE,
|
||||||
|
SV_SQR_CURRENT,
|
||||||
SV_POLE,
|
SV_POLE,
|
||||||
SV_ZERO,
|
SV_ZERO,
|
||||||
SV_SPARAM,
|
SV_SPARAM,
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ CKTnoise (CKTcircuit *ckt, int mode, int operation, Ndata *data)
|
||||||
data->outpVector =
|
data->outpVector =
|
||||||
TMALLOC(double, data->numPlots);
|
TMALLOC(double, data->numPlots);
|
||||||
data->squared_value =
|
data->squared_value =
|
||||||
TMALLOC(char, data->numPlots);
|
data->squared ? NULL : TMALLOC(char, data->numPlots);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INT_NOIZ:
|
case INT_NOIZ:
|
||||||
|
|
@ -85,7 +85,7 @@ CKTnoise (CKTcircuit *ckt, int mode, int operation, Ndata *data)
|
||||||
data->outpVector =
|
data->outpVector =
|
||||||
TMALLOC(double, data->numPlots);
|
TMALLOC(double, data->numPlots);
|
||||||
data->squared_value =
|
data->squared_value =
|
||||||
TMALLOC(char, data->numPlots);
|
data->squared ? NULL : TMALLOC(char, data->numPlots);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
@ -107,9 +107,10 @@ CKTnoise (CKTcircuit *ckt, int mode, int operation, Ndata *data)
|
||||||
(outNdens * data->GainSqInv);
|
(outNdens * data->GainSqInv);
|
||||||
|
|
||||||
refVal.rValue = data->freq; /* the reference is the freq */
|
refVal.rValue = data->freq; /* the reference is the freq */
|
||||||
for (i = 0; i < data->outNumber; i++)
|
if (!data->squared)
|
||||||
if (data->squared_value[i])
|
for (i = 0; i < data->outNumber; i++)
|
||||||
data->outpVector[i] = sqrt(data->outpVector[i]);
|
if (data->squared_value[i])
|
||||||
|
data->outpVector[i] = sqrt(data->outpVector[i]);
|
||||||
outData.v.numValue = data->outNumber; /* vector number */
|
outData.v.numValue = data->outNumber; /* vector number */
|
||||||
outData.v.vec.rVec = data->outpVector; /* vector of outputs */
|
outData.v.vec.rVec = data->outpVector; /* vector of outputs */
|
||||||
SPfrontEnd->OUTpData (data->NplotPtr, &refVal, &outData);
|
SPfrontEnd->OUTpData (data->NplotPtr, &refVal, &outData);
|
||||||
|
|
@ -119,9 +120,10 @@ CKTnoise (CKTcircuit *ckt, int mode, int operation, Ndata *data)
|
||||||
case INT_NOIZ:
|
case INT_NOIZ:
|
||||||
data->outpVector[data->outNumber++] = data->outNoiz;
|
data->outpVector[data->outNumber++] = data->outNoiz;
|
||||||
data->outpVector[data->outNumber++] = data->inNoise;
|
data->outpVector[data->outNumber++] = data->inNoise;
|
||||||
for (i = 0; i < data->outNumber; i++)
|
if (!data->squared)
|
||||||
if (data->squared_value[i])
|
for (i = 0; i < data->outNumber; i++)
|
||||||
data->outpVector[i] = sqrt(data->outpVector[i]);
|
if (data->squared_value[i])
|
||||||
|
data->outpVector[i] = sqrt(data->outpVector[i]);
|
||||||
outData.v.vec.rVec = data->outpVector; /* vector of outputs */
|
outData.v.vec.rVec = data->outpVector; /* vector of outputs */
|
||||||
outData.v.numValue = data->outNumber; /* vector number */
|
outData.v.numValue = data->outNumber; /* vector number */
|
||||||
SPfrontEnd->OUTpData (data->NplotPtr, &refVal, &outData);
|
SPfrontEnd->OUTpData (data->NplotPtr, &refVal, &outData);
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ Modified: 2001 AlansFixes
|
||||||
#include "ngspice/acdefs.h"
|
#include "ngspice/acdefs.h"
|
||||||
#include "ngspice/cktdefs.h"
|
#include "ngspice/cktdefs.h"
|
||||||
#include "ngspice/iferrmsg.h"
|
#include "ngspice/iferrmsg.h"
|
||||||
|
#include "ngspice/cpextern.h"
|
||||||
#include "ngspice/noisedef.h"
|
#include "ngspice/noisedef.h"
|
||||||
#include "ngspice/sperror.h"
|
#include "ngspice/sperror.h"
|
||||||
#include "ngspice/sim.h"
|
#include "ngspice/sim.h"
|
||||||
|
|
@ -122,6 +123,7 @@ NOISEan (CKTcircuit *ckt, int restart)
|
||||||
data->freq = job->NstartFreq;
|
data->freq = job->NstartFreq;
|
||||||
data->outNoiz = 0.0;
|
data->outNoiz = 0.0;
|
||||||
data->inNoise = 0.0;
|
data->inNoise = 0.0;
|
||||||
|
data->squared = cp_getvar("sqrnoise", CP_BOOL, NULL) ? 1 : 0;
|
||||||
|
|
||||||
/* the current front-end needs the namelist to be fully
|
/* the current front-end needs the namelist to be fully
|
||||||
declared before an OUTpBeginplot */
|
declared before an OUTpBeginplot */
|
||||||
|
|
@ -138,19 +140,26 @@ NOISEan (CKTcircuit *ckt, int restart)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (src_type == SV_VOLTAGE)
|
if (src_type == SV_VOLTAGE)
|
||||||
fixme_inoise_type = SV_VOLTAGE_DENSITY;
|
fixme_inoise_type =
|
||||||
|
data->squared ? SV_SQR_VOLTAGE_DENSITY : SV_VOLTAGE_DENSITY;
|
||||||
else
|
else
|
||||||
fixme_inoise_type = SV_CURRENT_DENSITY;
|
fixme_inoise_type =
|
||||||
|
data->squared ? SV_SQR_CURRENT_DENSITY : SV_CURRENT_DENSITY;
|
||||||
|
|
||||||
fixme_onoise_type = SV_VOLTAGE_DENSITY;
|
fixme_onoise_type =
|
||||||
|
data->squared ? SV_SQR_VOLTAGE_DENSITY : SV_VOLTAGE_DENSITY;
|
||||||
|
|
||||||
for (i = 0; i < data->numPlots; i++)
|
if (!data->squared)
|
||||||
data->squared_value[i] =
|
for (i = 0; i < data->numPlots; i++)
|
||||||
ciprefix("inoise", data->namelist[i]) ||
|
data->squared_value[i] =
|
||||||
ciprefix("onoise", data->namelist[i]);
|
ciprefix("inoise", data->namelist[i]) ||
|
||||||
|
ciprefix("onoise", data->namelist[i]);
|
||||||
|
|
||||||
error = SPfrontEnd->OUTpBeginPlot (ckt, ckt->CKTcurJob,
|
error = SPfrontEnd->OUTpBeginPlot (ckt, ckt->CKTcurJob,
|
||||||
"Noise Spectral Density Curves",
|
data->squared
|
||||||
|
? "Noise Spectral Density Curves - (V^2 or A^2)/Hz"
|
||||||
|
|
||||||
|
: "Noise Spectral Density Curves",
|
||||||
freqUid, IF_REAL,
|
freqUid, IF_REAL,
|
||||||
data->numPlots, data->namelist, IF_REAL,
|
data->numPlots, data->namelist, IF_REAL,
|
||||||
&(data->NplotPtr));
|
&(data->NplotPtr));
|
||||||
|
|
@ -296,16 +305,26 @@ NOISEan (CKTcircuit *ckt, int restart)
|
||||||
|
|
||||||
if (error) return(error);
|
if (error) return(error);
|
||||||
|
|
||||||
fixme_inoise_type = src_type;
|
if (src_type == SV_VOLTAGE)
|
||||||
fixme_onoise_type = SV_VOLTAGE;
|
fixme_inoise_type =
|
||||||
|
data->squared ? SV_SQR_VOLTAGE : SV_VOLTAGE;
|
||||||
|
else
|
||||||
|
fixme_inoise_type =
|
||||||
|
data->squared ? SV_SQR_CURRENT : SV_CURRENT;
|
||||||
|
|
||||||
for (i = 0; i < data->numPlots; i++)
|
fixme_onoise_type =
|
||||||
data->squared_value[i] =
|
data->squared ? SV_SQR_VOLTAGE : SV_VOLTAGE;
|
||||||
ciprefix("inoise", data->namelist[i]) ||
|
|
||||||
ciprefix("onoise", data->namelist[i]);
|
if (!data->squared)
|
||||||
|
for (i = 0; i < data->numPlots; i++)
|
||||||
|
data->squared_value[i] =
|
||||||
|
ciprefix("inoise", data->namelist[i]) ||
|
||||||
|
ciprefix("onoise", data->namelist[i]);
|
||||||
|
|
||||||
SPfrontEnd->OUTpBeginPlot (ckt, ckt->CKTcurJob,
|
SPfrontEnd->OUTpBeginPlot (ckt, ckt->CKTcurJob,
|
||||||
"Integrated Noise",
|
data->squared
|
||||||
|
? "Integrated Noise - V^2 or A^2"
|
||||||
|
: "Integrated Noise",
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
data->numPlots, data->namelist, IF_REAL,
|
data->numPlots, data->namelist, IF_REAL,
|
||||||
&(data->NplotPtr));
|
&(data->NplotPtr));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue