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

📄 s_buffer.c

📁 这是一个c++编写的WCDMA链路采用RAKE接收的方针源代码
💻 C
字号:
/* | Project:     WCDMA simulation environment | Module:      This is a test buffer used for utra_lib |              The buffer is implemented only as Simulink |              s_function. This is an alternative to   |              s_frame_buffer.c which utilizes the |              wcdma_symbol_buffer function used  |              in several different occasion in this |              simulator | |  | Author:      Maarit Melvasalo | Date:        May 1999 | | History: |              May 18,  1999 Maarit Melvasalo  |       | |  Abstract: | | USER GIVEN PARAMETERS | | 1: IN_SIZE = Input block size | 2: OUT_SIZE = Ouput block size | 3: B_SIZE = how many times the ouputbuffer size |             a temporary buffer needed    | 4: nSlot = number od slot in a frame (used for sample timing) |  | Inputs: | | |                | Outputs:  | | | DEPENDS ON FILES  |          | | Copyright disclaimer: |   This software was developed at the National Institute of Standards |   and Technology by employees of the Federal Government in the course |   of their official duties. Pursuant to title 17 Section 105 of the |   United States Code this software is not subject to copyright |   protection and is in the public domain. | |   We would appreciate acknowledgement if the software is used. | */ #define S_FUNCTION_NAME s_buffer#define S_FUNCTION_LEVEL 2#include <math.h>#include "simstruc.h"#include "tmwtypes.h"#include "config_wcdma.h"#include "wcdma_simulink.h"/* MAX_CHANNEL_TAPS/**/#define NPARAMS 4#define IN_SIZE(S)  ssGetSFcnParam(S,0)#define in_buff (int_T)(mxGetPr(IN_SIZE(S))[0])#define OUT_SIZE(S)  ssGetSFcnParam(S,1)#define out_buff (int_T)(mxGetPr(OUT_SIZE(S))[0]) /*number of coded bits in frame/**/#define B_SIZE(S)  ssGetSFcnParam(S,2)#define n_buff (int_T)(mxGetPr(B_SIZE(S))[0]) /*how many times size of the outputbuffer is neede/**/#define SLOTS(S)  ssGetSFcnParam(S,3)#define nSlots (int_T)(mxGetPr(SLOTS(S))[0]) #define I(element) (*IPtrs[element])#define Is(element)  (*IsPtrs[element])#define tdI  TD_FRAME / (real_T)nSlots  /*SLOT     /**/#define tdO  TD_FRAME                     /* Output sample time/**/static void mdlInitializeSizes(SimStruct *S){  ssSetNumSFcnParams(S, NPARAMS);  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S))     {      return;	}    if (!ssSetNumInputPorts(S, 2)) return;    ssSetInputPortWidth(S, 0, in_buff);    ssSetInputPortWidth(S, 1,  nSide);    ssSetInputPortDirectFeedThrough(S, 0, 1);    ssSetInputPortDirectFeedThrough(S, 1, 1);    if (!ssSetNumOutputPorts(S, 2)) return;    ssSetOutputPortWidth(S, 0,out_buff);      ssSetOutputPortWidth(S, 1,nSide); /* channel /**/    ssSetNumSampleTimes(S, 2);    ssSetNumIWork(S, 2);     ssSetNumRWork(S, n_buff * out_buff);     ssSetSFcnParamNotTunable(S,0);  /* speeds up simulations*/      ssSetSFcnParamNotTunable(S,1);      ssSetSFcnParamNotTunable(S,2);     ssSetSFcnParamNotTunable(S,3);     /* Take care when specifying exception free code - see sfuntmpl.doc */    ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);    /* do not use mxCalloc or  mexErrMsgTxt functions */} static void mdlInitializeSampleTimes(SimStruct *S){         ssSetSampleTime(S, 0, tdI);      ssSetOffsetTime(S, 0, 0.0);     ssSetSampleTime(S, 1, tdO);      ssSetOffsetTime(S, 1, 0.0);}static void mdlOutputs(SimStruct *S, int_T tid){  real_T            *y   = ssGetOutputPortRealSignal(S,0);  real_T            *flag   = ssGetOutputPortRealSignal(S,1);  InputRealPtrsType IPtrs = ssGetInputPortRealSignalPtrs(S,0);  InputRealPtrsType IsPtrs = ssGetInputPortRealSignalPtrs(S,1);  int_T             *iwork = ssGetIWork(S);  real_T            *rwork = ssGetRWork(S);  int_T             lp,ready = 0;  if(ssIsSampleHit(S, 1, tid) && iwork[1] > 0){/**/       for (lp = 0; lp < out_buff;  lp++){	y[lp] = rwork[lp];	rwork[lp] = rwork[ out_buff + lp];      }/**/       flag[0] = iwork[1];/**/       iwork[1] = 0;       iwork[0] = 0;  }  if (ssIsSampleHit(S, 0, tid)) {    for (lp = 0; lp < Is(0);  lp++){      rwork[iwork[0]] = I(lp);      iwork[0] ++;             if ( iwork[0] == out_buff )	iwork[1] = 1;    }  }}static void mdlTerminate(SimStruct *S){  }#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */#include "simulink.c"      /* MEX-file interface mechanism */#else#include "cg_sfun.h"       /* Code generation registration function */#endif

⌨️ 快捷键说明

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