📄 s_channel_estimator.c
字号:
/* | Project: WCDMA simulation environment | Module: | This function is a simulink interface to channel | estimation function. Currently this only checks | what channel (amplitude) taps are above | given threshold and return those | taps and the number of relevant taps | | | Author: Maarit Melvasalo | Date: May 1999 | | History: | May 18, 1999 Maarit Melvasalo | | | Abstract: | | USER GIVEN PARAMETERS | | 1: THERS = threshold value for channel estimation | 2: nSlot = number od slot in a frame (used for sample timing) | | Inputs: | Channel | Delay | | Outputs: | Channel | Delay | Number of relevant channel taps | | 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_channel_estimator#define S_FUNCTION_LEVEL 2#include <math.h>#include "simstruc.h"#include "channel.h"#include "tmwtypes.h"#include "config_wcdma.h"#include "wcdma_simulink.h"/* USER GIVEN PARAMETERS AND DEFINITIONS /**/#define NPARAMS 2 /* number of parameters /**/#define THRES(S) ssGetSFcnParam(S,0) /* Channel threshold*/#define SLOTS(S) ssGetSFcnParam(S,1)#define nSlots (int_T)(mxGetPr(SLOTS(S))[0]) #define A(element) (*aPtrs[element]) /* Pointer to Input Port0 */#define D(element) (*dPtrs[element]) /* Pointer to Input Port0 */ /*turha, mutta ei se mitaan */#define td TD_FRAME / (real_T)nSlots /*SLOT /**//*====================* */static void mdlInitializeSizes(SimStruct *S){ ssSetNumSFcnParams(S, NPARAMS); /* Number of expected parameters */ if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { return; } ssSetNumContStates(S, 0); ssSetNumDiscStates(S, 0); if (!ssSetNumInputPorts(S, 2)) return; ssSetInputPortWidth(S, 0, MAX_CHANNEL_TAPS); ssSetInputPortWidth(S, 1, MAX_CHANNEL_TAPS); ssSetInputPortDirectFeedThrough(S, 0, 1); ssSetInputPortDirectFeedThrough(S, 1, 1); if (!ssSetNumOutputPorts(S, 3)) return; ssSetOutputPortWidth(S, 0, MAX_CHANNEL_TAPS); ssSetOutputPortWidth(S, 1, MAX_CHANNEL_TAPS); ssSetOutputPortWidth(S, 2, 1); ssSetNumSampleTimes(S, 1); ssSetSFcnParamNotTunable(S,0); /* nopeuttaa, kun vakio parametrit*/ ssSetSFcnParamNotTunable(S,1); /* Take care when specifying exception free code - see sfuntmpl.doc */ ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);} /* ei saa kayttaa mxCalloc tai mexErrMsgTxt tms rutiineita *//* Function: mdlInitializeSampleTimes ========================================= */static void mdlInitializeSampleTimes(SimStruct *S){ ssSetSampleTime(S, 0, td); ssSetOffsetTime(S, 0, 0.0);}/* Function: mdlOutputs ======================================================= */static void mdlOutputs(SimStruct *S, int_T tid){ real_T *channel = ssGetOutputPortRealSignal(S,0); real_T *delay = ssGetOutputPortRealSignal(S,1); real_T *length = ssGetOutputPortRealSignal(S,2); InputRealPtrsType aPtrs = ssGetInputPortRealSignalPtrs(S,0); InputRealPtrsType dPtrs = ssGetInputPortRealSignalPtrs(S,1); int_T i,i_tmp; real_T channel_threshold = mxGetPr(THRES(S))[0] ; i_tmp =0; for (i = 0; i < MAX_CHANNEL_TAPS; i++){ if (A(i) > channel_threshold) { channel[i_tmp] = A(i); delay[i_tmp] = D(i); i_tmp ++; } } length[0] = i_tmp;}/* Function: mdlTerminate ===================================================== */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 + -