⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dltxmod.cpp

📁 在vc上做的802.16d ofdm phy的仿真
💻 CPP
字号:
#include "fft.h"
#include "dlTxMod.h"
#include "globalMacro.h"
#include "global_var.h"
#include "interpolation.h"

#include "fstream.h"
#include "iomanip.h"


//extern Uint16 g_dlTxFrameSymIndex;	
void	cpInsert (Int16  *pCpInsertIn, 
				  Uint16 cpInsertInLength,
			      Uint8  cpDataRatio,
			      Uint8  outBitwidth,
			      Int16  *pCpInsertOut)
{
	Int16 i,j;
	Uint16 tempSize;
	Int16 *temp;
	Int16 iMaxValue;
	
	iMaxValue = (1 << (outBitwidth - 1)) - 1;
	for (i = 0; i < 2 * cpInsertInLength; i++)
	{
		if (pCpInsertIn[i] >= iMaxValue)
		{
			pCpInsertIn[i] = iMaxValue;
		}
	}

	tempSize = INTERP_RATE * cpDataRatio; //****
	temp = new Int16[2*tempSize];
	for (i = cpInsertInLength - tempSize,j = 0; i < cpInsertInLength; i++,j++)
	{
		temp[2*j] = pCpInsertIn[2*i];
		temp[2*j+1] = pCpInsertIn[2*i+1];
	}
	for (i = 0; i < tempSize; i++)
	{
		pCpInsertOut[2*i] = temp[2*i];
		pCpInsertOut[2*i+1] = temp[2*i+1];
	}
	delete[]temp;
}

void	dlTxMod(void)
{
	int i;
	Int16 *pFDSymbolOne, *pFDSymbolTwo;
	Int16 *pInterpOutOne, *pInterpOutTwo;
	Int16 *pInsertOutOne, *pInsertOutTwo;
	
	Uint16 ifftSize;
	Int16 *pWeight;
	Uint8 weightBitWidth;
	Uint8 iInterplRate;
	Int16 iCPInLength;
	Uint8 iCPDataRatio;
	Uint8 outBitwidth;

	pWeight = fftWeights;
	ifftSize = g_fftSize;
	weightBitWidth = fftWeightBitwidth;
	iInterplRate = INTERP_RATE;
	iCPInLength = ifftSize * iInterplRate;
	iCPDataRatio = g_cpDataRatio; //cp insert ratio
	outBitwidth = 16; 
	
	if (g_dlTxBurstParam[g_dlTxBurstIndex].burstFlag == FCH_BURSTFLAG
		|| g_dlTxBurstParam[g_dlTxBurstIndex].burstFlag == BURSTONE_BURSTFLAG)
	{
		pFDSymbolOne = g_dlTxModulationOutBuff;
		
		iFft (pFDSymbolOne, ifftSize, pWeight, weightBitWidth, g_dlTxIfftOutBuff0);
		
		//右移一位,使ifft输入输出功率一致
		for (i = 0; i < ifftSize; i++)
		{
			g_dlTxIfftOutBuff0[2*i] >>= 1;
			g_dlTxIfftOutBuff0[2*i+1] >>= 1;
		}
		for (i = 1; i < ifftSize; i+=2)
		{
			g_dlTxIfftOutBuff0[2*i] *= -1;
			g_dlTxIfftOutBuff0[2*i+1] *= -1;
		}

		pInterpOutOne = g_dlTxInterpOutBuff0 + iCPDataRatio * iInterplRate* 2;
		
		interpolation (g_dlTxIfftOutBuff0, ifftSize, iInterplRate, pInterpOutOne);

		pInsertOutOne = g_dlTxInterpOutBuff0;

		cpInsert (pInterpOutOne, iCPInLength, iCPDataRatio, 
				  outBitwidth, pInsertOutOne);
		
	}

	else
	{
		pFDSymbolOne = g_dlTxStcOutBuff0;
		pFDSymbolTwo = g_dlTxStcOutBuff1;

		iFft (pFDSymbolOne, ifftSize, pWeight, weightBitWidth, g_dlTxIfftOutBuff0);

		iFft (pFDSymbolTwo, ifftSize, pWeight, weightBitWidth, g_dlTxIfftOutBuff1);

		for (i = 0; i < ifftSize; i++)
		{
			g_dlTxIfftOutBuff0[2*i] >>= 1;
			g_dlTxIfftOutBuff0[2*i+1] >>= 1;
			g_dlTxIfftOutBuff1[2*i] >>= 1;
			g_dlTxIfftOutBuff1[2*i+1] >>= 1;
		}
		
		for (i = 1; i < ifftSize; i+=2)
		{
			g_dlTxIfftOutBuff0[2*i] *= -1;
			g_dlTxIfftOutBuff0[2*i+1] *= -1;
			g_dlTxIfftOutBuff1[2*i] *= -1;
			g_dlTxIfftOutBuff1[2*i+1] *= -1;			
		}

		pInterpOutOne = g_dlTxInterpOutBuff0 + iCPDataRatio * iInterplRate * 2;
		pInterpOutTwo = g_dlTxInterpOutBuff1 + iCPDataRatio * iInterplRate * 2;
		
		interpolation(g_dlTxIfftOutBuff0, ifftSize, iInterplRate, pInterpOutOne);
		interpolation(g_dlTxIfftOutBuff1, ifftSize, iInterplRate, pInterpOutTwo);
		
		pInsertOutOne = g_dlTxInterpOutBuff0;
		pInsertOutTwo = g_dlTxInterpOutBuff1;

		cpInsert (pInterpOutOne, iCPInLength, iCPDataRatio, outBitwidth, pInsertOutOne);
		
		cpInsert (pInterpOutTwo, iCPInLength, iCPDataRatio, outBitwidth, pInsertOutTwo);

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -