?? s_mod_plain.c
字號(hào):
/* | | 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. |*//* | Project: WCDMA simulation environment | Module: | Author: | Date: June 14, 1999 | | History: | | June 14, 1999 Maarit Melvasalo | Initial version. | to internal * * File : s_dl_discmod.c * Abstract: * * USER GIVEN PARAMETERS * * 0: in_len = Size of real input vector (= packet size) * 1: nFrames = sample time */#define S_FUNCTION_NAME s_mod_plain#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 /**//* General Parameters /**/#define NPARAMS 2#define IN_SIZE(S) ssGetSFcnParam(S,0)#define in_len (int_T)(mxGetPr(IN_SIZE(S))[0])#define frame(S) ssGetSFcnParam(S,1) /* /**/#define nFrames (int_T)(mxGetPr(frame(S))[0]) #define I(element) (*IPtrs[element])#define td nFrames * TD_FRAME /* sample time/**//*====================* * 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, 1)) return; /* ONE input port/**/ ssSetInputPortWidth(S, 0, in_len); ssSetInputPortDirectFeedThrough(S, 0, 1); if (!ssSetNumOutputPorts(S, 2)) return; /* TWO output port/**/ ssSetOutputPortWidth(S, 0,in_len/2); ssSetOutputPortWidth(S, 1,in_len/2); ssSetNumSampleTimes(S, 1); ssSetSFcnParamNotTunable(S,0); /* speeds up simulations*/ 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);}/* Function: mdlOutputs ======================================================= * Abstract: * */static void mdlOutputs(SimStruct *S, int_T tid){ real_T *yI = ssGetOutputPortRealSignal(S,0); real_T *yQ = ssGetOutputPortRealSignal(S,1); InputRealPtrsType IPtrs = ssGetInputPortRealSignalPtrs(S,0); int_T lp,tmp; for (lp=0; lp< (in_len/2); lp++){ yI[lp] = I( 2 * lp ); yQ[lp] = I( 2 * lp + 1 ); }/**/}/* 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
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -