📄 c4_std5.c
字号:
/* Include files */
#include "std5_sfun.h"
#include "c4_std5.h"
#define CHARTINSTANCE_CHARTNUMBER (chartInstance.chartNumber)
#define CHARTINSTANCE_INSTANCENUMBER (chartInstance.instanceNumber)
#include "std5_sfun_debug_macros.h"
/* Type Definitions */
/* Named Constants */
#define c4_IN_NO_ACTIVE_CHILD (0)
/* Variable Declarations */
/* Variable Definitions */
static SFc4_std5InstanceStruct chartInstance;
/* Function Declarations */
static void initialize_c4_std5(void);
static void initialize_params_c4_std5(void);
static void enable_c4_std5(void);
static void disable_c4_std5(void);
static void finalize_c4_std5(void);
static void sf_c4_std5(void);
static void c4_eML_blk_kernel(creal_T *c4_b_freq_tr_syms, creal_T
*c4_b_channel_estimate);
static const mxArray *c4_sf_marshall(void *c4_chartInstance, void *c4_u);
static const mxArray *c4_b_sf_marshall(void *c4_chartInstance, void *c4_u);
static const mxArray *c4_c_sf_marshall(void *c4_chartInstance, void *c4_u);
static const mxArray *c4_d_sf_marshall(void *c4_chartInstance, void *c4_u);
static const mxArray *c4_e_sf_marshall(void *c4_chartInstance, void *c4_u);
static creal_T *c4_channel_estimate(void);
static creal_T *c4_freq_tr_syms(void);
static void init_dsm_address_info(void);
/* Function Definitions */
static void initialize_c4_std5(void)
{
_sfTime_ = (real_T)ssGetT(chartInstance.S);
chartInstance.c4_is_active_c4_std5 = 0U;
}
static void initialize_params_c4_std5(void)
{
}
static void enable_c4_std5(void)
{
}
static void disable_c4_std5(void)
{
}
static void finalize_c4_std5(void)
{
}
static void sf_c4_std5(void)
{
uint8_T c4_previousEvent;
int32_T c4_i0;
int32_T c4_i1;
creal_T c4_dcv0[104];
creal_T c4_dcv1[52];
int32_T c4_i2;
_sfTime_ = (real_T)ssGetT(chartInstance.S);
c4_previousEvent = _sfEvent_;
_sfEvent_ = CALL_EVENT;
_SFD_CC_CALL(CHART_ENTER_DURING_FUNCTION_TAG,3);
for(c4_i0 = 0; c4_i0 < 2; c4_i0 = c4_i0 + 1) {
for(c4_i1 = 0; c4_i1 < 52; c4_i1 = c4_i1 + 1) {
c4_dcv0[c4_i1 + 52 * c4_i0].re = c4_freq_tr_syms()[c4_i1 + 52 * c4_i0].re;
c4_dcv0[c4_i1 + 52 * c4_i0].im = c4_freq_tr_syms()[c4_i1 + 52 * c4_i0].im;
}
}
c4_eML_blk_kernel((creal_T *)c4_dcv0, (creal_T *)c4_dcv1);
for(c4_i2 = 0; c4_i2 < 52; c4_i2 = c4_i2 + 1) {
c4_channel_estimate()[c4_i2].re = c4_dcv1[c4_i2].re;
c4_channel_estimate()[c4_i2].im = c4_dcv1[c4_i2].im;
}
_SFD_CC_CALL(EXIT_OUT_OF_FUNCTION_TAG,3);
_sfEvent_ = c4_previousEvent;
sf_debug_check_for_state_inconsistency(_std5MachineNumber_,
chartInstance.chartNumber, chartInstance.instanceNumber);
}
static void c4_eML_blk_kernel(creal_T *c4_b_freq_tr_syms, creal_T
*c4_b_channel_estimate)
{
creal_T c4_channel_estimate1[52];
creal_T c4_mean_symbols[52];
real_T c4_long_f_symbols[52];
int32_T c4_i3;
static real_T c4_dv0[52] = { 1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 1.0,
-1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0,
-1.0, 1.0, -1.0, -1.0, -1.0
, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0
};
int32_T c4_i4;
real_T c4_y[2];
int32_T c4_i5;
real_T c4_b_y[52];
int32_T c4_i6;
int32_T c4_iv0[52];
int32_T c4_i7;
int32_T c4_iv1[2];
int32_T c4_i8;
int32_T c4_i9;
creal_T c4_x[104];
int32_T c4_i10;
int32_T c4_i11;
creal_T c4_b_x[104];
int32_T c4_i12;
int32_T c4_i13;
creal_T c4_c_x[104];
int32_T c4_i14;
creal_T c4_d_x[52];
int32_T c4_i15;
creal_T c4_e_x[52];
int32_T c4_ix;
int32_T c4_iy;
int32_T c4_i;
int32_T c4_ixstart;
int32_T c4_a;
creal_T c4_f_x;
creal_T c4_s;
int32_T c4_b_a;
creal_T c4_g_x;
creal_T c4_r;
int32_T c4_c_a;
int32_T c4_i16;
creal_T c4_h_x[52];
int32_T c4_i17;
real_T c4_k;
real_T c4_b_k;
creal_T c4_xk;
real_T c4_ar;
real_T c4_ai;
real_T c4_cr;
real_T c4_ci;
int32_T c4_i18;
int32_T c4_i19;
sf_debug_symbol_scope_push(5U, 0U);
sf_debug_symbol_scope_add("channel_estimate1", &c4_channel_estimate1,
c4_e_sf_marshall);
sf_debug_symbol_scope_add("mean_symbols", &c4_mean_symbols, c4_d_sf_marshall);
sf_debug_symbol_scope_add("long_f_symbols", &c4_long_f_symbols,
c4_c_sf_marshall);
sf_debug_symbol_scope_add("channel_estimate", c4_b_channel_estimate,
c4_b_sf_marshall);
sf_debug_symbol_scope_add("freq_tr_syms", c4_b_freq_tr_syms, c4_sf_marshall);
CV_EML_FCN(0, 0);
_SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,5);
for(c4_i3 = 0; c4_i3 < 52; c4_i3 = c4_i3 + 1) {
c4_long_f_symbols[c4_i3] = c4_dv0[c4_i3];
}
_SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,7);
for(c4_i4 = 0; c4_i4 < 2; c4_i4 = c4_i4 + 1) {
c4_y[c4_i4] = 1.0 + (real_T)c4_i4;
}
for(c4_i5 = 0; c4_i5 < 52; c4_i5 = c4_i5 + 1) {
c4_b_y[c4_i5] = 1.0 + (real_T)c4_i5;
}
for(c4_i6 = 0; c4_i6 < 52; c4_i6 = c4_i6 + 1) {
c4_iv0[c4_i6] = (int32_T)_SFD_EML_ARRAY_BOUNDS_CHECK("freq_tr_syms",
(int32_T)_SFD_INTEGER_CHECK("", c4_b_y[c4_i6]), 1, 52, 1) - 1;
}
for(c4_i7 = 0; c4_i7 < 2; c4_i7 = c4_i7 + 1) {
c4_iv1[c4_i7] = (int32_T)_SFD_EML_ARRAY_BOUNDS_CHECK("freq_tr_syms",
(int32_T)_SFD_INTEGER_CHECK("", c4_y[c4_i7]), 1, 2, 2) - 1;
}
for(c4_i8 = 0; c4_i8 < 52; c4_i8 = c4_i8 + 1) {
for(c4_i9 = 0; c4_i9 < 2; c4_i9 = c4_i9 + 1) {
c4_x[c4_i9 + (c4_i8 << 1)].re = c4_b_freq_tr_syms[c4_iv0[c4_i8] + 52 *
c4_iv1[c4_i9]].re;
c4_x[c4_i9 + (c4_i8 << 1)].im = c4_b_freq_tr_syms[c4_iv0[c4_i8] + 52 *
c4_iv1[c4_i9]].im;
}
}
for(c4_i10 = 0; c4_i10 < 52; c4_i10 = c4_i10 + 1) {
for(c4_i11 = 0; c4_i11 < 2; c4_i11 = c4_i11 + 1) {
c4_b_x[c4_i11 + (c4_i10 << 1)].re = c4_x[c4_i11 + (c4_i10 << 1)].re;
c4_b_x[c4_i11 + (c4_i10 << 1)].im = c4_x[c4_i11 + (c4_i10 << 1)].im;
}
}
for(c4_i12 = 0; c4_i12 < 52; c4_i12 = c4_i12 + 1) {
for(c4_i13 = 0; c4_i13 < 2; c4_i13 = c4_i13 + 1) {
c4_c_x[c4_i13 + (c4_i12 << 1)].re = c4_b_x[c4_i13 + (c4_i12 << 1)].re;
c4_c_x[c4_i13 + (c4_i12 << 1)].im = c4_b_x[c4_i13 + (c4_i12 << 1)].im;
}
}
for(c4_i14 = 0; c4_i14 < 52; c4_i14 = c4_i14 + 1) {
c4_d_x[c4_i14].re = 0.0;
c4_d_x[c4_i14].im = 0.0;
}
for(c4_i15 = 0; c4_i15 < 52; c4_i15 = c4_i15 + 1) {
c4_e_x[c4_i15].re = c4_d_x[c4_i15].re;
c4_e_x[c4_i15].im = c4_d_x[c4_i15].im;
}
c4_ix = 0;
c4_iy = 0;
for(c4_i = 1; c4_i < 53; c4_i = c4_i + 1) {
c4_ixstart = c4_ix;
c4_a = c4_ixstart;
c4_ixstart = c4_a + 1;
c4_ix = c4_ixstart;
c4_f_x.re = c4_c_x[_SFD_EML_ARRAY_BOUNDS_CHECK("x", _SFD_INTEGER_CHECK("ix",
(real_T)c4_ix), 1, 104, 1) - 1].re;
c4_f_x.im = c4_c_x[_SFD_EML_ARRAY_BOUNDS_CHECK("x", _SFD_INTEGER_CHECK("ix",
(real_T)c4_ix), 1, 104, 1) - 1].im;
c4_s.re = c4_f_x.re;
c4_s.im = c4_f_x.im;
c4_b_a = c4_ix;
c4_ix = c4_b_a + 1;
c4_g_x.re = c4_c_x[_SFD_EML_ARRAY_BOUNDS_CHECK("x", _SFD_INTEGER_CHECK("ix",
(real_T)c4_ix), 1, 104, 1) - 1].re;
c4_g_x.im = c4_c_x[_SFD_EML_ARRAY_BOUNDS_CHECK("x", _SFD_INTEGER_CHECK("ix",
(real_T)c4_ix), 1, 104, 1) - 1].im;
c4_r.re = c4_g_x.re;
c4_r.im = c4_g_x.im;
c4_s.re = c4_s.re + c4_r.re;
c4_s.im = c4_s.im + c4_r.im;
c4_c_a = c4_iy;
c4_iy = c4_c_a + 1;
c4_e_x[_SFD_EML_ARRAY_BOUNDS_CHECK("y", _SFD_INTEGER_CHECK("iy",
(real_T)c4_iy), 1, 52, 1) - 1].re = c4_s.re;
c4_e_x[_SFD_EML_ARRAY_BOUNDS_CHECK("y", _SFD_INTEGER_CHECK("iy",
(real_T)c4_iy), 1, 52, 1) - 1].im = c4_s.im;
}
for(c4_i16 = 0; c4_i16 < 52; c4_i16 = c4_i16 + 1) {
c4_h_x[c4_i16].re = c4_e_x[c4_i16].re;
c4_h_x[c4_i16].im = c4_e_x[c4_i16].im;
}
for(c4_i17 = 0; c4_i17 < 52; c4_i17 = c4_i17 + 1) {
c4_mean_symbols[c4_i17].re = 0.0;
c4_mean_symbols[c4_i17].im = 0.0;
}
for(c4_k = 1.0; c4_k <= 52.0; c4_k = c4_k + 1.0) {
c4_b_k = c4_k;
c4_xk.re = c4_h_x[(int32_T)_SFD_EML_ARRAY_BOUNDS_CHECK("x",
(int32_T)_SFD_INTEGER_CHECK("k", c4_b_k), 1, 52, 1) - 1].re;
c4_xk.im = c4_h_x[(int32_T)_SFD_EML_ARRAY_BOUNDS_CHECK("x",
(int32_T)_SFD_INTEGER_CHECK("k", c4_b_k), 1, 52, 1) - 1].im;
c4_ar = c4_xk.re;
c4_ai = c4_xk.im;
if(c4_ai == 0.0) {
c4_cr = c4_ar / 2.0;
c4_ci = 0.0;
} else {
c4_ci = c4_ai / 2.0;
c4_cr = c4_ar / 2.0;
}
c4_mean_symbols[(int32_T)_SFD_EML_ARRAY_BOUNDS_CHECK("z",
(int32_T)_SFD_INTEGER_CHECK("k", c4_b_k), 1, 52, 1) - 1].re = c4_cr;
c4_mean_symbols[(int32_T)_SFD_EML_ARRAY_BOUNDS_CHECK("z",
(int32_T)_SFD_INTEGER_CHECK("k", c4_b_k), 1, 52, 1) - 1].im = c4_ci;
}
_SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,8);
for(c4_i18 = 0; c4_i18 < 52; c4_i18 = c4_i18 + 1) {
c4_channel_estimate1[c4_i18].re = c4_dv0[c4_i18] *
c4_mean_symbols[c4_i18].re;
c4_channel_estimate1[c4_i18].im = c4_dv0[c4_i18] *
c4_mean_symbols[c4_i18].im;
}
_SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,9);
for(c4_i19 = 0; c4_i19 < 52; c4_i19 = c4_i19 + 1) {
c4_b_channel_estimate[c4_i19].re = c4_channel_estimate1[c4_i19].re;
c4_b_channel_estimate[c4_i19].im = -c4_channel_estimate1[c4_i19].im;
}
/* search_win = 320; */
/* D = 16; */
/* delay_xcorr=rx_signal; */
/* ma_M=rx_signal; */
/* for i=1:search_win */
/* delay_xcorr(i)=rx_signal(i)*conj(rx_signal(D+i)); */
/* end */
/* */
/* for n=1:search_win */
/* */
/* sum_delay_xcorr=complex(0); */
/* for ii=1:2*D */
/* sum_delay_xcorr=sum_delay_xcorr+delay_xcorr(ii+n-1); */
/* end */
/* sum_delay_xcorr2=abs(sum_delay_xcorr)^2; */
/* */
/* */
/* p=0; */
/* for iii=1:2*D */
/* pwr=abs(rx_signal(n+iii+D-1))^2; */
/* p=p+pwr; */
/* end */
/* p2=p^2; */
/* */
/* ma_M(n)=sum_delay_xcorr2/p2; */
/* */
/* end */
/* detected_packet = ma_M; */
/* rx_len = length(rx_signal); */
/* */
/* % Calculate the delayd correlation */
/* delay_xcorr = rx_signal(:,1:search_win+2*D).*conj(rx_signal(:,1*D+1:search_win+3*D)); */
/* */
/* % Moving average of the delayed correlation */
/* ma_delay_xcorr = abs(filter(ones(1,2*D), 1, delay_xcorr, [], 2)); */
/* */
/* % Moving average of received power */
/* ma_rx_pwr = filter(ones(1,2*D), 1, abs(rx_signal(:,1*D+1:search_win+3*D)).^2,[], 2); */
/* */
/* % The decision variable */
/* delay_len = length(ma_delay_xcorr); */
/* ma_M = ma_delay_xcorr(:,1:delay_len)./ma_rx_pwr(:,1:delay_len); */
/* */
/* % remove delay samples */
/* ma_M(:,1:2*D) = []; */
/* */
/* % combine antennas, if rx diversity is used */
/* ma_M = sum(ma_M, 1); */
/* */
/* if ~sim_options.UseRxDiv */
/* threshold = 0.75; */
/* else */
/* threshold = 1.5; */
/* end */
/* */
/* thres_idx = find(ma_M > threshold); */
/* if isempty(thres_idx) */
/* thres_idx = 1; */
/* else */
/* thres_idx = thres_idx(1); */
/* end */
/* */
/* else */
/* thres_idx = sim_consts.ExtraNoiseSamples; */
/* end; */
/* */
/* % check if the packet has been detected too late, */
/* % > sim_consts.extra_noise_samples + 35 index */
/* % is out of range of the fine timing algorithm */
/* % This prevents simulation error for code running out samples */
/* if thres_idx > sim_consts.ExtraNoiseSamples + 35 */
/* thres_idx = 1; */
/* end */
/* */
/* detected_packet = rx_signal(:,thres_idx:length(rx_signal)); */
_SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,-9);
sf_debug_symbol_scope_pop();
}
static const mxArray *c4_sf_marshall(void *c4_chartInstance, void *c4_u)
{
const mxArray *c4_y = NULL;
int32_T c4_i20;
int32_T c4_i21;
creal_T c4_b_u[104];
const mxArray *c4_b_y = NULL;
c4_y = NULL;
for(c4_i20 = 0; c4_i20 < 2; c4_i20 = c4_i20 + 1) {
for(c4_i21 = 0; c4_i21 < 52; c4_i21 = c4_i21 + 1) {
c4_b_u[c4_i21 + 52 * c4_i20].re = (*(creal_T (*)[104])c4_u)[c4_i21 + 52 *
c4_i20].re;
c4_b_u[c4_i21 + 52 * c4_i20].im = (*(creal_T (*)[104])c4_u)[c4_i21 + 52 *
c4_i20].im;
}
}
c4_b_y = NULL;
sf_mex_assign(&c4_b_y, sf_mex_create(&c4_b_u, "y", 0, 1U, 1U, 2, 52, 2));
sf_mex_assign(&c4_y, c4_b_y);
return c4_y;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -