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

📄 modmapper.c

📁 OFDMA 物理层开发的matlab 源码.飞思卡尔提供.对物理层开发的工程师有帮助!
💻 C
字号:
/* ============================================================================
   Property of Freescale
   Freescale Confidential Proprietary
   Freescale Copyright (C) 2005 All rights reserved
   ----------------------------------------------------------------------------
   $RCSfile: ModMapper.c.rca $
   Tag $Name:  $
   $Revision: 1.1 $
   $Date: Fri Nov  3 17:33:10 2006 $
   Target Processor: Matlab
============================================================================ */

#include <stdlib.h>
#include <math.h>
#include "mex.h"
//#include "SBX_UP_common.h"
#include "SBX_UPDLSPK_ModMap.c"
#undef _ENTERPRISE_C_
#include "prototype.c"
#include "math_funcs.c"
#include "ModMapLUT_15bit.c"

// Input Arguments (not all might be used)
#define	X1_IN	prhs[0]
#define	X2_IN	prhs[1]
#define	X3_IN	prhs[2]
#define	X4_IN	prhs[3]
#define	X5_IN	prhs[4]

// Output Arguments (not all might be used)
#define	Y1_OUT	plhs[0]
//#define	Y2_OUT	plhs[1]



/*
 *function [output] = mModMapper(input,BlkSize,mode,res,Boosting)
 *
 * signed long SBX_UPDLSPK_ModMap(
                unsigned char *paucIn,
                signed short  *pasiOut,
                unsigned long uliInLen,
                t_eModType    eModType,
                signed short  *pasiLUT)
 */

void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
    
    /* Matlab input dimensions (not all might be used) */
    unsigned long mx1,nx1;
    unsigned long mx2,nx2;
    unsigned long mx3,nx3;
    unsigned long mx4,nx4;
    unsigned long mx5,nx5;
    
    /* Matlab output dimensions (not all might be used) */
    unsigned long my1,ny1;
    //unsigned long my2,ny2;
    
    
    //Others
    double *temp4,*temp5,*temp7,*temp8;
    unsigned char *X1,*temp1;
    unsigned long X3;
    t_eModType X4;
    signed short *X5;
    signed short *Y1;
    int i,status,k;
    signed short *pasiLUT;
    unsigned char  gucBoostFactor;
    
    
    /* Check for proper number of arguments */
    if ( nrhs!=5 ) {mexErrMsgTxt("Error: 5 input arguments required.");}
    else if (nlhs !=1 ) {mexErrMsgTxt("Error: 1 output argument required.");}
    
    /* Check the input format */
    if ( !mxIsLogical(X1_IN) || mxIsComplex(X1_IN)) {mexErrMsgTxt("Error: input 1 must be real of class 'logical'.");}
    if ( !mxIsDouble(X2_IN) || mxIsComplex(X2_IN) ) {mexErrMsgTxt("Error: input 2 must be real of class 'double'.");}
    if ( !mxIsDouble(X3_IN) || mxIsComplex(X3_IN))  {mexErrMsgTxt("Error: input 3 must be real of class 'double'.");}
    if ( !mxIsDouble(X4_IN) || mxIsComplex(X4_IN))  {mexErrMsgTxt("Error: input 4 must be real of class 'double'.");}
    if ( !mxIsDouble(X5_IN) || mxIsComplex(X5_IN))  {mexErrMsgTxt("Error: input 5 must be real of class 'double'.");}
    
    /* get input dimensions (not all might be used) */
    mx1=mxGetM(X1_IN); nx1=mxGetN(X1_IN);
    mx2=mxGetM(X2_IN); nx2=mxGetN(X2_IN);
    mx3=mxGetM(X3_IN); nx3=mxGetN(X3_IN);
    mx4=mxGetM(X4_IN); nx4=mxGetN(X4_IN);
    mx5=mxGetM(X5_IN); nx5=mxGetN(X5_IN);
    
    //check input dimensions
    if ( mx2!=1 || nx2!=1 ) {mexErrMsgTxt("Error: input 2 must be a 1x1 matrix.");}
    if ( mx3!=1 || nx3!=1 ) {mexErrMsgTxt("Error: input 3 must be a 1x1 matrix.");}
    if ( mx4!=1 || nx4!=1 ) {mexErrMsgTxt("Error: input 4 must be a 1x1 matrix.");}
    if ( mx5!=1 || nx5!=1 ) {mexErrMsgTxt("Error: input 5 must be a 1x1 matrix.");}
    
    /* collect data : initialise temp 1*/
    temp1   = (unsigned char*)mxGetPr(X1_IN);
    X1 = mxMalloc(sizeof(unsigned char*)*mx1*1); //col by col
    
    /* collect data : X3*/
    X3 = (unsigned long int) (mx1*1);
    
    /* collect data : X4*/
    temp4 = (double*)mxGetPr(X3_IN);
    X4 = (t_eModType) (temp4[0]);
    
    // Define proper LUT, Collect X5
    temp5 = (double*)mxGetPr(X5_IN);
    gucBoostFactor = (unsigned char) temp5[0];
    if (X4 == M_QPSK)  {pasiLUT = (signed short *)gasiModMapExt[gucBoostFactor];}
    else if (X4 == M_16QAM) {pasiLUT = (signed short *)gasiModMapExt[gucBoostFactor] + SIZE_QPSK_LUT;}
    else {pasiLUT = (signed short *)gasiModMapExt[gucBoostFactor] + SIZE_QPSK_LUT + SIZE_16QAM_LUT;}

    // outputs initialisation
    // Define Y1 //col by col as well
        my1=(mx1*1)/( (int) X4 );     ny1=nx1;
    Y1 = mxMalloc(sizeof(signed short*)*my1*2);
    Y1_OUT = mxCreateNumericMatrix(my1, ny1, mxDOUBLE_CLASS, mxCOMPLEX);
    temp7 = (double*)mxGetPr(Y1_OUT);   temp8 = (double*)mxGetPi(Y1_OUT);
    
    // loop over columns
    for(k=0;k<(nx1);k++)
    {
        for(i=0;i<mx1;i++)  {  X1[i] = (unsigned char) temp1[i+mx1*k] ; }
       
        // Call C function
        status=SBX_UPDLSPK_ModMap(X1,Y1,X3,X4,pasiLUT);
                
        // outputs collection
        for(i=0;i<my1;i++)
        {   temp7[i+my1*k] = (double)  Y1[2*i]; //
        temp8[i+my1*k] = (double)  Y1[2*i+1];}
        
    }
    
    // Deallocate Data
    mxFree(X1); mxFree(Y1);
    
    return;
}


⌨️ 快捷键说明

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