📄 cdma20001x_acc.c
字号:
}
}
/* S-Function Block: <S8>/Reshape */
/* DSP Blockset Pad (sdsppad) - '<S4>/Zero Pad' */
/* Input dimensions: [172 x 1], output dimensions: [172 x 1] */
memcpy( &cdma20001x_B->Zero_Pad_a[0], &rtb_temp61[0], (172 * sizeof(real_T))
);
/* Level2 S-Function Block: <S4>/General CRC Generator (scomcrcgen) */
/* Call into Simulink for MEX-version of S-function */
ssCallAccelRunBlock(S, 1, 32, SS_CALL_MDL_OUTPUTS);
/* DSP Blockset Pad (sdsppad) - '<S5>/Zero Pad' */
/* Input dimensions: [184 x 1], output dimensions: [192 x 1] */
MWDSP_PadAlongCols( (const byte_T *)&cdma20001x_B->General_CRC_Generator[0],
(byte_T *)&cdma20001x_B->Zero_Pad_b[0], (byte_T
*)(&cdma20001x_P->Zero_Pad_b_PadValue), 1, 184 * sizeof(real_T), 8,
sizeof(real_T) );
/* Level2 S-Function Block: <S5>/Convolutional Encoder (scomconvenc) */
/* Call into Simulink for MEX-version of S-function */
ssCallAccelRunBlock(S, 1, 34, SS_CALL_MDL_OUTPUTS);
/* DSP Blockset Repeat (sdsprepeat2) - '<S6>/Repeat' */
/* Not multi-rate and Multitasking mode */
{
byte_T *y = (byte_T *)(&cdma20001x_B->Repeat_a[0]);
byte_T *uptr = (byte_T *)(&cdma20001x_B->Convolutional_Encoder[0]);
int_T Input_repeat_cnt;
int_T Iteration_cnt;
int_T n;
for (n=0; n<1; n++) {
/* Point to next channel: */
if (n!=0) uptr += (768*sizeof(real_T));
/* Reset the counters */
Input_repeat_cnt = cdma20001x_DWork->Repeat_a_REPEAT_CNT;
Iteration_cnt = cdma20001x_DWork->Repeat_a_ITERATION_CNT;
{
int_T k;
for (k=0; k < 1536; k++) {
memcpy(y,uptr + Iteration_cnt*sizeof(real_T),sizeof(real_T));
y+=sizeof(real_T);
if (++Input_repeat_cnt == 2) {
Input_repeat_cnt = 0;
if (++Iteration_cnt == 768) Iteration_cnt = 0;
}
}
}
}
/* Update counters */
cdma20001x_DWork->Repeat_a_ITERATION_CNT = Iteration_cnt;
cdma20001x_DWork->Repeat_a_REPEAT_CNT = Input_repeat_cnt;
}
/* Level2 S-Function Block: <S6>/Puncture (scomselect) */
/* Call into Simulink for MEX-version of S-function */
ssCallAccelRunBlock(S, 1, 36, SS_CALL_MDL_OUTPUTS);
/* Level1 S-Function Block: <S6>/S-Function (MS_SFUN_Interleaver) */
/* Call into Simulink for MEX-version of S-function */
ssCallAccelRunBlock(S, 1, 37, SS_CALL_MDL_OUTPUTS);
/* DSP Blockset Repeat (sdsprepeat2) - '<S7>/Repeat' */
/* Not multi-rate and Multitasking mode */
{
byte_T *y = (byte_T *)(&cdma20001x_B->Repeat_b[0]);
byte_T *uptr = (byte_T *)(&cdma20001x_B->S_Function_a[0]);
int_T Input_repeat_cnt;
int_T Iteration_cnt;
int_T n;
for (n=0; n<1; n++) {
/* Point to next channel: */
if (n!=0) uptr += (1536*sizeof(real_T));
/* Reset the counters */
Input_repeat_cnt = cdma20001x_DWork->Repeat_b_REPEAT_CNT;
Iteration_cnt = cdma20001x_DWork->Repeat_b_ITERATION_CNT;
{
int_T k;
for (k=0; k < 24576; k++) {
memcpy(y,uptr + Iteration_cnt*sizeof(real_T),sizeof(real_T));
y+=sizeof(real_T);
if (++Input_repeat_cnt == 16) {
Input_repeat_cnt = 0;
if (++Iteration_cnt == 1536) Iteration_cnt = 0;
}
}
}
}
/* Update counters */
cdma20001x_DWork->Repeat_b_ITERATION_CNT = Iteration_cnt;
cdma20001x_DWork->Repeat_b_REPEAT_CNT = Input_repeat_cnt;
}
}
/* DSP Blockset Buffer/Unbuffer (sdsprebuff2) - '<S7>/Unbuffer' */
{
if (ssIsSampleHit(S, 1, tid)) {
MWDSP_Buf_CopyInputToOutput_1ch((const byte_T
*)&cdma20001x_B->Repeat_b[0], (byte_T *)&cdma20001x_B->Unbuffer_c,
(int32_T *)&cdma20001x_DWork->Unbuffer_c_CircBuff, sizeof(real_T),
sizeof(real_T)*1, 24576, 1);
}
}
if (ssIsSampleHit(S, 1, tid)) { /* Sample time: [8.1380208333333339E-007, 0.0] */
/* Constant: '<S12>/Constant' */
cdma20001x_B->Constant_d = cdma20001x_P->Constant_d_Value;
/* FromWorkspace: '<S14>/From Workspace' */
/* Call into Simulink for From Workspace */
ssCallAccelRunBlock(S, 1, 44, SS_CALL_MDL_OUTPUTS);
/* S-Function Block: <S11>/Reshape */
rtb_Reshape_b = cdma20001x_B->From_Workspace;
/* Product: '<S7>/Power Control' incorporates:
* Product: '<S7>/Spread'
* Gain: '<S12>/Polarity'
* Sum: '<S12>/Sum'
* Gain: '<S12>/Gain'
*
* Regarding '<S12>/Polarity':
* Gain value: cdma20001x_P->Polarity_d_Gain
*
* Regarding '<S12>/Gain':
* Gain value: cdma20001x_P->Gain_d_Gain
*/
rtb_temp60 = cdma20001x_B->Relative_Gain * ((((cdma20001x_B->Unbuffer_c *
cdma20001x_P->Gain_d_Gain) - cdma20001x_B->Constant_d) *
cdma20001x_P->Polarity_d_Gain) * rtb_Reshape_b);
/* Sum: '<S2>/Add1'
*
* Regarding '<S2>/Add1':
* Sum Block: '<S2>/Add1'
*
* y = u0 + u1
*
* Input0 Data Type: Floating Point real_T
* Input1 Data Type: Floating Point real_T
* Output0 Data Type: Fixed Point S16 2^-10
* Round Mode: Floor
* Saturation Mode: Wrap
*/
{
int16_T castIn;
{
double uTemp;
uTemp = floor(ldexp(rtb_temp60,10));
uTemp = fmod( uTemp, ldexp( 1.0, 16 ) );
if ( uTemp < ldexp( -1.0, 15 ) )
{
uTemp += ldexp( 1.0, 16 );
}
else if ( uTemp >= ldexp( 1.0, 15 ) )
{
uTemp -= ldexp( 1.0, 16 );
}
rtb_Add1 = (int16_T)uTemp;
}
{
double uTemp;
uTemp = floor(ldexp(cdma20001x_B->data,10));
uTemp = fmod( uTemp, ldexp( 1.0, 16 ) );
if ( uTemp < ldexp( -1.0, 15 ) )
{
uTemp += ldexp( 1.0, 16 );
}
else if ( uTemp >= ldexp( 1.0, 15 ) )
{
uTemp -= ldexp( 1.0, 16 );
}
castIn = (int16_T)uTemp;
}
rtb_Add1 += castIn;
}
/* Product: '<S2>/Product3' */
/* Product Block: '<S2>/Product3'
*
* y = u0 * u1
*
* Input0 Data Type: Floating Point real_T
* Input1 Data Type: Fixed Point S16 2^-10
* Output0 Data Type: Floating Point real_T
* Round Mode: Floor
* Saturation Mode: Saturate
*/
{
rtb_temp60 = (rtb_Q_Product2*ldexp((double)rtb_Add1,-10));
}
/* Sum: '<S2>/Add2' */
cdma20001x_B->Add2 = rtb_Product1 - rtb_temp60;
}
/* DSP Blockset FIR Interpolation S-Function (sdspupfir2) - '<S2>/FIR Interpolation 1' */
{
/* Input port polyphase filtering */
if (ssIsSampleHit(S, 1, tid))
MWDSP_UpFIR_DF_DblBuf_DD(&cdma20001x_B->Add2,
(real_T *)&cdma20001x_DWork->FIR_Interpolati_a_OutBuff[0],
(real_T *)&cdma20001x_DWork->FIR_Interpolati_a_TapDelayBuff[0],
&cdma20001x_P->FIR_Interpolati_a_FILTER_COEFF[0],
&cdma20001x_DWork->FIR_Interpolati_a_TapDelayIndex,
&cdma20001x_DWork->FIR_Interpolati_a_wrtBufIdx,
1,
1,
4,
12,
4);
/* Output port buffer processing */
if (ssIsSampleHit(S, 0, tid))
MWDSP_UpFIR_CopyDataToOutPort((byte_T
*)&cdma20001x_DWork->FIR_Interpolati_a_OutBuff[0],
(byte_T *)&cdma20001x_B->FIR_Interpolati_a,
&cdma20001x_DWork->FIR_Interpolati_a_ReadIdx,
1,
1,
sizeof(real_T),
1 * sizeof(real_T),
4,
4 * sizeof(real_T),
0 * sizeof(real_T),
8);
}
if (ssIsSampleHit(S, 1, tid)) { /* Sample time: [8.1380208333333339E-007, 0.0] */
/* Product: '<S2>/Product2' */
/* Product Block: '<S2>/Product2'
*
* y = u0 * u1
*
* Input0 Data Type: Fixed Point S16 2^-10
* Input1 Data Type: Floating Point real_T
* Output0 Data Type: Fixed Point S16 2^-10
* Round Mode: Floor
* Saturation Mode: Saturate
*/
{
{
real_T tempFloatPt3;
tempFloatPt3 = (ldexp((double)rtb_temp64,-10)*rtb_Q_Product2);
if ( tempFloatPt3 >= 3.1999023437500000E+001 )
{
/* Saturate to MAXIMUM */
rtb_Product2_a = (int16_T)((0x7FFF));
}
else if ( tempFloatPt3 <= -32.0 )
{
/* Saturate to MINIMUM */
rtb_Product2_a = (int16_T)((0x8000U));
}
else
{
/* StoredInteger = FLOOR( ScaledValue ) */
rtb_Product2_a = (int16_T)floor(ldexp(tempFloatPt3,10));
}
}
}
/* Product: '<S2>/Product4' */
/* Product Block: '<S2>/Product4'
*
* y = u0 * u1
*
* Input0 Data Type: Fixed Point S16 2^-10
* Input1 Data Type: Floating Point real_T
* Output0 Data Type: Fixed Point S16 2^-10
* Round Mode: Floor
* Saturation Mode: Saturate
*/
{
{
real_T tempFloatPt3;
tempFloatPt3 = (ldexp((double)rtb_Add1,-10)*rtb_I_Product);
if ( tempFloatPt3 >= 3.1999023437500000E+001 )
{
/* Saturate to MAXIMUM */
rtb_temp64 = (int16_T)((0x7FFF));
}
else if ( tempFloatPt3 <= -32.0 )
{
/* Saturate to MINIMUM */
rtb_temp64 = (int16_T)((0x8000U));
}
else
{
/* StoredInteger = FLOOR( ScaledValue ) */
rtb_temp64 = (int16_T)floor(ldexp(tempFloatPt3,10));
}
}
}
/* Sum: '<S2>/Add3'
*
* Regarding '<S2>/Add3':
* Sum Block: '<S2>/Add3'
*
* y = u0 + u1
*
* Input0 Data Type: Fixed Point S16 2^-10
* Input1 Data Type: Fixed Point S16 2^-10
* Output0 Data Type: Floating Point real_T
* Round Mode: Floor
* Saturation Mode: Wrap
*/
cdma20001x_B->Add3 = ldexp((double)rtb_Product2_a,-10);
cdma20001x_B->Add3 += ldexp((double)rtb_temp64,-10);
}
/* DSP Blockset FIR Interpolation S-Function (sdspupfir2) - '<S2>/FIR Interpolation 2' */
{
/* Input port polyphase filtering */
if (ssIsSampleHit(S, 1, tid))
MWDSP_UpFIR_DF_DblBuf_DD(&cdma20001x_B->Add3,
(real_T *)&cdma20001x_DWork->FIR_Interpolati_b_OutBuff[0],
(real_T *)&cdma20001x_DWork->FIR_Interpolati_b_TapDelayBuff[0],
&cdma20001x_P->FIR_Interpolati_b_FILTER_COEFF[0],
&cdma20001x_DWork->FIR_Interpolati_b_TapDelayIndex,
&cdma20001x_DWork->FIR_Interpolati_b_wrtBufIdx,
1,
1,
4,
12,
4);
/* Output port buffer processing */
if (ssIsSampleHit(S, 0, tid))
MWDSP_UpFIR_CopyDataToOutPort((byte_T
*)&cdma20001x_DWork->FIR_Interpolati_b_OutBuff[0],
(byte_T *)&cdma20001x_B->FIR_Interpolati_b,
&cdma20001x_DWork->FIR_Interpolati_b_ReadIdx,
1,
1,
sizeof(real_T),
1 * sizeof(real_T),
4,
4 * sizeof(real_T),
0 * sizeof(real_T),
8);
}
if (ssIsSampleHit(S, 0, tid)) { /* Sample time: [2.0345052083333335E-007, 0.0] */
/* RealImagToComplex: '<S2>/Real-Imag to Complex' */
rtb_Real_Imag_to_Complex.re = cdma20001x_B->FIR_Interpolati_a;
rtb_Real_Imag_to_Complex.im = cdma20001x_B->FIR_Interpolati_b;
/* Constant: '<Root>/Gain' */
cdma20001x_B->Gain_e = cdma20001x_P->Gain_e_Value;
/* Product: '<S2>/Gain Product' */
{
creal_T output;
output = rtb_Real_Imag_to_Complex;
{
real_T tmpReal = output.re * cdma20001x_B->Gain_e - output.im * 0.0;
output.im = output.re * 0.0 + output.im * cdma20001x_B->Gain_e;
output.re = tmpReal;
}
cdma20001x_B->Gain_Product = output;
}
/* Outport: '<Root>/Out1' */
/* Call into Simulink for root Outports */
ssCallAccelRunBlock(S, 1, 59, SS_CALL_MDL_OUTPUTS);
/* ComplexToRealImag: '<Root>/Complex to Real-Imag' */
cdma20001x_B->Complex_to_Real_Imag_o1 = cdma20001x_B->Gain_Product.re;
cdma20001x_B->Complex_to_Real_Imag_o2 = cdma20001x_B->Gain_Product.im;
/* Scope: '<Root>/Scope I and Q' */
/* Call into Simulink for Scope */
ssCallAccelRunBlock(S, 1, 61, SS_CALL_MDL_OUTPUTS);
}
/* SubSystem: '<Root>/Spectrum Scope' */
if (ssIsSampleHit(S, 0, tid) || ssIsSampleHit(S, 2, tid)) {
cdma20001x_Spectrum_Scope(S, tid);
}
}
/* Update for root system: '<Root>' */
#define MDL_UPDATE
static void mdlUpdate(SimStruct *S, int_T tid)
{
/* simstruct variables */
cdma20001x_BlockIO *cdma20001x_B = (cdma20001x_BlockIO *) _ssGetBlockIO(S);
cdma20001x_D_Work *cdma20001x_DWork = (cdma20001x_D_Work *) ssGetRootDWork(S);
if (ssIsSampleHit(S, 1, tid)) { /* Sample time: [8.1380208333333339E-007, 0.0] */
/* UnitDelay Block: <S17>/Unit Delay */
cdma20001x_DWork->Unit_Delay_DSTATE = cdma20001x_B->Polarity_b;
/* Level1 S-Function Block: <S17>/Conversion (MS_SFUN_QConvert) */
/* Call into Simulink for MEX-version of S-function */
ssCallAccelRunBlock(S, 1, 25, SS_CALL_MDL_UPDATE);
}
if (ssIsSampleHit(S, 3, tid)) { /* Sample time: [0.02, 0.0] */
/* Level1 S-Function Block: <S6>/S-Function (MS_SFUN_Interleaver) */
/* Call into Simulink for MEX-version of S-function */
ssCallAccelRunBlock(S, 1, 37, SS_CALL_MDL_UPDATE);
}
/* atomic SubSystem Block: <Root>/Spectrum Scope */
if (ssIsSampleHit(S, 0, tid) || ssIsSampleHit(S, 2, tid)) {
cdma20001x_Spectrum_Scope_Update(S, tid);
}
}
/* Function to initialize sizes */
static void mdlInitializeSizes(SimStruct *S)
{
/* checksum */
ssSetChecksumVal(S, 0, 2925616763U);
ssSetChecksumVal(S, 1, 1384154605U);
ssSetChecksumVal(S, 2, 2279269747U);
ssSetChecksumVal(S, 3, 4151154494U);
/* options */
ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);
/* Accelerator check memory map size match for DWork */
if (ssGetSizeofDWork(S) != sizeof(cdma20001x_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(cdma20001x_BlockIO)) {
ssSetErrorStatus(S,"Unexpected error: Internal BlockIO sizes do "
"not match for accelerator mex file.");
}
/* model parameters */
_ssSetDefaultParam(S, (real_T *) &cdma20001x_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 + -