📄 s_rate.c
字号:
/* | Project: WCDMA simulation environment | Module: | Author: | Date: February, 1999 | | History: | May 20, 1999 Maarit Melvasalo | | File : s_rate.c | Abstract: | This function | | USER GIVEN PARAMETERS | | | | 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_rate#define S_FUNCTION_LEVEL 2#include <math.h>#include "simstruc.h"#include "tmwtypes.h"#include "config_wcdma.h"#include "wcdma_simulink.h"/* USER GIVEN PARAMETERS AND DEFINITIONS /**/#define NPARAMS 4 /* number of parameters /**/#define IN_SIZE(S) ssGetSFcnParam(S,0) /* Block size*/#define nInputs (int_T)(mxGetPr(IN_SIZE(S))[0]) /* Number of inputs*/#define OUT_SIZE(S) ssGetSFcnParam(S,1) /* Allowed block sizes*/#define nOutputs (int_T)(mxGetPr(OUT_SIZE(S))[0]) /* Number of inputs*/#define punk_ratio(S) ssGetSFcnParam(S,2) /*Signal to noise ratio*//**/#define frame(S) ssGetSFcnParam(S,3) /* /**/#define nFrames mxGetPr(frame(S))[0] #define U(element) (*uPtrs[element]) /* Pointer to Input Port0 *//* input and output vector sizes/**/#define td nFrames *TD_FRAME /* Sampletime -- defined in config_cdma /**//*====================* */static void mdlInitializeSizes(SimStruct *S){ ssSetNumSFcnParams(S, NPARAMS); /* Number of expected parameters */ if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { return; } if (!ssSetNumInputPorts(S, 1)) return; ssSetInputPortWidth(S, 0, nInputs); ssSetInputPortDirectFeedThrough(S, 0, 1); if (!ssSetNumOutputPorts(S, 1)) return; ssSetOutputPortWidth(S, 0, nOutputs); ssSetNumSampleTimes(S, 1); ssSetSFcnParamNotTunable(S,0); /* nopeuttaa, kun vakio parametrit*/ 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);} /* 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 *y = ssGetOutputPortRealSignal(S,0); InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0); real_T punk = mxGetPr(punk_ratio(S))[0]; int_T data[nInputs]; int_T out[nOutputs]; int_T i,tmp; for (i = 0; i < nInputs; i++) data[i] = (int_T)U(i); tmp = wcdma_rate_match(data,nInputs,punk,nOutputs,out); for (i = 0; i < nOutputs; i++) y[i] = out[i]; /**/}/* 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 + -