⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example6_acc.c

📁 或许这个代码会对大家有用
💻 C
字号:
/*
 * This file is not available for use in any application other than as a
 * MATLAB(R) MEX file for use with the Simulink(R) Accelerator product.
 */

/*
 * Real-Time Workshop code generation for Simulink model "example6_acc.mdl".
 *
 * Model Version                        : 1.43
 * Real-Time Workshop file version      : 5.0 $Date: 2002/05/30 19:21:33 $
 * Real-Time Workshop file generated on : Mon Jan 10 16:38:03 2005
 * TLC version                          : 5.0 (Jun 18 2002)
 * C source code generated on           : Mon Jan 10 16:38:03 2005
 */

#include <math.h>
#include <string.h>
#include "example6_acc.h"
#include "example6_acc_private.h"
#include <stdio.h>
#include "simstruc.h"

#define CodeFormat                      S-Function
#define AccDefine1                      Accelerator_S-Function

/* Outputs for root system: '<Root>' */
static void mdlOutputs(SimStruct *S, int_T tid)
{
  /* simstruct variables */
  example6_BlockIO *example6_B = (example6_BlockIO *) _ssGetBlockIO(S);
  example6_D_Work *example6_DWork = (example6_D_Work *) ssGetRootDWork(S);
  example6_Parameters *example6_P = (example6_Parameters *) ssGetDefaultParam(S);

  /* local block i/o variables */
  real_T rtb_temp9[3];

  /* tid is required for a uniform function interface. This system
   * is single rate, and in this case, tid is not accessed. */
  UNUSED_PARAMETER(tid);

  /* DSP Blockset Random Source (sdsprandsrc2) - '<S3>/Random Source' */
  MWDSP_RandSrc_U_D((real64_T*)&rtb_temp9[0],&example6_P->Random_Source_a_Min,1,&example6_P->Random_Source_a_Max,1,&example6_DWork->Random_Source_a_STATE_DWORK[0],1,3);

  /* Constant: '<S4>/Constant' */
  example6_B->Constant[0] = example6_P->Constant_Value[0];
  example6_B->Constant[1] = example6_P->Constant_Value[1];
  example6_B->Constant[2] = example6_P->Constant_Value[2];

  /* RelationalOperator: '<S3>/Relational Operator' */
  rtb_temp9[0] = (rtb_temp9[0] > example6_B->Constant[0]);
  rtb_temp9[1] = (rtb_temp9[1] > example6_B->Constant[1]);
  rtb_temp9[2] = (rtb_temp9[2] > example6_B->Constant[2]);

  /* S-Function Block: <S3>/Reshape */
  example6_B->Reshape[0] = rtb_temp9[0];
  example6_B->Reshape[1] = rtb_temp9[1];
  example6_B->Reshape[2] = rtb_temp9[2];

  /* Level2 S-Function Block: <Root>/Convolutional Encoder (scomconvenc) */
  /* Call into Simulink for MEX-version of S-function */
  ssCallAccelRunBlock(S, 0, 4, SS_CALL_MDL_OUTPUTS);

  /* Level2 S-Function Block: <S2>/M-PSK Modulator Baseband (scomapskmod) */
  /* Call into Simulink for MEX-version of S-function */
  ssCallAccelRunBlock(S, 0, 5, SS_CALL_MDL_OUTPUTS);

  /* DSP Blockset Random Source (sdsprandsrc2) - '<S1>/Random Source' */
  MWDSP_RandSrc_GZ_Z((creal64_T*)&example6_B->Random_Source_b[0],(creal64_T*)&example6_P->Random_Source_b_Mean,1,&example6_P->Random_Source_b_Variance,1,&example6_DWork->Random_Source_b_STATE_DWORK[0],1,6);

  /* Level2 S-Function Block: <S1>/Dynamic AWGN (scomawgnchan2) */
  /* Call into Simulink for MEX-version of S-function */
  ssCallAccelRunBlock(S, 0, 7, SS_CALL_MDL_OUTPUTS);

  /* ComplexToRealImag: '<Root>/Complex to Real-Imag' */
  {
    int_T i1;

    const creal_T *u0 = &example6_B->Dynamic_AWGN[0];
    real_T *y0 = &example6_B->Complex_to_Real_Imag[0];

    for (i1=0; i1 < 6; i1++) {
      y0[i1] = u0[i1].re;
    }
  }

  /* Level2 S-Function Block: <Root>/Viterbi Decoder (scomviterbi) */
  /* Call into Simulink for MEX-version of S-function */
  ssCallAccelRunBlock(S, 0, 9, SS_CALL_MDL_OUTPUTS);

  /* Level2 S-Function Block: <Root>/Error Rate Calculation (scomerrrate2) */
  /* Call into Simulink for MEX-version of S-function */
  ssCallAccelRunBlock(S, 0, 10, SS_CALL_MDL_OUTPUTS);

  /* Display: '<Root>/Display' */
  /* Call into Simulink for Display */
  ssCallAccelRunBlock(S, 0, 11, SS_CALL_MDL_OUTPUTS);
}

/* Update for root system: '<Root>' */
#define MDL_UPDATE
static void mdlUpdate(SimStruct *S, int_T tid)
{

  /* tid is required for a uniform function interface. This system
   * is single rate, and in this case, tid is not accessed. */
  UNUSED_PARAMETER(tid);
}

/* Function to initialize sizes */
static void mdlInitializeSizes(SimStruct *S)
{

  /* checksum */
  ssSetChecksumVal(S, 0, 561394734U);
  ssSetChecksumVal(S, 1, 1152152900U);
  ssSetChecksumVal(S, 2, 2487829343U);
  ssSetChecksumVal(S, 3, 3804244527U);

  /* options */
  ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);

  /* Accelerator check memory map size match for DWork */
  if (ssGetSizeofDWork(S) != sizeof(example6_D_Work)) {
    ssSetErrorStatus(S,"Unexpected error: Internal DWork sizes do "
     "not match for accelerator mex file.");
  }

  /* Accelerator check memory map size match for BlockIO */
  if (ssGetSizeofGlobalBlockIO(S) != sizeof(example6_BlockIO)) {
    ssSetErrorStatus(S,"Unexpected error: Internal BlockIO sizes do "
     "not match for accelerator mex file.");
  }

  /* model parameters */
  _ssSetDefaultParam(S, (real_T *) &example6_DefaultParameters);
}

/* Empty mdlInitializeSampleTimes function (never called) */
static void mdlInitializeSampleTimes(SimStruct *S) { }

/* Empty mdlTerminate function (never called) */
static void mdlTerminate(SimStruct *S) { }

/* MATLAB MEX Glue */
#include "simulink.c"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -