cxpatx

Capsim Block Documentation

Short Description

Model a nonlinear Power Amplifier specifying 1dB compression, gain and backoff. Complex input/output.

Top
Input Connections
Port Type Name
0 complex inStream
Top
Output Connections
Port Type Name
0 complex outStream
Top
Parameters
Num Description Type Name Default Value
0 Output 1-db compression point(dBm) float out1dB 25
1 Linear Gain(dB) float G 30
2 Source Impedance float sourceR 50
3 Knee sharpness of limiter float s 1
4 Input Backoff float bo -6
5 Window length for power estimate int windowLength 25
Top
States
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
Top

Declarations


 

  float rho, pNat,outPowerDBm;
  complex tmpIn;
  complex thirdOrder;
  double tmpRe, tmpIm;
  double tmpOutRe, tmpOutIm;



Top

Initialization Code



 

    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;
 



Top

Main Code



 


  
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));
    }

	
}




Top

Wrapup Code



 





Top

License



/*
 * (c) XCAD  Corporation, Portland, Oregon, All Rights Reserved
 * Acknowledgemnet: Dr. Yoon.
 */




Top

Description