Capsim Block Documentation
Model a nonlinear Power Amplifier specifying 1dB compression, gain and backoff. Complex input/output.
Port | Type | Name | |
---|---|---|---|
0 | complex | inStream |
Port | Type | Name | |
---|---|---|---|
0 | complex | outStream |
Num | Type | Name | Initial Value | Description |
---|---|---|---|---|
0 | float | sumOut | ||
1 | float | aGain | ||
2 | float | bGain | ||
3 | float | cmp | ||
4 | float | rout | ||
5 | float | rin | ||
6 | float | bov | ||
7 | float | rhoInMax | ||
8 | float | rhoOutMax | ||
9 | int | counter |
float rho, pNat,outPowerDBm; complex tmpIn; complex thirdOrder; double tmpRe, tmpIm; double tmpOutRe, tmpOutIm; |
---|
rout = sourceR; rin = sourceR; /* * Calculate voltage gain from power gain */ aGain = (pow(10.0, (G/20.0))); /* * Calculate 1dB compression in voltage from dBm */ cmp = sqrt(pow(10.0, out1dB/10)*2*rout*0.001)/aGain; printf("cmp=%f\n",cmp); /* * Scale input for input backoff */ bov=(pow(10.0, (bo/20.0))); /* * Calculate third order term */ bGain = (0.108749)/(cmp*cmp); /* * Calculate soft-limiting input threshold */ rhoInMax = cmp*s; printf("rhoInMax=%f\n",rhoInMax); /* * Calculate output limiting ceiling */ rhoOutMax = aGain*s*cmp*(1-bGain*pow((cmp*s),2)); printf("rhoOutMax=%f\n",rhoOutMax); counter = 0; sumOut = 0.0; |
---|
while( AVAIL(0) ) { IT_IN(0); counter++; tmpIn = INCX(0,0); tmpIn.re *= bov; tmpIn.im *= bov; rho=sqrt(tmpIn.re*tmpIn.re + tmpIn.im*tmpIn.im); if (rho < rhoInMax) { /* third_order(y) = in(y)*a*(1 - b*in(y)^2); */ tmpRe=tmpIn.re*tmpIn.re -tmpIn.im*tmpIn.im; tmpIm=tmpIn.re*tmpIn.im+tmpIn.re*tmpIn.im; tmpRe = aGain*(1.0 - bGain*tmpRe); tmpIm = aGain*( - bGain*tmpIm); tmpOutRe=tmpIn.re*tmpRe -tmpIn.im*tmpIm; tmpOutIm=tmpIn.re*tmpIm+tmpRe*tmpIn.im; thirdOrder.re = (float) tmpOutRe; thirdOrder.im = (float) tmpOutIm; } else { /* third_order(y) = rhoOutMax*sign(in(y)); */ thirdOrder.re = rhoOutMax * tmpIn.re/rho; thirdOrder.im = rhoOutMax * tmpIn.im/rho; } if (IT_OUT(0)){ KrnOverflow("cxpatx",0); return(99); } OUTCX(0,0) = thirdOrder; /* Estimate Output Power */ sumOut += thirdOrder.re*thirdOrder.re + thirdOrder.im*thirdOrder.im; if(counter == windowLength) { pNat = sumOut/(float)windowLength; outPowerDBm=10*log10(10*pNat); printf("OBO=%f\n",(out1dB - outPowerDBm)); } } |
---|
/* * (c) XCAD Corporation, Portland, Oregon, All Rights Reserved * Acknowledgemnet: Dr. Yoon. */ |
---|