📄 example5_acc.c
字号:
&example5_DWork->FIR_Interpolati_c_wrtBufIdx,
1,
1,
5,
8,
5);
/* Output port buffer processing */
if (ssIsSampleHit(S, 0, tid))
MWDSP_UpFIR_CopyDataToOutPort((byte_T
*)&example5_DWork->FIR_Interpolati_c_OutBuff[0],
(byte_T *)&example5_B->FIR_Interpolati_c,
&example5_DWork->FIR_Interpolati_c_ReadIdx,
1,
1,
sizeof(real_T),
1 * sizeof(real_T),
5,
5 * sizeof(real_T),
0 * sizeof(real_T),
10);
}
if (ssIsSampleHit(S, 0, tid)) { /* Sample time: [2.0833333333333336E-005, 0.0] */
/* DSP Blockset Sine Wave (sdspsine2) - '<S14>/Complex Carrier' - Output */
{
/* Discrete aperiodic trigonometric mode: */
const real_T Ts_pi2 = 1.3089969389957473E-004;
const real_T Ts_pi2_f = example5_P->Complex_Carrier_a_Frequency * Ts_pi2;
rtb_temp35.re = example5_P->Complex_Carrier_a_Amplitude *
(cos((example5_DWork->Complex_Carrier_a_CountIdx * Ts_pi2_f +
example5_P->Complex_Carrier_a_Phase)));
rtb_temp35.im = example5_P->Complex_Carrier_a_Amplitude *
(sin((example5_DWork->Complex_Carrier_a_CountIdx++ * Ts_pi2_f +
example5_P->Complex_Carrier_a_Phase)));
}
/* ComplexToRealImag: '<S14>/Complex to Real-Imag' */
rtb_Complex_to_Real_Imag_o1 = rtb_temp35.re;
rtb_Complex_to_Real_Imag_o2 = rtb_temp35.im;
}
if (ssIsSampleHit(S, 1, tid)) { /* Sample time: [1.0416666666666667E-004, 0.0] */
/* DSP Blockset FIR Interpolation S-Function (sdspupfir2) - '<S17>/FIR Interpolation' */
{
/* Input port polyphase filtering */
MWDSP_UpFIR_DF_DblBuf_DD(&example5_B->Complex_to_Real_Imag1_o2,
(real_T *)&example5_DWork->FIR_Interpolati_d_OutBuff[0],
(real_T *)&example5_DWork->FIR_Interpolati_d_TapDelayBuff[0],
&example5_P->FIR_Interpolati_d_FILTER_COEFF[0],
&example5_DWork->FIR_Interpolati_d_TapDelayIndex,
&example5_DWork->FIR_Interpolati_d_wrtBufIdx,
1,
1,
1,
5,
1);
/* Output port buffer processing */
MWDSP_UpFIR_CopyDataToOutPort((byte_T
*)&example5_DWork->FIR_Interpolati_d_OutBuff[0],
(byte_T *)&example5_B->FIR_Interpolati_d,
&example5_DWork->FIR_Interpolati_d_ReadIdx,
1,
1,
sizeof(real_T),
1 * sizeof(real_T),
1,
1 * sizeof(real_T),
0 * sizeof(real_T),
2);
}
/* DSP Blockset FIR Interpolation S-Function (sdspupfir2) - '<S17>/FIR Interpolation1' */
{
/* Input port polyphase filtering */
MWDSP_UpFIR_DF_DblBuf_DD(&example5_B->FIR_Interpolati_d,
(real_T *)&example5_DWork->FIR_Interpolati_e_OutBuff[0],
(real_T *)&example5_DWork->FIR_Interpolati_e_TapDelayBuff[0],
&example5_P->FIR_Interpolati_e_FILTER_COEFF[0],
&example5_DWork->FIR_Interpolati_e_TapDelayIndex,
&example5_DWork->FIR_Interpolati_e_wrtBufIdx,
1,
1,
1,
5,
1);
/* Output port buffer processing */
MWDSP_UpFIR_CopyDataToOutPort((byte_T
*)&example5_DWork->FIR_Interpolati_e_OutBuff[0],
(byte_T *)&example5_B->FIR_Interpolati_e,
&example5_DWork->FIR_Interpolati_e_ReadIdx,
1,
1,
sizeof(real_T),
1 * sizeof(real_T),
1,
1 * sizeof(real_T),
0 * sizeof(real_T),
2);
}
}
/* DSP Blockset FIR Interpolation S-Function (sdspupfir2) - '<S17>/FIR Interpolation2' */
{
/* Input port polyphase filtering */
if (ssIsSampleHit(S, 1, tid))
MWDSP_UpFIR_DF_DblBuf_DD(&example5_B->FIR_Interpolati_e,
(real_T *)&example5_DWork->FIR_Interpolati_f_OutBuff[0],
(real_T *)&example5_DWork->FIR_Interpolati_f_TapDelayBuff[0],
&example5_P->FIR_Interpolati_f_FILTER_COEFF[0],
&example5_DWork->FIR_Interpolati_f_TapDelayIndex,
&example5_DWork->FIR_Interpolati_f_wrtBufIdx,
1,
1,
5,
8,
5);
/* Output port buffer processing */
if (ssIsSampleHit(S, 0, tid))
MWDSP_UpFIR_CopyDataToOutPort((byte_T
*)&example5_DWork->FIR_Interpolati_f_OutBuff[0],
(byte_T *)&example5_B->FIR_Interpolati_f,
&example5_DWork->FIR_Interpolati_f_ReadIdx,
1,
1,
sizeof(real_T),
1 * sizeof(real_T),
5,
5 * sizeof(real_T),
0 * sizeof(real_T),
10);
}
if (ssIsSampleHit(S, 0, tid)) { /* Sample time: [2.0833333333333336E-005, 0.0] */
/* Sum: '<S14>/Sum' incorporates:
* Product: '<S14>/Product1'
* Product: '<S14>/Product2'
*/
example5_B->Sum =
(example5_B->FIR_Interpolati_c * rtb_Complex_to_Real_Imag_o1)
- (rtb_Complex_to_Real_Imag_o2 * example5_B->FIR_Interpolati_f);
}
/* Level2 S-Function Block: <S15>/Inherit Shape1 (scominhshape) */
/* Call into Simulink for MEX-version of S-function */
ssCallAccelRunBlock(S, 1, 25, SS_CALL_MDL_OUTPUTS);
/* SubSystem: '<Root>/Spectrum Scope' */
if (ssIsSampleHit(S, 0, tid) || ssIsSampleHit(S, 3, tid)) {
example5_Spectrum_Scope(S, tid);
}
if (ssIsSampleHit(S, 0, tid)) { /* Sample time: [2.0833333333333336E-005, 0.0] */
/* DSP Blockset Random Source (sdsprandsrc2) - '<S1>/Random Source' */
MWDSP_RandSrc_GZ_D((real64_T*)&example5_B->Random_Source_b,(real64_T*)&example5_P->Random_Source_b_Mean,1,&example5_P->Random_Source_b_Variance,1,&example5_DWork->Random_Source_b_STATE_DWORK[0],1,1);
/* Level2 S-Function Block: <S1>/Dynamic AWGN (scomawgnchan2) */
/* Call into Simulink for MEX-version of S-function */
ssCallAccelRunBlock(S, 1, 28, SS_CALL_MDL_OUTPUTS);
/* DSP Blockset Sine Wave (sdspsine2) - '<S10>/Complex Carrier' - Output */
{
/* Discrete aperiodic trigonometric mode: */
const real_T Ts_pi2 = 1.3089969389957473E-004;
const real_T Ts_pi2_f = example5_P->Complex_Carrier_b_Frequency * Ts_pi2;
rtb_temp35.re = example5_P->Complex_Carrier_b_Amplitude *
(cos((example5_DWork->Complex_Carrier_b_CountIdx * Ts_pi2_f +
example5_P->Complex_Carrier_b_Phase)));
rtb_temp35.im = example5_P->Complex_Carrier_b_Amplitude *
(sin((example5_DWork->Complex_Carrier_b_CountIdx++ * Ts_pi2_f +
example5_P->Complex_Carrier_b_Phase)));
}
/* Product: '<S10>/Product1' */
{
creal_T output;
output.re = example5_B->Dynamic_AWGN;
output.im = 0.0;
{
real_T tmpReal = output.re * rtb_temp35.re - output.im * rtb_temp35.im;
output.im = output.re * rtb_temp35.im + output.im * rtb_temp35.re;
output.re = tmpReal;
}
example5_B->Product1_b = output;
}
/* DSP Blockset FIR Decimation S-Function (sdspfirdn2) - '<S12>/FIR Decimation1' */
{
/* Input polyphase filtering */
MWDSP_FIRDn_DF_DblBuf_ZD(&example5_B->Product1_b,
(creal_T *)&example5_DWork->FIR_Decimation1_OutBuff[0],
(creal_T *)&example5_DWork->FIR_Decimation1_TapDelayBuff[0],
(creal_T *)&example5_DWork->FIR_Decimation1_Sums,
&example5_P->FIR_Decimation1_FILT[0],
(const real_T **)&example5_DWork->FIR_Decimation1_CoeffPtr,
&example5_DWork->FIR_Decimation1_TapDelayIndex,
&example5_DWork->FIR_Decimation1_OutIdx,
&example5_DWork->FIR_Decimation1_PhaseIdx,
&example5_DWork->FIR_Decimation1_wrtBufIdx,
4,
1,
1,
1,
1,
4,
1);
/* Write out double-buffered data */
{
byte_T *y = (byte_T *)&example5_DWork->FIR_Decimation1_OutBuff[0];
const int_T bytesToCopy = 1 * 1 * sizeof(creal_T);
if (example5_DWork->FIR_Decimation1_readBufIdx) y += bytesToCopy;
memcpy((byte_T *)&example5_B->FIR_Decimation1, y, bytesToCopy);
example5_DWork->FIR_Decimation1_readBufIdx =
!(example5_DWork->FIR_Decimation1_readBufIdx);
}
}
/* DSP Blockset FIR Decimation S-Function (sdspfirdn2) - '<S12>/FIR Decimation2' */
{
/* Input polyphase filtering */
MWDSP_FIRDn_DF_DblBuf_ZD(&example5_B->FIR_Decimation1,
(creal_T *)&example5_DWork->FIR_Decimation2_OutBuff[0],
(creal_T *)&example5_DWork->FIR_Decimation2_TapDelayBuff[0],
(creal_T *)&example5_DWork->FIR_Decimation2_Sums,
&example5_P->FIR_Decimation2_FILT[0],
(const real_T **)&example5_DWork->FIR_Decimation2_CoeffPtr,
&example5_DWork->FIR_Decimation2_TapDelayIndex,
&example5_DWork->FIR_Decimation2_OutIdx,
&example5_DWork->FIR_Decimation2_PhaseIdx,
&example5_DWork->FIR_Decimation2_wrtBufIdx,
4,
1,
1,
1,
1,
4,
1);
/* Write out double-buffered data */
{
byte_T *y = (byte_T *)&example5_DWork->FIR_Decimation2_OutBuff[0];
const int_T bytesToCopy = 1 * 1 * sizeof(creal_T);
if (example5_DWork->FIR_Decimation2_readBufIdx) y += bytesToCopy;
memcpy((byte_T *)&example5_B->FIR_Decimation2, y, bytesToCopy);
example5_DWork->FIR_Decimation2_readBufIdx =
!(example5_DWork->FIR_Decimation2_readBufIdx);
}
}
}
/* DSP Blockset FIR Decimation S-Function (sdspfirdn2) - '<S12>/FIR Decimation3' */
{
/* Input polyphase filtering */
if (ssIsSampleHit(S, 0, tid)) {
MWDSP_FIRDn_DF_DblBuf_ZD(&example5_B->FIR_Decimation2,
(creal_T *)&example5_DWork->FIR_Decimation3_OutBuff[0],
(creal_T *)&example5_DWork->FIR_Decimation3_TapDelayBuff[0],
(creal_T *)&example5_DWork->FIR_Decimation3_Sums,
&example5_P->FIR_Decimation3_FILT[0],
(const real_T **)&example5_DWork->FIR_Decimation3_CoeffPtr,
&example5_DWork->FIR_Decimation3_TapDelayIndex,
&example5_DWork->FIR_Decimation3_OutIdx,
&example5_DWork->FIR_Decimation3_PhaseIdx,
&example5_DWork->FIR_Decimation3_wrtBufIdx,
40,
1,
1,
1,
5,
8,
1);
}
/* Write out double-buffered data */
if (ssIsSampleHit(S, 1, tid))
{
byte_T *y = (byte_T *)&example5_DWork->FIR_Decimation3_OutBuff[0];
const int_T bytesToCopy = 1 * 1 * sizeof(creal_T);
if (example5_DWork->FIR_Decimation3_readBufIdx) y += bytesToCopy;
memcpy((byte_T *)&example5_B->FIR_Decimation3, y, bytesToCopy);
example5_DWork->FIR_Decimation3_readBufIdx =
!(example5_DWork->FIR_Decimation3_readBufIdx);
}
}
}
/* Update for root system: '<Root>' */
#define MDL_UPDATE
static void mdlUpdate(SimStruct *S, int_T tid)
{
/* simstruct variables */
example5_BlockIO *example5_B = (example5_BlockIO *) _ssGetBlockIO(S);
example5_D_Work *example5_DWork = (example5_D_Work *) ssGetRootDWork(S);
example5_Parameters *example5_P = (example5_Parameters *) ssGetDefaultParam(S);
if (ssIsSampleHit(S, 1, tid)) { /* Sample time: [1.0416666666666667E-004, 0.0] */
/* DSP Blockset Delay (sdspdly2) - '<S3>/Integer Delay1' */
{
const int_T bytesPerElem = (2 * sizeof(real_T));
int_T bufferStart;
/* Scalar input */
bufferStart = example5_DWork->Integer_Delay1_BUFF_OFFSET;
memcpy(((byte_T *) &example5_DWork->Integer_Delay1_BUFF[0]) +
(bufferStart*bytesPerElem), &example5_B->FIR_Decimation3, bytesPerElem);
example5_DWork->Integer_Delay1_BUFF_OFFSET += 1;
while (example5_DWork->Integer_Delay1_BUFF_OFFSET >=
example5_P->Integer_Delay1_Delays)
example5_DWork->Integer_Delay1_BUFF_OFFSET -=
example5_P->Integer_Delay1_Delays;
}
}
if (ssIsSampleHit(S, 2, tid)) { /* Sample time: [8.3333333333333339E-004, 0.0] */
/* DSP Blockset Delay (sdspdly2) - '<Root>/Integer Delay' */
{
const int_T bytesPerElem = sizeof(real_T);
int_T bufferStart;
/* Scalar input */
bufferStart = example5_DWork->Integer_Delay_BUFF_OFFSET;
memcpy(((byte_T *) &example5_DWork->Integer_Delay_BUFF[0]) +
(bufferStart*bytesPerElem), &example5_B->Reshape, bytesPerElem);
example5_DWork->Integer_Delay_BUFF_OFFSET += 1;
while (example5_DWork->Integer_Delay_BUFF_OFFSET >=
example5_P->Integer_Delay_Delays)
example5_DWork->Integer_Delay_BUFF_OFFSET -=
example5_P->Integer_Delay_Delays;
}
}
/* atomic SubSystem Block: <Root>/Spectrum Scope */
if (ssIsSampleHit(S, 0, tid) || ssIsSampleHit(S, 3, tid)) {
example5_Spectrum_Scope_Update(S, tid);
}
}
/* Function to initialize sizes */
static void mdlInitializeSizes(SimStruct *S)
{
/* checksum */
ssSetChecksumVal(S, 0, 1920894413U);
ssSetChecksumVal(S, 1, 811139493U);
ssSetChecksumVal(S, 2, 2449366036U);
ssSetChecksumVal(S, 3, 2581535926U);
/* options */
ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
/* Accelerator check memory map size match for DWork */
if (ssGetSizeofDWork(S) != sizeof(example5_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(example5_BlockIO)) {
ssSetErrorStatus(S,"Unexpected error: Internal BlockIO sizes do "
"not match for accelerator mex file.");
}
/* model parameters */
_ssSetDefaultParam(S, (real_T *) &example5_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 + -