Skip to content

Commit

Permalink
firdes/autotest: testing frequency response for rnyquist filters
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaeddert committed Apr 17, 2024
1 parent 34977c8 commit 78dd6dc
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions src/filter/tests/firdes_autotest.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,45 +89,51 @@ void autotest_liquid_firdes_rrcos() {
CONTEND_DELTA( h[i], h0[i], 0.00001f );
}


void autotest_liquid_firdes_rkaiser()
void test_harness_matched_filter(int _type,
unsigned int _k,
unsigned int _m,
float _beta,
float _tol_isi,
float _tol_as)
{
// Initialize variables
unsigned int k=2, m=10;
float beta=0.3f;
float offset=0.0f;
float isi_test = -60.0f;

// Create filter
unsigned int h_len = 2*k*m+1;
unsigned int h_len = 2*_k*_m+1;
float h[h_len];
liquid_firdes_rkaiser(k,m,beta,offset,h);
liquid_firdes_prototype(_type,_k,_m,_beta,0.0f,h);

// scale by samples per symbol
liquid_vectorf_mulscalar(h, h_len, 1.0f/(float)k, h);
liquid_vectorf_mulscalar(h, h_len, 1.0f/(float)_k, h);

// compute filter ISI
float isi_max;
float isi_rms;
liquid_filter_isi(h,k,m,&isi_rms,&isi_max);
liquid_filter_isi(h,_k,_m,&isi_rms,&isi_max);

// convert to log scale
isi_max = 20*log10f(isi_max);
isi_rms = 20*log10f(isi_rms);

// ensure ISI is sufficiently small
CONTEND_LESS_THAN(isi_max, isi_test);
CONTEND_LESS_THAN(isi_rms, isi_test);
CONTEND_LESS_THAN(isi_max, _tol_isi);
CONTEND_LESS_THAN(isi_rms, _tol_isi);

// verify spectrum
autotest_psd_s regions[] = {
{.fmin=-0.50, .fmax=-0.35f, .pmin= 0, .pmax=-70, .test_lo=0, .test_hi=1},
{.fmin=-0.20, .fmax= 0.20f, .pmin=-1, .pmax= +1, .test_lo=1, .test_hi=1},
{.fmin= 0.35, .fmax= 0.50f, .pmin= 0, .pmax=-70, .test_lo=0, .test_hi=1},
{.fmin=-0.50, .fmax=-0.35f, .pmin= 0, .pmax=_tol_as, .test_lo=0, .test_hi=1},
{.fmin=-0.20, .fmax= 0.20f, .pmin=-1, .pmax= +1, .test_lo=1, .test_hi=1},
{.fmin= 0.35, .fmax= 0.50f, .pmin= 0, .pmax=_tol_as, .test_lo=0, .test_hi=1},
};
char filename[256];
sprintf(filename,"autotest/logs/firdes_%s.m", liquid_firfilt_type_str[_type][0]);
liquid_autotest_validate_psd_signalf(h, h_len, regions, 3,
liquid_autotest_verbose ? "autotest/logs/firdes_rkaiser.m" : NULL);
liquid_autotest_verbose ? filename : NULL);
}

// test matched filter responses for square-root nyquist filter prototypes
void autotest_firdes_rrcos () { test_harness_matched_filter(LIQUID_FIRFILT_RRC, 2, 10, 0.3f, -60.0f, -40.0f); }
void autotest_firdes_rkaiser () { test_harness_matched_filter(LIQUID_FIRFILT_RKAISER, 2, 10, 0.3f, -60.0f, -70.0f); }
void autotest_firdes_arkaiser() { test_harness_matched_filter(LIQUID_FIRFILT_ARKAISER,2, 10, 0.3f, -60.0f, -70.0f); }

void autotest_liquid_firdes_dcblock()
{
// options
Expand Down

0 comments on commit 78dd6dc

Please sign in to comment.