3 * Copyright 2006 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #include "encoder_convolutional_ic1_ic1.h"
24 #include <qa_encoder_convolutional_ic1_ic1.h>
25 #include <cppunit/TestAssert.h>
33 qa_encoder_convolutional_ic1_ic1::do_encoder_check
40 const int* code_generators,
41 const int* code_feedback)
43 std::vector<int> t_code_generators;
44 t_code_generators.assign (n_code_inputs * n_code_outputs, 0);
45 for (int m = 0; m < n_code_inputs * n_code_outputs; m++)
46 t_code_generators[m] = code_generators[m];
48 encoder_convolutional_ic1_ic1* t_encoder;
51 std::vector<int> t_code_feedback;
52 t_code_feedback.assign (n_code_inputs * n_code_outputs, 0);
53 for (int m = 0; m < n_code_inputs * n_code_outputs; m++)
54 t_code_feedback[m] = code_feedback[m];
56 t_encoder = new encoder_convolutional_ic1_ic1
63 t_encoder = new encoder_convolutional_ic1_ic1
70 char** t_out = new char*[n_code_outputs];
71 for (int m = 0; m < n_code_outputs; m++) {
72 t_out[m] = new char[n_output_items];
75 t_encoder->encode (c_in, (char**) t_out, n_output_items);
77 for (int m = 0; m < n_code_outputs; m++) {
78 for (int n = 0; n < n_output_items; n++) {
79 CPPUNIT_ASSERT_EQUAL (c_res[m][n], t_out[m][n]);
86 for (int m = 0; m < n_code_outputs; m++) {
96 // checking for SOAI realization (implicitely)
97 // no feedback, no termination
99 const static int t0_code_generator[6] = {1, 0, 5, 0, 1, 6};
100 const static int t0_n_code_inputs = 3;
101 const static int t0_n_code_outputs = 2;
102 const static int t0_n_input_items = 10;
103 const static int t0_n_output_items = 10;
105 const static char t0_in_0[t0_n_input_items] =
106 {0, 1, 0, 0, 1, 0, 1, 0, 0, 0};
107 const static char t0_in_1[t0_n_input_items] =
108 {0, 1, 0, 0, 0, 1, 1, 0, 0, 0};
109 const static char t0_in_2[t0_n_input_items] =
110 {0, 0, 1, 1, 1, 1, 1, 0, 0, 0};
111 const static char* t0_in[t0_n_code_inputs] =
112 {t0_in_0, t0_in_1, t0_in_2};
114 const static char t0_res_0[t0_n_output_items] =
115 {0, 1, 1, 1, 1, 0, 1, 1, 1, 0};
116 const static char t0_res_1[t0_n_output_items] =
117 {0, 1, 0, 1, 0, 1, 1, 0, 1, 0};
118 const static char* t0_res[t0_n_code_outputs] =
119 {t0_res_0, t0_res_1};
122 qa_encoder_convolutional_ic1_ic1::t0
125 do_encoder_check ((const char**) t0_in, (const char**) t0_res,
126 t0_n_output_items, 100, t0_n_code_inputs,
127 t0_n_code_outputs, (const int*) t0_code_generator);
132 // checking for SIAO realization (implicitely)
133 // no feedback, no termination
135 const static int t1_code_generator[6] = {1, 0, 0, 1, 5, 6};
136 const static int t1_n_code_inputs = 2;
137 const static int t1_n_code_outputs = 3;
138 const static int t1_n_input_items = 9;
139 const static int t1_n_output_items = 9;
141 const static char t1_in_0[t1_n_input_items] =
142 {0, 1, 1, 1, 0, 0, 0, 1, 0};
143 const static char t1_in_1[t1_n_input_items] =
144 {0, 0, 0, 0, 0, 1, 1, 1, 0};
145 const static char* t1_in[t1_n_code_inputs] =
148 const static char t1_res_0[t1_n_output_items] =
149 {0, 1, 1, 1, 0, 0, 0, 1, 0};
150 const static char t1_res_1[t1_n_output_items] =
151 {0, 0, 0, 0, 0, 1, 1, 1, 0};
152 const static char t1_res_2[t1_n_output_items] =
153 {0, 1, 1, 0, 1, 1, 1, 1, 0};
154 const static char* t1_res[t1_n_code_outputs] =
155 {t1_res_0, t1_res_1, t1_res_2};
158 qa_encoder_convolutional_ic1_ic1::t1
161 do_encoder_check ((const char**) t1_in, (const char**) t1_res,
162 t1_n_output_items, 100, t1_n_code_inputs,
163 t1_n_code_outputs, (const int*) t1_code_generator);
168 // checking for SIAO realization (implicitely)
169 // with same feedback, no termination
171 const static int t2_code_generator[6] = {1, 0, 0, 1, 5, 6};
172 const static int t2_code_feedback[6] = {0, 0, 0, 0, 7, 7};
173 const static int t2_n_code_inputs = 2;
174 const static int t2_n_code_outputs = 3;
175 const static int t2_n_input_items = 19;
176 const static int t2_n_output_items = 19;
178 const static char t2_in_0[t2_n_input_items] =
179 {0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0};
180 const static char t2_in_1[t2_n_input_items] =
181 {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0};
182 const static char* t2_in[t2_n_code_inputs] =
185 const static char t2_res_0[t2_n_output_items] =
186 {0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0};
187 const static char t2_res_1[t2_n_output_items] =
188 {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0};
189 const static char t2_res_2[t2_n_output_items] =
190 {0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0};
191 const static char* t2_res[t2_n_code_outputs] =
192 {t2_res_0, t2_res_1, t2_res_2};
195 qa_encoder_convolutional_ic1_ic1::t2
198 do_encoder_check ((const char**) t2_in, (const char**) t2_res,
199 t2_n_output_items, 100, t2_n_code_inputs,
200 t2_n_code_outputs, (const int*) t2_code_generator,
201 (const int*) t2_code_feedback);
206 // checking for SOAI realization (implicitely)
207 // with same feedback, no termination
209 const static int t3_code_generator[6] = {1, 0, 5, 0, 1, 6};
210 const static int t3_code_feedback[6] = {0, 0, 7, 0, 0, 7};
211 const static int t3_n_code_inputs = 3;
212 const static int t3_n_code_outputs = 2;
213 const static int t3_n_input_items = 17;
214 const static int t3_n_output_items = 17;
216 const static char t3_in_0[t3_n_input_items] =
217 {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0};
218 const static char t3_in_1[t3_n_input_items] =
219 {0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
220 const static char t3_in_2[t3_n_input_items] =
221 {0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0};
222 const static char* t3_in[t3_n_code_inputs] =
223 {t3_in_0, t3_in_1, t3_in_2};
225 const static char t3_res_0[t3_n_output_items] =
226 {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0};
227 const static char t3_res_1[t3_n_output_items] =
228 {0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0};
229 const static char* t3_res[t3_n_code_outputs] =
230 {t3_res_0, t3_res_1};
233 qa_encoder_convolutional_ic1_ic1::t3
236 do_encoder_check ((const char**) t3_in, (const char**) t3_res,
237 t3_n_output_items, 100, t3_n_code_inputs,
238 t3_n_code_outputs, (const int*) t3_code_generator,
239 (const int*) t3_code_feedback);
244 // checking for SIAO realization (implicitely),
245 // with different feedbacks, no termination
247 const static int t4_code_generator[6] = {1, 4, 0, 3, 1, 6};
248 const static int t4_code_feedback[6] = {0, 7, 0, 5, 0, 5};
249 const static int t4_n_code_inputs = 2;
250 const static int t4_n_code_outputs = 3;
251 const static int t4_n_input_items = 20;
252 const static int t4_n_output_items = 20;
254 const static char t4_in_0[t4_n_input_items] =
255 {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0};
256 const static char t4_in_1[t4_n_input_items] =
257 {0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0};
258 const static char* t4_in[t4_n_code_inputs] =
261 const static char t4_res_0[t4_n_output_items] =
262 {0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0};
263 const static char t4_res_1[t4_n_output_items] =
264 {0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0};
265 const static char t4_res_2[t4_n_output_items] =
266 {0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0};
267 const static char* t4_res[t4_n_code_outputs] =
268 {t4_res_0, t4_res_1, t4_res_2};
271 qa_encoder_convolutional_ic1_ic1::t4
274 do_encoder_check ((const char**) t4_in, (const char**) t4_res,
275 t4_n_output_items, 100, t4_n_code_inputs,
276 t4_n_code_outputs, (const int*) t4_code_generator,
277 (const int*) t4_code_feedback);
282 // checking for SOAI realization (implicitely),
283 // with different feedbacks, no termination
285 const static int t5_code_generator[6] = {1, 0, 0, 1, 5, 7};
286 const static int t5_code_feedback[6] = {0, 0, 0, 0, 7, 3};
287 const static int t5_n_code_inputs = 2;
288 const static int t5_n_code_outputs = 3;
289 const static int t5_n_input_items = 19;
290 const static int t5_n_output_items = 19;
292 const static char t5_in_0[t5_n_input_items] =
293 {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0};
294 const static char t5_in_1[t5_n_input_items] =
295 {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0};
296 const static char* t5_in[t5_n_code_inputs] =
299 const static char t5_res_0[t5_n_output_items] =
300 {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0};
301 const static char t5_res_1[t5_n_output_items] =
302 {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0};
303 const static char t5_res_2[t5_n_output_items] =
304 {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0};
305 const static char* t5_res[t5_n_code_outputs] =
306 {t5_res_0, t5_res_1, t5_res_2};
309 qa_encoder_convolutional_ic1_ic1::t5
313 do_encoder_check ((const char**) t5_in, (const char**) t5_res,
314 t5_n_output_items, 100, t5_n_code_inputs,
315 t5_n_code_outputs, (const int*) t5_code_generator);
321 // checking for termination, no feedback
323 const static int t6_code_generator[6] = {1, 0, 5, 0, 1, 6};
324 const static int t6_n_code_inputs = 3;
325 const static int t6_n_code_outputs = 2;
326 const static int t6_n_input_items = 6;
327 const static int t6_n_output_items = 8;
329 const static char t6_in_0[t6_n_input_items] =
331 const static char t6_in_1[t6_n_input_items] =
333 const static char t6_in_2[t6_n_input_items] =
335 const static char* t6_in[t6_n_code_inputs] =
336 {t6_in_0, t6_in_1, t6_in_2};
338 const static char t6_res_0[t6_n_output_items] =
339 {0, 1, 1, 1, 1, 1, 1, 0};
340 const static char t6_res_1[t6_n_output_items] =
341 {0, 1, 0, 1, 0, 0, 1, 0};
342 const static char* t6_res[t6_n_code_outputs] =
343 {t6_res_0, t6_res_1};
346 qa_encoder_convolutional_ic1_ic1::t6
349 do_encoder_check ((const char**) t6_in, (const char**) t6_res,
350 t6_n_output_items, 5, t6_n_code_inputs,
351 t6_n_code_outputs, (const int*) t6_code_generator);
356 // checking for termination, with same feedback
358 const static int t7_code_generator[6] = {1, 0, 5, 0, 1, 6};
359 const static int t7_code_feedback[6] = {0, 0, 7, 0, 0, 7};
360 const static int t7_n_code_inputs = 3;
361 const static int t7_n_code_outputs = 2;
362 const static int t7_n_input_items = 17;
363 const static int t7_n_output_items = 17;
365 const static char t7_in_0[t7_n_input_items] =
366 {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0};
367 const static char t7_in_1[t7_n_input_items] =
368 {0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
369 const static char t7_in_2[t7_n_input_items] =
370 {0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0};
371 const static char* t7_in[t7_n_code_inputs] =
372 {t7_in_0, t7_in_1, t7_in_2};
374 const static char t7_res_0[t7_n_output_items] =
375 {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0};
376 const static char t7_res_1[t7_n_output_items] =
377 {0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0};
378 const static char* t7_res[t7_n_code_outputs] =
379 {t7_res_0, t7_res_1};
382 qa_encoder_convolutional_ic1_ic1::t7
386 do_encoder_check ((const char**) t7_in, (const char**) t7_res,
387 t7_n_output_items, 5, t7_n_code_inputs,
388 t7_n_code_outputs, (const int*) t7_code_generator,
389 (const int*) t7_code_feedback);
395 // checking for termination, with different feedback
397 const static int t8_code_generator[6] = {1, 0, 5, 0, 1, 6};
398 const static int t8_code_feedback[6] = {0, 0, 7, 0, 0, 3};
399 const static int t8_n_code_inputs = 3;
400 const static int t8_n_code_outputs = 2;
401 const static int t8_n_input_items = 17;
402 const static int t8_n_output_items = 17;
404 const static char t8_in_0[t8_n_input_items] =
405 {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0};
406 const static char t8_in_1[t8_n_input_items] =
407 {0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
408 const static char t8_in_2[t8_n_input_items] =
409 {0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0};
410 const static char* t8_in[t8_n_code_inputs] =
411 {t8_in_0, t8_in_1, t8_in_2};
413 const static char t8_res_0[t8_n_output_items] =
414 {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0};
415 const static char t8_res_1[t8_n_output_items] =
416 {0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0};
417 const static char* t8_res[t8_n_code_outputs] =
418 {t8_res_0, t8_res_1};
421 qa_encoder_convolutional_ic1_ic1::t8
425 do_encoder_check ((const char**) t8_in, (const char**) t8_res,
426 t8_n_output_items, 5, t8_n_code_inputs,
427 t8_n_code_outputs, (const int*) t8_code_generator,
428 (const int*) t8_code_feedback);