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" } ,
|
||||
{ "voltage-density", "V/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 } ,
|
||||
{ "zero", NULL } ,
|
||||
{ "s-param", NULL } ,
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ typedef struct {
|
|||
char *squared_value;
|
||||
runDesc *NplotPtr; /* the plot pointer */
|
||||
IFuid *namelist; /* list of plot names */
|
||||
unsigned squared : 1;
|
||||
} Ndata;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ enum simulation_types {
|
|||
SV_CURRENT,
|
||||
SV_VOLTAGE_DENSITY,
|
||||
SV_CURRENT_DENSITY,
|
||||
SV_SQR_VOLTAGE_DENSITY,
|
||||
SV_SQR_CURRENT_DENSITY,
|
||||
SV_SQR_VOLTAGE,
|
||||
SV_SQR_CURRENT,
|
||||
SV_POLE,
|
||||
SV_ZERO,
|
||||
SV_SPARAM,
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ CKTnoise (CKTcircuit *ckt, int mode, int operation, Ndata *data)
|
|||
data->outpVector =
|
||||
TMALLOC(double, data->numPlots);
|
||||
data->squared_value =
|
||||
TMALLOC(char, data->numPlots);
|
||||
data->squared ? NULL : TMALLOC(char, data->numPlots);
|
||||
break;
|
||||
|
||||
case INT_NOIZ:
|
||||
|
|
@ -85,7 +85,7 @@ CKTnoise (CKTcircuit *ckt, int mode, int operation, Ndata *data)
|
|||
data->outpVector =
|
||||
TMALLOC(double, data->numPlots);
|
||||
data->squared_value =
|
||||
TMALLOC(char, data->numPlots);
|
||||
data->squared ? NULL : TMALLOC(char, data->numPlots);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -107,9 +107,10 @@ CKTnoise (CKTcircuit *ckt, int mode, int operation, Ndata *data)
|
|||
(outNdens * data->GainSqInv);
|
||||
|
||||
refVal.rValue = data->freq; /* the reference is the freq */
|
||||
for (i = 0; i < data->outNumber; i++)
|
||||
if (data->squared_value[i])
|
||||
data->outpVector[i] = sqrt(data->outpVector[i]);
|
||||
if (!data->squared)
|
||||
for (i = 0; i < data->outNumber; i++)
|
||||
if (data->squared_value[i])
|
||||
data->outpVector[i] = sqrt(data->outpVector[i]);
|
||||
outData.v.numValue = data->outNumber; /* vector number */
|
||||
outData.v.vec.rVec = data->outpVector; /* vector of outputs */
|
||||
SPfrontEnd->OUTpData (data->NplotPtr, &refVal, &outData);
|
||||
|
|
@ -119,9 +120,10 @@ CKTnoise (CKTcircuit *ckt, int mode, int operation, Ndata *data)
|
|||
case INT_NOIZ:
|
||||
data->outpVector[data->outNumber++] = data->outNoiz;
|
||||
data->outpVector[data->outNumber++] = data->inNoise;
|
||||
for (i = 0; i < data->outNumber; i++)
|
||||
if (data->squared_value[i])
|
||||
data->outpVector[i] = sqrt(data->outpVector[i]);
|
||||
if (!data->squared)
|
||||
for (i = 0; i < data->outNumber; i++)
|
||||
if (data->squared_value[i])
|
||||
data->outpVector[i] = sqrt(data->outpVector[i]);
|
||||
outData.v.vec.rVec = data->outpVector; /* vector of outputs */
|
||||
outData.v.numValue = data->outNumber; /* vector number */
|
||||
SPfrontEnd->OUTpData (data->NplotPtr, &refVal, &outData);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ Modified: 2001 AlansFixes
|
|||
#include "ngspice/acdefs.h"
|
||||
#include "ngspice/cktdefs.h"
|
||||
#include "ngspice/iferrmsg.h"
|
||||
#include "ngspice/cpextern.h"
|
||||
#include "ngspice/noisedef.h"
|
||||
#include "ngspice/sperror.h"
|
||||
#include "ngspice/sim.h"
|
||||
|
|
@ -122,6 +123,7 @@ NOISEan (CKTcircuit *ckt, int restart)
|
|||
data->freq = job->NstartFreq;
|
||||
data->outNoiz = 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
|
||||
declared before an OUTpBeginplot */
|
||||
|
|
@ -138,19 +140,26 @@ NOISEan (CKTcircuit *ckt, int restart)
|
|||
*/
|
||||
|
||||
if (src_type == SV_VOLTAGE)
|
||||
fixme_inoise_type = SV_VOLTAGE_DENSITY;
|
||||
fixme_inoise_type =
|
||||
data->squared ? SV_SQR_VOLTAGE_DENSITY : SV_VOLTAGE_DENSITY;
|
||||
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++)
|
||||
data->squared_value[i] =
|
||||
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]);
|
||||
|
||||
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,
|
||||
data->numPlots, data->namelist, IF_REAL,
|
||||
&(data->NplotPtr));
|
||||
|
|
@ -296,16 +305,26 @@ NOISEan (CKTcircuit *ckt, int restart)
|
|||
|
||||
if (error) return(error);
|
||||
|
||||
fixme_inoise_type = src_type;
|
||||
fixme_onoise_type = SV_VOLTAGE;
|
||||
if (src_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++)
|
||||
data->squared_value[i] =
|
||||
ciprefix("inoise", data->namelist[i]) ||
|
||||
ciprefix("onoise", data->namelist[i]);
|
||||
fixme_onoise_type =
|
||||
data->squared ? SV_SQR_VOLTAGE : SV_VOLTAGE;
|
||||
|
||||
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,
|
||||
"Integrated Noise",
|
||||
data->squared
|
||||
? "Integrated Noise - V^2 or A^2"
|
||||
: "Integrated Noise",
|
||||
NULL, 0,
|
||||
data->numPlots, data->namelist, IF_REAL,
|
||||
&(data->NplotPtr));
|
||||
|
|
|
|||
Loading…
Reference in New Issue