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

📄 dltxburstdata.cpp

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

//#include "simuInit.h"
#include "genBinData.h"
#include "randomization.h"
#include "rsEncoding.h"
#include "dlCcEncoding.h"
#include "interleaving.h"
#include "dataModulation.h"

#include <fstream.h>
#include <iomanip.h>



/******************************************************
********************************************************/
void dlTxBurstData(DlTxBurstParam *pDlTxBurstParam) 
{
	Int16 *pTxModulationOutBuff0;
	Int16 *pTxModulationOutBuff1;
	pTxModulationOutBuff0 = g_dlTxModulationOutBuff;
	pTxModulationOutBuff1 = g_dlTxModulationOutBuff + 2 * FFT_SIZE;
    OfdmSymbolParam *pDlOfdmSymbolParam;
	
//	Uint16  pRandV;
	Uint16  randomizationInLength;
	Uint16  rsParityBytes;
	Uint16  rsEncodingOutLength;
	Uint8	ccRate;
	Uint16  ccEncodingOutLength;
	Uint16  Ncbps;
	Uint8	Ncpc;
//	Uint8   pStateReg = 0;
	Uint8	modulationType;
	Uint8   subChannelIndex;

	int i;
	PilotParam *pilot;
	pilot = &g_dlTxPilotParam;
	subChannelIndex = (*pDlTxBurstParam).subChannelIndex;

	ofstream out;
	if (subChannelIndex == 16)
	{ 
		if ((*pDlTxBurstParam).burstFlag == FCH_BURSTFLAG
			|| (*pDlTxBurstParam).burstFlag == BURSTONE_BURSTFLAG)
		{
			if ((*pDlTxBurstParam).burstIndex == 0)
			{
				pDlOfdmSymbolParam = &g_bsDlFchOfdmSymbolParam;
				randomizationInLength = (*pDlOfdmSymbolParam).uncodedBlockSize;
				rsParityBytes = (*pDlOfdmSymbolParam).rsParityBytes;
				rsEncodingOutLength = randomizationInLength + rsParityBytes;
				ccRate = (*pDlOfdmSymbolParam).ccRate;
				ccEncodingOutLength = 8 * (*pDlOfdmSymbolParam).codedBlockSize;
				Ncbps = 16 * (*pDlOfdmSymbolParam).ncbpss;
				Ncpc = (*pDlOfdmSymbolParam).ncpc;
				modulationType = (*pDlOfdmSymbolParam).modulation;
				
			}
			else
			{
				if ((*pDlTxBurstParam).burstIndex == 1)
				{
					pDlOfdmSymbolParam = g_bsDlFirstBurstOfdmSymbolParam;
					randomizationInLength = pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].uncodedBlockSize;
					rsParityBytes = pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].rsParityBytes;
					rsEncodingOutLength = randomizationInLength + rsParityBytes;
					ccRate = pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].ccRate;
					ccEncodingOutLength = 8 * pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].codedBlockSize;
					Ncbps = 16 * pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].ncbpss;
					Ncpc = pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].ncpc;
					modulationType = pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].modulation;
				}
				else
				{
					pDlOfdmSymbolParam = g_bsDlOfdmSymbolParam;
					randomizationInLength = pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].uncodedBlockSize;
					rsParityBytes = pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].rsParityBytes;
					rsEncodingOutLength = randomizationInLength + rsParityBytes;
					ccRate = pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].ccRate;
					ccEncodingOutLength = 8 * pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].codedBlockSize;
					Ncbps = 16 * pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].ncbpss;
					Ncpc = pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].ncpc;
					modulationType = pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].modulation;
				
				}
			}	
			if ((*pDlTxBurstParam).burstSymIndex == (*pDlTxBurstParam).burstSizeSym - 1)
			{
				genBinData(g_dlTxInBuff, (randomizationInLength - 1));
				/*
				out.open("temp\\putin.txt",ios::app);

				for (i = 0; i < randomizationInLength - 1; i++)
				{
					out << setw(8) << (Int16)g_dlTxInBuff[i];
					if ((i + 1) % 8 == 0)
					{
						out << endl;
					}
				}
				out << setw(8) << "0";

				out.close();
				*/
				randomization (0,
							   pDlTxBurstParam,
							   g_dlTxBurstIndex, 
							   g_dlTxInBuff, 
							   randomizationInLength - 1, 
							   &g_dlTxRandVector, 
							   g_dlTxRandOutBuff);

				g_dlTxRandOutBuff[randomizationInLength-1] = 0;
			//the burst has only one ofdm symbol;
			//0X00tail byte is appended to the end of the burst
			}
			else
			{
				genBinData(g_dlTxInBuff, randomizationInLength);
				/*
				out.open("temp\\putin.txt",ios::app);

				for (i = 0; i < randomizationInLength; i++)
				{
					out << setw(8) << (Int16)g_dlTxInBuff[i];
					if ((i + 1) % 8 == 0)
					{
						out << endl;
					}
					
				}
				//out << endl;

				out.close();
				*/
				randomization (0,
							   pDlTxBurstParam,
							   g_dlTxBurstIndex, 
							   g_dlTxInBuff, 
							   randomizationInLength, 
							   &g_dlTxRandVector, 
							   g_dlTxRandOutBuff);
			}

			(*pDlTxBurstParam).status = NOFEC_DONE;

			rsEncoding (g_dlTxRandOutBuff,
						randomizationInLength,
						rsParityBytes,
						g_dlTxRsOutBuff,
						rsEncodingOutLength);

			(*pDlTxBurstParam).status= RSENCODE_DONE;
	
			dlCcEncoding (0,
						  g_dlTxRsOutBuff,
						  rsEncodingOutLength,
						  ccRate,
						  g_dlTxCcEncodeOutBuff,
						  ccEncodingOutLength,
						  &g_dlTxCcEncodeReg);

			(*pDlTxBurstParam).status= CONVENCODE_DONE;

			interleaving (g_dlTxCcEncodeOutBuff,
						  Ncbps,
						  Ncpc,
						  g_dlTxInterleaveOutBuff);
			(*pDlTxBurstParam).status= INTERLEAVE_DONE;

			out.open("temp\\codeout.txt",ios::app);

			for (i = 0; i < ccEncodingOutLength; i++)
			{
				out << setw(8) << (Int16)g_dlTxInterleaveOutBuff[i];
					
			}

			out.close();

			dataModulation (subChannelIndex,
							g_dlTxInterleaveOutBuff,
							ccEncodingOutLength,
							modulationType,
							g_dlTxScalingParam.qamSymAveAmp,
							pilot,
							pTxModulationOutBuff0,
							FFT_SIZE);

			(*pDlTxBurstParam).status= DATAMOD_DONE;
			/*

			out.open("temp\\txdata.txt",ios::app);

			for (i = 0; i < 402; i++)
			{
				out << setw(8) << pTxModulationOutBuff0[i+56];
			}
			out.close();
			*/

		}
		else 
		{
			if ((*pDlTxBurstParam).burstIndex == g_dlTxStcStartTime.Burst)
			{
				pDlOfdmSymbolParam = &g_bsDlFchOfdmSymbolParam;
				randomizationInLength = (*pDlOfdmSymbolParam).uncodedBlockSize;
				rsParityBytes = (*pDlOfdmSymbolParam).rsParityBytes;
				rsEncodingOutLength = randomizationInLength + rsParityBytes;
				ccRate = (*pDlOfdmSymbolParam).ccRate;
				ccEncodingOutLength = 8 * (*pDlOfdmSymbolParam).codedBlockSize;
				Ncbps = 16 * (*pDlOfdmSymbolParam).ncbpss;
				Ncpc = (*pDlOfdmSymbolParam).ncpc;
				modulationType = (*pDlOfdmSymbolParam).modulation;

			}
			else 
			{
				if ((*pDlTxBurstParam).burstIndex == (g_dlTxStcStartTime.Burst + 1))
				{
					pDlOfdmSymbolParam = g_bsDlFirstBurstOfdmSymbolParam;
					randomizationInLength = pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].uncodedBlockSize;
					rsParityBytes = pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].rsParityBytes;
					rsEncodingOutLength = randomizationInLength + rsParityBytes;
					ccRate = pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].ccRate;
					ccEncodingOutLength = 8 * pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].codedBlockSize;
					Ncbps = 16 * pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].ncbpss;
					Ncpc = pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].ncpc;
					modulationType = pDlOfdmSymbolParam[(*pDlTxBurstParam).rateId].modulation;
				}
				else
				{
					pDlOfdmSymbolParam = g_bsDlOfdmSymbolParam;
					randomizationInLength = pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].uncodedBlockSize;
					rsParityBytes = pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].rsParityBytes;
					rsEncodingOutLength = randomizationInLength + rsParityBytes;
					ccRate = pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].ccRate;
					ccEncodingOutLength = 8 * pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].codedBlockSize;
					Ncbps = 16 * pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].ncbpss;
					Ncpc = pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].ncpc;
					modulationType = pDlOfdmSymbolParam[(*pDlTxBurstParam).diuc].modulation;
				}
			}
			if ((*pDlTxBurstParam).burstSymIndex == (*pDlTxBurstParam).burstSizeSym - 1)
			{
				genBinData(g_dlTxInBuff, (randomizationInLength - 1));
				/*
				out.open("temp\\putin.txt",ios::app);

				for (i = 0; i < randomizationInLength - 1; i++)
				{
					out << setw(8) << (Int16)g_dlTxInBuff[i];
					
				}
				out << setw(8) << "0" ;

				out.close();
				*/
				randomization (0,
							   pDlTxBurstParam,
							   g_dlTxBurstIndex, 
							   g_dlTxInBuff, 
							   randomizationInLength - 1, 
							   &g_dlTxRandVector, 
							   g_dlTxRandOutBuff);

				g_dlTxRandOutBuff[randomizationInLength-1] = 0;
			//the burst has only one ofdm symbol;
			//0X00tail byte is appended to the end of the burst
			}
			else
			{
				genBinData(g_dlTxInBuff, randomizationInLength);
				/*
				out.open("temp\\putin.txt",ios::app);

				for (i = 0; i < randomizationInLength; i++)
				{
					out << setw(8) << (Int16)g_dlTxInBuff[i];
					
				}

				out.close();
			*/
				randomization (0,
							   pDlTxBurstParam,
							   g_dlTxBurstIndex, 
							   g_dlTxInBuff, 
							   randomizationInLength, 
							   &g_dlTxRandVector, 
							   g_dlTxRandOutBuff);
			}

			(*pDlTxBurstParam).status = NOFEC_DONE;

			rsEncoding (g_dlTxRandOutBuff,
						randomizationInLength,
						rsParityBytes,
						g_dlTxRsOutBuff,
						rsEncodingOutLength);

			(*pDlTxBurstParam).status = RSENCODE_DONE;

			dlCcEncoding (0,
						  g_dlTxRsOutBuff,
						  rsEncodingOutLength,
						  ccRate,
						  g_dlTxCcEncodeOutBuff,
						  ccEncodingOutLength,
						  &g_dlTxCcEncodeReg);
			(*pDlTxBurstParam).status = CONVENCODE_DONE;

			interleaving (g_dlTxCcEncodeOutBuff,
						  Ncbps,
						  Ncpc,
						  g_dlTxInterleaveOutBuff);
			(*pDlTxBurstParam).status = INTERLEAVE_DONE;
			
			out.open("temp\\codeout.txt",ios::app);

			for (i = 0; i < ccEncodingOutLength; i++)
			{
				out << setw(8) << (Int16)g_dlTxInterleaveOutBuff[i];
					
			}

			out.close();
			
			if (g_dlTxStcFlag == 0)
			{
				dataModulation (subChannelIndex,
								g_dlTxInterleaveOutBuff,
								ccEncodingOutLength,
								modulationType,
								g_dlTxScalingParam.qamSymAveAmp,
								pilot,
								pTxModulationOutBuff0,
								FFT_SIZE);
				/*
				out.open("temp\\txdata.txt",ios::app);

				for (i = 0; i < 402; i++)
				{
					out << setw(8) << pTxModulationOutBuff0[i+56];
				}
				out.close();
				*/
			}

			else
			{
				dataModulation (subChannelIndex,
								g_dlTxInterleaveOutBuff,
								ccEncodingOutLength,
								modulationType,
								g_dlTxScalingParam.qamSymAveAmp,
								pilot,
								pTxModulationOutBuff1,
								FFT_SIZE);

				/*out.open("temp\\txdata.txt",ios::app);

				for (i = 0; i < 402; i++)
				{
					out << setw(8) << pTxModulationOutBuff1[i+56];
				}
				out.close();
				*/
			}			
			(*pDlTxBurstParam).status= DATAMOD_DONE;	
		}
	}
}

⌨️ 快捷键说明

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