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

📄 dlrxframe.cpp

📁 在vc上做的802.16d ofdm phy的仿真
💻 CPP
字号:
#include "sample.h"
#include "dlRxDemod.h"
#include "RxPreamble.h"
#include "dlRxChTrackComp.h"
#include "dlRxChTrackCompStc.h"

#include "channelDecoding.h"

#include "typedef.h"
#include "global_var.h"
#include "globalMacro.h"

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

void dlRxFrame()
{
	int i;
	Uint16 g_dlRxFrameSymSize;
	Uint16  rxModIndex = 0;
	Int16 tempBuff0[DL_RX_BUFF_SIZE];
	Int16 tempBuff1[DL_RX_BUFF_SIZE];
	
	DlRxBurstParam *pRxBurstParam;
	Int16   *pChTrackCompOutBuff;
	
	pRxBurstParam = g_dlRxBurstParam;
	pChTrackCompOutBuff = g_dlRxStcDecodeOutBuff;

	g_dlRxFrameSymSize = g_ssDlFrameParam.frameDurationSym;
	g_dlRxStcFlag = 0;
	g_dlTxFrameSymIndex = 0;

	ofstream out1;

	ifstream fin0("temp\\channelout0.txt");
	
	ifstream fin1("temp\\channelout1.txt");
	
	//rx
	while(rxModIndex < NUM_OF_SYMBOL)
	{
		if ((*pRxBurstParam).burstFlag == STCFCH_BURSTFLAG
			|| (*pRxBurstParam).burstFlag == STC_BURSTFLAG)
		{
	
			if ((*pRxBurstParam).burstFlag == STCFCH_BURSTFLAG 
				&& (*pRxBurstParam).ofdmSymIndex == 0)
			{
				for (i = 0 ; i < 1280; i++)
				{
					fin0 >> g_dlTxInterpOutBuff0[i];
					fin1 >> g_dlTxInterpOutBuff1[i];
				}
			
				sample (g_dlTxInterpOutBuff0, DL_TX_INTERP_OUTBUFF_SIZE/2, INTERP_RATE, tempBuff0);

				sample (g_dlTxInterpOutBuff1, DL_TX_INTERP_OUTBUFF_SIZE/2, INTERP_RATE, tempBuff1);
					
				for (i = 0; i < DL_RX_BUFF_SIZE; i++)
				{
					g_dlRxBuff[i] = tempBuff0[i] + tempBuff1[i];
				}
				
				dlRxDemod();
				/*
				
				out1.open("temp\\rxstcpreamble.txt");
				for (i = 0; i < 512; i ++)
				{
					out1 << setw(10) << g_dlRxFftOutBuff[i];
				}
				out1.close();
				*/
				
				g_chEstMode = PREAMBLE_STC;

				pdlPreambleChEstRes = g_dlPreambleChEstResStc;
			
				dlRxPreamble();
				/*
				out1.open("temp\\ChEstOutStc0.txt");
				for (i = 0; i < 2 * PREAMBLE_FREQ_FULL_SIZE; i++)
				{
					out1 << setw(10) << g_dlRxPreambleChEstRes[0].ChEstOut[i];
				}
				out1.close();
				
				out1.open("temp\\ChEstOutStc1.txt");
				for (i = 0; i < 2 * PREAMBLE_FREQ_FULL_SIZE; i++)
				{
					out1 << setw(10) << g_dlRxPreambleChEstRes[1].ChEstOut[i];

				}
				out1.close();
				*/
				g_dlRxFrameSymIndex ++;
				
				(*pRxBurstParam).ofdmSymIndex ++;			
			}
			else
			{
				for (i = 0 ; i < 1280; i++)
				{
					fin0 >> g_dlTxInterpOutBuff0[i];
					fin1 >> g_dlTxInterpOutBuff1[i];
				}
			
				sample (g_dlTxInterpOutBuff0, DL_TX_INTERP_OUTBUFF_SIZE/2, INTERP_RATE, tempBuff0);

				sample (g_dlTxInterpOutBuff1, DL_TX_INTERP_OUTBUFF_SIZE/2, INTERP_RATE, tempBuff1);
					
				for (i = 0; i < DL_RX_BUFF_SIZE; i++)
				{
					g_dlRxBuff[i] = tempBuff0[i] + tempBuff1[i];
				}
				
				if (g_dlRxStcFlag == 0)
				{

					dlRxDemod();
					
					g_dlRxStcFlag ^= 1;
					
				}
				
				else
				{
					
					dlRxDemod();
				
				    dlRxChTrackCompStc();
				    
				    g_dlRxStcFlag ^= 1;
				    /*
				    out1.open("temp\\rxchomp.txt",ios::app);
					for (i = 0; i < 2*402; i ++)
					{
						out1 << setw(8) << g_dlRxStcDecodeOutBuff[i];
					}
					out1.close();
					*/
					channelDecoding (pRxBurstParam, pChTrackCompOutBuff);
					
					g_dlRxFrameSymIndex ++;
					(*pRxBurstParam).ofdmSymIndex ++;

					if ((*pRxBurstParam).ofdmSymIndex == (*pRxBurstParam).burstSizeSym
						&& g_dlRxBurstIndex < g_ssDlFrameParam.burstNum - 1)
					{
						pRxBurstParam ++;
						g_dlRxBurstIndex ++;
					}
					//channel decode the next symbol 
					channelDecoding (pRxBurstParam, pChTrackCompOutBuff + 402);
					
					g_dlRxFrameSymIndex ++;
					(*pRxBurstParam).ofdmSymIndex ++;

					if ((*pRxBurstParam).ofdmSymIndex == (*pRxBurstParam).burstSizeSym
						&& g_dlRxBurstIndex < g_ssDlFrameParam.burstNum - 1)
					{
						pRxBurstParam ++;
						g_dlRxBurstIndex ++;
					}
					
				}			
			}	
		}
		else
		{
			for (i = 0 ; i < 1280; i++)
			{
				fin0 >> g_dlTxInterpOutBuff0[i];
			}

			sample (g_dlTxInterpOutBuff0, DL_TX_INTERP_OUTBUFF_SIZE/2, INTERP_RATE, g_dlRxBuff);

			dlRxDemod();

			if ((*pRxBurstParam).preambleFlag != NO_PREAMBLE 
				&& (*pRxBurstParam).ofdmSymIndex < 2)
			{
				if ((*pRxBurstParam).ofdmSymIndex == 0)
				{
					g_chEstMode = LONGPREAMBLE_64;

					pdlPreambleChEstRes = &g_dlPreambleChEstRes64;
				}
				else
				{
					g_chEstMode = LONGPREAMBLE_128;

					pdlPreambleChEstRes = &g_dlPreambleChEstRes128;

				}	
				dlRxPreamble();
				
				out1.open("temp\\ChEstOut.txt");
				for (i = 0; i < 2 * PREAMBLE_FREQ_FULL_SIZE; i++)
				{
					out1 << setw(8) << g_dlRxPreambleChEstRes[0].ChEstOut[i];
				}
				out1.close();
				/*
				out1.open("temp\\SignalandNoise.txt");
		
				out1 << "rxsignal =" << g_dlRxPreambleChEstRes[0].rxSignalPower << endl;

				out1 << "rxnoise =" << g_dlRxPreambleChEstRes[0].rxNoisePower << endl;

				out1.close();
				*/
			}
			else
			{
				/*
				out1.open("temp\\rxdata.txt",ios::app);
				for (i = 0; i < 402; i ++)
				{
					out1 << setw(10) << g_dlRxFftOutBuff[i+56];
				}
				out1.close();
				*/
				dlRxChTrackComp();
				/*
				out1.open("temp\\rxchomp.txt",ios::app);
				for (i = 0; i < 2 * PREAMBLE_FREQ_FULL_SIZE; i++)
				{
					out1 << setw(10) << g_dlRxChCompOutBuff[i];
				}
				out1.close();
				*/
				channelDecoding (pRxBurstParam, g_dlRxChCompOutBuff);
				
			}
			g_dlRxFrameSymIndex ++;
			(*pRxBurstParam).ofdmSymIndex ++;

/*			if ((*pRxBurstParam).ofdmSymIndex == (*pRxBurstParam).burstSizeSym
				&& g_dlRxBurstIndex < g_ssDlFrameParam.burstNum - 1)
			{
				pRxBurstParam ++;
				g_dlRxBurstIndex ++;
			}
			*/
		}
		rxModIndex ++;
		
	}
	fin0.close();
	fin1.close();

}
	

⌨️ 快捷键说明

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