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

📄 rxdemodulator.c

📁 MIMO 2x2接收端选择全系统仿真代码
💻 C
字号:
/*****************************************************************************
  Module     : Demodulator
******************************************************************************

  Function   : 

  Procedures : none

  Author     : $Author: Adrian $

  Revision   : $Revision: 8 $

  Modified   : $Modtime: 05-05-27 18:29 $

  File       : $Workfile: rxdemodulator.c $

******************************************************************************
 KTH, Royal Institute of Technology, S3, Stockholm
*****************************************************************************/

/*--- Include files --------------------------------------------------------*/

/* import */
#include "rxinit.h"
//#include <std.h>
#include <string.h>
//#include <math.h>
//#include <csl_stdinc.h>
#include <dspf_sp_fir_gen.h>

/* export */
#include "rxdemodulator.h"


/*=== End of include files =================================================*/


/*--- Global variables definition ------------------------------------------*/

typRX_MFDEMODSTATE MFDemodStat1;
typRX_MFDEMODSTATE MFDemodStat2;

/*=== End of global variables definition ===================================*/


/*--- Global constants definition ------------------------------------------*/

//extern int SyncState->iSyncIndex;
//iSyncIndex;
 
/*=== End of global constants definition ===================================*/


/*--- Local defines --------------------------------------------------------*/
/*=== End of local defines =================================================*/


/*--- Local types declaration ----------------------------------------------*/
/*=== End of local types declaration =======================================*/


/*--- Local variables definition -------------------------------------------*/
/*=== End of local variables definition ====================================*/


/*--- Local constants definition -------------------------------------------*/

/*static const float hfilt[MFFILTLEN]={
-1.326317299913e-02f, -1.587012564507e-02f, -1.674415963467e-02f, -1.552379037950e-02f, -1.207384207562e-02f, 
-6.530498290477e-03f, 6.827876599095e-04f, 8.873440131166e-03f, 1.713318251174e-02f, 2.442381052974e-02f, 
2.968828760708e-02f, 3.197654640544e-02f, 3.057277541973e-02f, 2.510971402739e-02f, 1.565580495773e-02f, 
2.763018660282e-03f, -1.253335896622e-02f, -2.876700524936e-02f, -4.414351803653e-02f, -5.668707693111e-02f, 
-6.441869232707e-02f, -6.554982151897e-02f, -5.867256335808e-02f, -4.292696016243e-02f, -1.812729001269e-02f, 
1.516744324445e-02f, 5.564860708042e-02f, 1.013221966660e-01f, 1.496390292044e-01f, 1.976809832637e-01f, 
2.423875467836e-01f, 2.808025543624e-01f, 3.103185589064e-01f, 3.288960816721e-01f, 3.352370707970e-01f, 
3.288960816721e-01f, 3.103185589064e-01f, 2.808025543624e-01f, 2.423875467836e-01f, 1.976809832637e-01f, 
1.496390292044e-01f, 1.013221966660e-01f, 5.564860708042e-02f, 1.516744324445e-02f, -1.812729001269e-02f, 
-4.292696016243e-02f, -5.867256335808e-02f, -6.554982151897e-02f, -6.441869232707e-02f, -5.668707693111e-02f, 
-4.414351803653e-02f, -2.876700524936e-02f, -1.253335896622e-02f, 2.763018660282e-03f, 1.565580495773e-02f, 
2.510971402739e-02f, 3.057277541973e-02f, 3.197654640544e-02f, 2.968828760708e-02f, 2.442381052974e-02f, 
1.713318251174e-02f, 8.873440131166e-03f, 6.827876599095e-04f, -6.530498290477e-03f, -1.207384207562e-02f, 
-1.552379037950e-02f
};*/


#pragma DATA_ALIGN(hfilt,8);
static const float hfilt[MFFILTLEN]={
-1.207384207562e-02f, -6.530498290477e-03f, 6.827876599095e-04f, 8.873440131166e-03f, 1.713318251174e-02f, 
2.442381052974e-02f, 2.968828760708e-02f, 3.197654640544e-02f, 3.057277541973e-02f, 2.510971402739e-02f, 
1.565580495773e-02f, 2.763018660282e-03f, -1.253335896622e-02f, -2.876700524936e-02f, -4.414351803653e-02f, 
-5.668707693111e-02f, -6.441869232707e-02f, -6.554982151897e-02f, -5.867256335808e-02f, -4.292696016243e-02f, 
-1.812729001269e-02f, 1.516744324445e-02f, 5.564860708042e-02f, 1.013221966660e-01f, 1.496390292044e-01f, 
1.976809832637e-01f, 2.423875467836e-01f, 2.808025543624e-01f, 3.103185589064e-01f, 3.288960816721e-01f, 
3.352370707970e-01f, 3.288960816721e-01f, 3.103185589064e-01f, 2.808025543624e-01f, 2.423875467836e-01f, 
1.976809832637e-01f, 1.496390292044e-01f, 1.013221966660e-01f, 5.564860708042e-02f, 1.516744324445e-02f, 
-1.812729001269e-02f, -4.292696016243e-02f, -5.867256335808e-02f, -6.554982151897e-02f, -6.441869232707e-02f, 
-5.668707693111e-02f, -4.414351803653e-02f, -2.876700524936e-02f, -1.253335896622e-02f, 2.763018660282e-03f, 
1.565580495773e-02f, 2.510971402739e-02f, 3.057277541973e-02f, 3.197654640544e-02f, 2.968828760708e-02f, 
2.442381052974e-02f, 1.713318251174e-02f, 8.873440131166e-03f, 6.827876599095e-04f, -6.530498290477e-03f, 
-1.207384207562e-02f
};


/*=== End of local constants definition ====================================*/


/*--- Local functions definition -------------------------------------------*/
/*=== End of local functions definition ====================================*/


/*--- Global functions definition ------------------------------------------*/

/****************************************************************************
  Function   : matchedFilter
 ****************************************************************************

  Description : Inverse pulse shaping of the received signal

  Inputs      : The downconverted signal

  Outputs     : The inverse pulse shaped signal

  By          : 2005-05-17 Created by Anders Lindgren
  				2005-05-17 modified by Anders Lindgren

 ****************************************************************************/
void matchedFilter(typRX_MFDEMODSTATE *pDemodState)
{
	//int n;		
	float *pI_InBuffer = pDemodState->pCplxInBuff->pIBuffer; 
	float *pQ_InBuffer = pDemodState->pCplxInBuff->pQBuffer;
	float *pI_OutBuffer = pDemodState->pfCplxOutBuff->pIBuffer;
	float *pQ_OutBuffer = pDemodState->pfCplxOutBuff->pQBuffer;
	
	// filter Inphase part
	DSPF_sp_fir_gen(pI_InBuffer, hfilt, pI_OutBuffer, MFFILTLEN, pDemodState->uiRcvSigLen);
	// save the last values for overlap-save method
	memmove(pI_InBuffer, &pI_InBuffer[pDemodState->uiRcvSigLen], (MFFILTLEN-1)*sizeof(float));
	
	//pQ_InBuffer = pDemodState->pCplxBuff->pQBuffer;

	// filter Quadrature part
	DSPF_sp_fir_gen(pQ_InBuffer, hfilt, pQ_OutBuffer, MFFILTLEN, pDemodState->uiRcvSigLen);
	//save the last values for overlap-save method
	memmove(pQ_InBuffer, &pQ_InBuffer[pDemodState->uiRcvSigLen], (MFFILTLEN-1)*sizeof(float));

	pDemodState->uiSamplesProcessed += pDemodState->uiRcvSigLen;
}


/****************************************************************************
  Function   : downsampling
 ****************************************************************************

  Description : Downsampling of the matched filtered signal 

  Inputs      : The matched filtered signal

  Outputs     : The downsampled signal

  By          : 2005-05-17 Created by Anders Lindgren
  				2005-05-17 modified by Anders Lindgren

 ****************************************************************************/
void downsampling(typRX_MFDEMODSTATE *pDemodState)
{
// read from:
//  pDemodState->pfCplxOutBuff->pIBuffer, pDemodState->pfCplxOutBuff->pQBuffer
// put the sample in:
//  pDemodState->pfCplxSymbBuff->pIBuffer, pDemodState->pfCplxSymbBuff->pQBuffer
//	int i;
	//int startindex = SyncState->iSyncIndex;
	
	//i = pDemodState->iStartIndex;
	while (pDemodState->iStartIndex < pDemodState->uiRcvSigLen)
	{
		pDemodState->pfCplxSymbBuff->pIBuffer[pDemodState->uiNextWriteSymb] = pDemodState->pfCplxOutBuff->pIBuffer[pDemodState->iStartIndex];
		pDemodState->pfCplxSymbBuff->pQBuffer[pDemodState->uiNextWriteSymb] = pDemodState->pfCplxOutBuff->pQBuffer[pDemodState->iStartIndex];
	
		pDemodState->uiNextWriteSymb++;
		pDemodState->uiNextWriteSymb %= pDemodState->uibuflen;
		pDemodState->uiNoOfSymb++;
		pDemodState->iStartIndex += OVERSAMPLING;
	}
	pDemodState->iStartIndex -= pDemodState->uiRcvSigLen;

	//pDemodState->uiNextWriteSamp = pDemodState->uiNextWriteSamp + OVERSAMPLING;
		
}

/*=== End of global functions definition ===================================*/

/*--- AUTOMATICALLY GENERATED VERSION HISTORY --------------------------------

$Log: /MIMO/Receiver/rxdemodulator.c $ 
 * 
 * 8     05-05-27 20:45 Adrian
 * modified it to use a circular symbol buffer
 * 
 * 7     05-05-25 12:13 Anders
 * The demodulator is finished and checked with matlab.
 * 
 * 6     05-05-24 20:47 Anders
 * The function DSPF_sp_fir_gen() working well with matlab. Still have to
 * check that memmove and downsampling generate correct results.
 * 
 * 5     05-05-24 12:22 Anders
 * Changed the name of the demodulation function to downsampling.
 * uiRcvSigLen now indicates how many samples are available in I and Q
 * each.
 * 
 * 4     05-05-20 19:37 Anders
 * Finished but not tested
 * 
 * 1     05-05-11 17:00 Adrian
 * created and added to VSS

===== END OF AUTOMATICALLY GENERATED VERSION HISTORY =======================*/

/**** End of file ***********************************************************/

⌨️ 快捷键说明

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