📄 s_hard_decission.c
字号:
/* | | 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: April 2, 1999 | | History: | April 2, 1999 Maarit Melvasalo | Initial version * * File : * Abstract: * * USER GIVEN PARAMETERS * * 0: in_dem = Size of real input vector (= packet size) * 1: nFrames = sample time */#define S_FUNCTION_NAME s_hard_decission#define S_FUNCTION_LEVEL 2#include <math.h>#include "simstruc.h"#include "tmwtypes.h"#include "config_wcdma.h"/* MAX_CHANNEL_TAPS/**/#define NPARAMS 4#define IN_SIZE(S) ssGetSFcnParam(S,0)#define in_dem (int_T)(mxGetPr(IN_SIZE(S))[0])#define frame(S) ssGetSFcnParam(S,1) /* /**/#define nFrames (mxGetPr(frame(S))[0]) #define thres(S) ssGetSFcnParam(S,2) /* /**/#define out_mode(S) ssGetSFcnParam(S,3) /* /**/#define I(element) (*IPtrs[element])#define td nFrames * TD_FRAME /* sample time/**/static void mdlInitializeSizes(SimStruct *S){ ssSetNumSFcnParams(S, NPARAMS); if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) { return; } if (!ssSetNumInputPorts(S, 1)) return; ssSetInputPortWidth(S, 0, in_dem); ssSetInputPortDirectFeedThrough(S, 0, 1); if (!ssSetNumOutputPorts(S, 1)) return; ssSetOutputPortWidth(S, 0,in_dem); ssSetNumSampleTimes(S, 1); ssSetSFcnParamNotTunable(S,0); ssSetSFcnParamNotTunable(S,1); ssSetSFcnParamNotTunable(S,2); /* 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, td); ssSetOffsetTime(S, 0, 0.0);}static void mdlOutputs(SimStruct *S, int_T tid){ real_T *y = ssGetOutputPortRealSignal(S,0); InputRealPtrsType IPtrs = ssGetInputPortRealSignalPtrs(S,0); real_T mode = mxGetPr(out_mode(S))[0]; real_T threshold = mxGetPr(thres(S))[0]; int_T lp = 0; if( mode < 1) { for (lp = 0; lp < in_dem; lp++){ y[lp] = (I(lp) > threshold ? 1 : 0); } } else{ for (lp = 0; lp < in_dem; lp++){ y[lp] = (I(lp) > threshold ? 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 + -