root/experimental/components/SymbolSyncPoly/autotest_sources/SymbolSyncPoly_testsuite.h @ 3383

Revision 3383, 3.9 KB (checked in by jgaeddert, 6 years ago)

adding signal amplitude level assumption to SymbolSyncPolyDSP

Line 
1#ifndef __SYMBOLSYNCPOLYDSPTEST_H
2#define __SYMBOLSYNCPOLYDSPTEST_H
3
4#include <cxxtest/TestSuite.h>
5#include "../SymbolSyncPolyDSP.h"
6#include "I_in_rrc_qpsk_N512_dT0_dF0_k4_m4_b025_Npfb32.h"
7#include "Q_in_rrc_qpsk_N512_dT0_dF0_k4_m4_b025_Npfb32.h"
8#include "msg_i_rrc_qpsk_N512_dT0_dF0_k4_m4_b025_Npfb32.h"
9#include "msg_q_rrc_qpsk_N512_dT0_dF0_k4_m4_b025_Npfb32.h"
10
11//
12// A simple test suite: Just inherit CxxTest::TestSuite and write tests!
13//
14
15// NOTE: " : public CxxTest::TestSuite" must be on the same line as the class
16//       definition, otherwise the python script does not recognize it
17//       as a test class
18class SymbolSyncPoly_testsuite1 : public CxxTest::TestSuite,
19    public SymbolSyncPolyDSP
20{
21public:
22
23    void test1() {
24        // initialize variables
25        mf_i  = -10;
26        dmf_i =  10;
27        mf_q  =  10;
28        dmf_q =  10;
29        GenerateErrorSignal();
30        TS_ASSERT_DELTA( q, 0.0f/(Ac*Ac), 1e-6f );
31    }
32
33    void test2() {
34        // initialize variables
35        mf_i  =  30;
36        dmf_i =  5;
37        mf_q  =  20;
38        dmf_q =  1;
39        GenerateErrorSignal();
40        TS_ASSERT_DELTA( q, -85.0f/(Ac*Ac), 1e-12f );
41    }
42
43};
44
45
46class SymbolSyncPoly_testsuite_ComputeFilterBankIndex : public CxxTest::TestSuite,
47    public SymbolSyncPolyDSP
48{
49  public:
50    void testShift() {
51        // Normal operation
52        Npfb = 32;
53        b_soft = 11.0f;
54        ComputeFilterBankIndex();
55        TS_ASSERT_EQUALS( b, 11 );
56        TS_ASSERT_DELTA( b_soft, 11.0f, 0.0001f );
57        TS_ASSERT_EQUALS( lc, SHIFT );
58    }
59
60    void testStuff() {
61        // Filter bank overflow
62        Npfb = 32;
63        b_soft = 32.1f;
64        ComputeFilterBankIndex();
65        TS_ASSERT_EQUALS( b, 0 );
66        TS_ASSERT_DELTA( b_soft, 0.1f, 0.0001f );
67        TS_ASSERT_EQUALS( lc, STUFF );
68    }
69
70    void testSkip() {
71        // Filter bank underflow
72        Npfb = 32;
73        b_soft = -2.1f;
74        ComputeFilterBankIndex();
75        TS_ASSERT_EQUALS( b, 30 );
76        TS_ASSERT_DELTA( b_soft, 29.9f, 0.0001f );
77        TS_ASSERT_EQUALS( lc, SKIP );
78    }
79
80};
81
82class SymbolSyncPoly_symboltestsuite: public CxxTest::TestSuite
83{
84public:
85
86    void testBasicSynchronization() {
87        SymbolSyncPolyDSP symbolSync;
88        //read buffer
89//      float nominal_test_vector_I, nominal_test_vector_Q;
90        short nominal_expected_results_I, nominal_expected_results_Q;
91        short nominal_test_vector_I_short, nominal_test_vector_Q_short;
92
93//get n
94
95        //float to short conversion
96        float max_float_value = 3;   //double check this value later if signal is noisy
97        short max_short_value = 32767;
98        float tmp_float;
99        unsigned int N_in = 512;
100        for(unsigned int i =0 ; i < N_in; i++){
101       
102            tmp_float = nominal_test_vector_I[i] / max_float_value; //gives a value between 0 and 1
103            nominal_test_vector_I_short = (short) (tmp_float * max_short_value);
104            tmp_float = nominal_test_vector_Q[i] / max_float_value; //gives a value between 0 and 1
105            nominal_test_vector_Q_short = (short) (tmp_float * max_short_value);
106
107        }
108
109
110
111
112       
113
114        //init variables
115        char type[] = "rrcos";
116        unsigned int k = 4;             //samples per symbol
117        unsigned int m = 4;             //symbol delay
118        float beta = .25;                       //rolloff factor
119        unsigned int Npfb = 32;         //polyphse filter bank size
120
121        unsigned int N_out = N_in/k + 0; //Need some buffer for mismatched samples per symbol
122        short* system_output_I = new short[N_out];
123        short* system_output_Q = new short[N_out];
124
125
126        symbolSync.ConfigureFilterBank(type, k, m, beta, Npfb);
127
128        //send test data
129
130        symbolSync.SynchronizeAndDecimate(&nominal_test_vector_I_short, &nominal_test_vector_Q_short, N_in, system_output_I, system_output_Q, N_out);
131
132        //verify
133        //TS_ASSERT_SAME_DATA(system_output_I, nominal_expected_results_I,N_out);
134        //TS_ASSERT_SAME_DATA(system_output_Q, nominal_expected_results_Q,N_out);
135
136        TS_WARN("Test not fully implemented");
137        delete [] system_output_I;
138        delete [] system_output_Q;
139    }
140
141
142};
143
144#endif
145
Note: See TracBrowser for help on using the browser.