📄 s_ber_direct.c
字号:
/* | Project: WCDMA simulation environment | Module: | Author: | Date: February 23, 1999 | | History: | | June 8, 1999 Maarit Melvasalo | Initial version. * * File : s_ber_calc.c * Abstract: * * USER GIVEN PARAMETERS * * 1: B = the number of real input chips * 2: C = the spreading code * 3: SF = spreading factor * * | | 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. | */#define S_FUNCTION_NAME s_ber_direct#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 /**//*Number of input and output ports/**/#define NINPUTS 2#define NOUTPUTS 1/* Number of user given parameters/**/ #define NPARAMS 2 /* Input and Output Size parameters /**/#define SIZE_PARAM(S) ssGetSFcnParam(S,0) #define nInput (int_T)(mxGetPr(SIZE_PARAM(S))[0]) /* Number of frames in one block/**/#define FRAME_PARAM(S) ssGetSFcnParam(S,1) #define nFrames (mxGetPr(FRAME_PARAM(S))[0]) /* Pointers to Input Ports */#define I(element) (*iPtrs[element]) #define O(element) (*oPtrs[element]) /* Sampletime -- defined in config_cdma /**/#define td nFrames * TD_FRAME /*====================* * S-function methods * *====================*//* Function: mdlInitializeSizes =============================================== * Abstract: * The sizes information is used by Simulink to determine the S-function * block's characteristics (number of inputs, outputs, states, etc.). */static void mdlInitializeSizes(SimStruct *S){ ssSetNumSFcnParams(S, NPARAMS); /* Number of expected parameters */ if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { return; } if (!ssSetNumInputPorts(S, NINPUTS)) return; ssSetInputPortWidth(S, 0, nInput); ssSetInputPortWidth(S, 1, nInput); ssSetInputPortDirectFeedThrough(S, 0, 1); ssSetInputPortDirectFeedThrough(S, 1, 1); if (!ssSetNumOutputPorts(S, NOUTPUTS)) return; ssSetOutputPortWidth(S, 0, 1); ssSetNumSampleTimes(S, 1); ssSetNumRWork(S, 1); ssSetSFcnParamNotTunable(S,0); ssSetSFcnParamNotTunable(S,1); /* Take care when specifying exception free code - see sfuntmpl.doc */ ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);} /* do not use mxCalloc or mexErrMsgTxt functions *//* Function: mdlInitializeSampleTimes ========================================= * Abstract: * Specifiy that sampletime is given by the user */static void mdlInitializeSampleTimes(SimStruct *S){ ssSetSampleTime(S, 0, td); ssSetOffsetTime(S, 0, 0.0);}#define MDL_INITIALIZE_CONDITIONS/* Function: mdlInitializeConditions ======================================== * Abstract: */static void mdlInitializeConditions(SimStruct *S){ real_T *rwork = ssGetRWork(S); rwork[0] = 0;}/* Function: mdlOutputs ======================================================= * Abstract: * */static void mdlOutputs(SimStruct *S, int_T tid){ real_T *y = ssGetOutputPortRealSignal(S,0); InputRealPtrsType iPtrs = ssGetInputPortRealSignalPtrs(S,0); InputRealPtrsType oPtrs = ssGetInputPortRealSignalPtrs(S,1); real_T *rwork = ssGetRWork(S); int_T *iwork = ssGetIWork(S); int_T i; for (i = 0; i < nInput; i++){ if ( I(i) != O(i)) rwork[0] ++; } y[0] = rwork[0];}/* Function: mdlTerminate ===================================================== * Abstract: */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 + -