diff options
16 files changed, 2647 insertions, 417 deletions
diff --git a/configure.ac b/configure.ac index 0e7c560c0..9da583ced 100644 --- a/configure.ac +++ b/configure.ac @@ -161,7 +161,7 @@ GRC_GR_AUDIO_PORTAUDIO dnl ***NOT TESTED*** GRC_GR_AUDIO_WINDOWS dnl ***NOT TESTED*** GRC_GR_ATSC GRC_GR_COMEDI -#GRC_GR_ERROR_CORRECTING_CODES dnl disabled until fix for ticket:25 +GRC_GR_ERROR_CORRECTING_CODES dnl disabled until fix for ticket:25 GRC_GR_GSM_FR_VOCODER GRC_GR_RADAR GRC_GR_RADIO_ASTRONOMY diff --git a/gr-error-correcting-codes/src/Makefile.am b/gr-error-correcting-codes/src/Makefile.am index a7da9c7ae..c6a4f7003 100644 --- a/gr-error-correcting-codes/src/Makefile.am +++ b/gr-error-correcting-codes/src/Makefile.am @@ -22,3 +22,5 @@ SUBDIRS = lib python MOSTLYCLEANFILES = *~ + +CONFIG_CLEAN_FILES = *.in diff --git a/gr-error-correcting-codes/src/lib/Makefile.am b/gr-error-correcting-codes/src/lib/Makefile.am index 75559527b..ca3c99c68 100644 --- a/gr-error-correcting-codes/src/lib/Makefile.am +++ b/gr-error-correcting-codes/src/lib/Makefile.am @@ -30,16 +30,14 @@ SUBDIRS = libecc ourpythondir = $(grpythondir) ourlibdir = $(grpythondir) -INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) +INCLUDES = $(PYTHON_CPPFLAGS) $(STD_DEFINES_AND_INCLUDES) -SWIGCPPPYTHONARGS = -fvirtual -python -modern $(PYTHON_CPPFLAGS) $(STD_DEFINES_AND_INCLUDES) +SWIGCPPPYTHONARGS = -fvirtual -python -modern $(PYTHON_CPPFLAGS) \ + $(STD_DEFINES_AND_INCLUDES) -ALL_IFILES = \ - $(LOCAL_IFILES) \ - $(NON_LOCAL_IFILES) +ALL_IFILES = $(LOCAL_IFILES) $(NON_LOCAL_IFILES) -NON_LOCAL_IFILES = \ - $(GNURADIO_I) +NON_LOCAL_IFILES = $(GNURADIO_I) LOCAL_IFILES = \ ecc_syms_to_metrics.i \ diff --git a/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.h b/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.h index 9f37f0525..b25f35b1f 100644 --- a/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.h +++ b/gr-error-correcting-codes/src/lib/ecc_metrics_decode_viterbi_full_block.h @@ -35,21 +35,23 @@ ecc_metrics_decode_viterbi_full_block_feedback_sptr; ecc_metrics_decode_viterbi_full_block_sptr ecc_make_metrics_decode_viterbi_full_block -(int frame_size_bits, +(int sample_precision, + int frame_size_bits, int n_code_inputs, int n_code_outputs, - std::vector<int> code_generator, + std::vector<int>& code_generator, bool do_termination = true, int start_memory_state = 0, int end_memory_state = 0); ecc_metrics_decode_viterbi_full_block_feedback_sptr ecc_make_metrics_decode_viterbi_full_block_feedback -(int frame_size_bits, +(int sample_precision, + int frame_size_bits, int n_code_inputs, int n_code_outputs, - std::vector<int> code_generator, - std::vector<int> code_feedback, + std::vector<int>& code_generator, + std::vector<int>& code_feedback, bool do_termination = true, int start_memory_state = 0, int end_memory_state = 0); @@ -72,7 +74,7 @@ protected: int frame_size_bits, int n_code_inputs, int n_code_outputs, - const std::vector<int> &code_generator, + const std::vector<int>& code_generator, bool do_termination, int start_memory_state, int end_memory_state); @@ -83,8 +85,8 @@ protected: int frame_size_bits, int n_code_inputs, int n_code_outputs, - const std::vector<int> &code_generator, - const std::vector<int> &code_feedback, + const std::vector<int>& code_generator, + const std::vector<int>& code_feedback, bool do_termination, int start_memory_state, int end_memory_state); @@ -124,7 +126,7 @@ protected: int frame_size_bits, int n_code_inputs, int n_code_outputs, - const std::vector<int> &code_generator, + const std::vector<int>& code_generator, bool do_termination, int start_memory_state, int end_memory_state); @@ -134,8 +136,8 @@ protected: int frame_size_bits, int n_code_inputs, int n_code_outputs, - const std::vector<int> &code_generator, - const std::vector<int> &code_feedback, + const std::vector<int>& code_generator, + const std::vector<int>& code_feedback, bool do_termination, int start_memory_state, int end_memory_state); @@ -154,7 +156,7 @@ public: ~ecc_metrics_decode_viterbi_full_block (); virtual void forecast (int noutput_items, - gr_vector_int &ninput_items_required); + gr_vector_int& ninput_items_required); virtual int general_work (int noutput_items, gr_vector_int &ninput_items, diff --git a/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.cc b/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.cc index c60eec8a7..0235ab69b 100644 --- a/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.cc +++ b/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.cc @@ -84,6 +84,7 @@ ecc_syms_to_metrics::ecc_syms_to_metrics // use the static "create" member function to create the actual // code_metrics to use. +#if 0 d_code_metrics_table = libecc_code_metrics_create_table<float> (&pdf_fcn_0, &pdf_fcn_1, @@ -95,6 +96,7 @@ ecc_syms_to_metrics::ecc_syms_to_metrics // get the output item size in bytes from the new code_metrics. d_out_item_size_bytes = d_code_metrics_table->out_item_size_bytes (); +#endif // set the output signature to match that which the code_metrics // will generate. @@ -136,8 +138,10 @@ ecc_syms_to_metrics::general_work void* t_out_buf_0_bit = (void*)(&(output_items[2*n])); void* t_out_buf_1_bit = (void*)(&(output_items[(2*n)+1])); +#if 0 d_code_metrics_table->convert (l_n_output_items, t_in_buf, t_out_buf_0_bit, t_out_buf_1_bit); +#endif } // consume the number of used input items on all input streams diff --git a/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.h b/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.h index 0f4577ad7..4405241f0 100644 --- a/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.h +++ b/gr-error-correcting-codes/src/lib/ecc_syms_to_metrics.h @@ -106,10 +106,16 @@ protected: int sample_precision); size_t d_out_item_size_bytes; +#if 0 code_metrics_table<float>* d_code_metrics_table; +#endif public: - ~ecc_syms_to_metrics() {delete d_code_metrics_table;}; + ~ecc_syms_to_metrics() { +#if 0 + delete d_code_metrics_table; +#endif + }; bool check_topology (int ninputs, int noutputs); diff --git a/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.cc b/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.cc index c04fafaec..aabb07958 100644 --- a/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.cc +++ b/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.cc @@ -30,7 +30,10 @@ #define DO_TIME_THOUGHPUT 0 #define DO_PRINT_DEBUG 0 -#define DO_PRINT_DEBUG_ENCODE 0 +#define DO_PRINT_DEBUG_VARS 0 +#define DO_PRINT_DEBUG_TERM 0 +#define DO_PRINT_DEBUG_TERM_END 0 +#define DO_PRINT_DEBUG_LOOKUP 0 #include <mld/mld_timer.h> #include <mld/n2bs.h> @@ -127,7 +130,7 @@ code_convolutional_trellis::code_convolutional_trellis_init d_do_streaming = (block_size_bits == 0); d_do_termination = (d_do_streaming == true) ? false : do_termination; - if (DO_PRINT_DEBUG) { + if (DO_PRINT_DEBUG_VARS) { std::cout << "d_block_size_bits = " << d_block_size_bits << "\n" "d_n_code_inputs = " << d_n_code_inputs << "\n" @@ -335,16 +338,16 @@ code_convolutional_trellis::code_convolutional_trellis_init d_n_memories = d_n_code_inputs; } - if (DO_PRINT_DEBUG) { + if (DO_PRINT_DEBUG_VARS) { std::cout << " t_total_n_delays_siao = " << d_total_n_delays << "\n" " t_total_n_delays_soai = " << t_total_n_delays_soai << "\n"; } - // pick which realization to use; soai is preferred since it's faster - // ... but unfortunately it's also less likely + // pick which realization to use; + // siao is preferred since it's easier to debug, and more likely - if (d_total_n_delays < t_total_n_delays_soai) { + if (d_total_n_delays <= t_total_n_delays_soai) { // use siao // nothing else to do, since the global variables already hold // the correct values. @@ -377,15 +380,16 @@ code_convolutional_trellis::code_convolutional_trellis_init d_n_states = (1 << d_total_n_delays); d_n_input_combinations = (1 << d_n_code_inputs); - memory_t t_mask = (memory_t)((2 << d_total_n_delays) - 1); + if (DO_PRINT_DEBUG_VARS) { + std::cout << + " d_n_states = " << d_n_states << "\n" + " d_n_input_combinations = " << d_n_input_combinations << "\n"; + } - if (end_memory_state & t_mask) { - std::cout << "code_convolutional_trellis: Warning: " << - "provided end memory state out (" << end_memory_state << - ") is out of the state range [0, " << - (d_n_states-1) << "]; masking off the unused bits.\n"; + if ((d_do_feedback == true) & (d_do_encode_soai == true)) { + // create the individual output bits used in soai feedback - end_memory_state &= t_mask; + d_ind_outputs.assign (d_n_memories, 0); } // create the max_mem_mask to be used in encoding @@ -399,10 +403,16 @@ code_convolutional_trellis::code_convolutional_trellis_init d_max_mem_masks[m] = (memory_t)((2 << (d_n_delays[m])) - 1); } - if (DO_PRINT_DEBUG) { + if (DO_PRINT_DEBUG_VARS) { std::cout << " d_n_memories = " << d_n_memories << "\n" - " d_total_n_delays = " << d_total_n_delays << "\n" + " d_total_n_delays = " << d_total_n_delays << " : ["; + for (size_t m = 0; m < d_n_memories; m++) { + std::cout << d_n_delays[m]; + if (m != (d_n_memories-1)) + std::cout << ", "; + } + std::cout << "]\n" << " d_max_delay = " << d_max_delay << "\n" " d_do_encode_soai = " << ((d_do_encode_soai == true) ? "true" : "false") << "\n"; @@ -419,6 +429,18 @@ code_convolutional_trellis::code_convolutional_trellis_init // create the trellis for this code: + memory_t t_mask = (memory_t)((1 << d_total_n_delays) - 1); + memory_t t_end_memory_state = (memory_t) end_memory_state; + + if (t_end_memory_state != (t_end_memory_state & t_mask)) { + std::cout << "code_convolutional_trellis: Warning: " << + "provided end memory state out (" << end_memory_state << + ") is out of the state range [0, " << + (d_n_states-1) << "]; masking off the unused bits.\n"; + + end_memory_state &= t_mask; + } + create_trellis (); if (d_do_termination == true) { @@ -541,11 +563,6 @@ void code_convolutional_trellis::create_trellis () { - if (DO_PRINT_DEBUG_ENCODE) { - std::cout << "c_t: # states = " << d_n_states << - ", d_n_input_combinations = " << d_n_input_combinations << "\n"; - } - // first dimension is the number of states d_trellis.resize (d_n_states); @@ -559,18 +576,13 @@ code_convolutional_trellis::create_trellis // fill in the trellis - for (memory_t m = 0; m < d_n_states; m++) { - for (memory_t n = 0; n < d_n_input_combinations; n++) { + for (size_t m = 0; m < d_n_states; m++) { + for (size_t n = 0; n < d_n_input_combinations; n++) { connection_t_ptr t_connection = &(d_trellis[m][n]); - encode_single (m, n, t_connection->d_to_state, + encode_single ((memory_t) m, + (memory_t) n, + t_connection->d_to_state, t_connection->d_output_bits); - if (DO_PRINT_DEBUG_ENCODE) { - std::cout << "set d_t[" << n2bs(m,d_total_n_delays) << "][" << - n2bs(n,d_n_code_inputs) << "] : to_st = " << - n2bs(t_connection->d_to_state,d_total_n_delays) << - ", o_b = " << n2bs(t_connection->d_output_bits,d_n_code_outputs) << - "\n"; - } } } } @@ -585,16 +597,9 @@ code_convolutional_trellis::demux_state // assumes state bits start after the LSB (not at &1) memories.resize (d_n_memories); - if (DO_PRINT_DEBUG_ENCODE) { - std::cout << "in_st = " << n2bs(in_state,d_total_n_delays) << " ->\n"; - } for (size_t m = 0; m < d_n_memories; m++) { memories[m] = (in_state << 1) & d_max_mem_masks[m]; in_state >>= d_n_delays[m]; - if (DO_PRINT_DEBUG_ENCODE) { - std::cout << " #d = " << d_n_delays[m] << ", mem[" << m << "] = " << - n2bs(memories[m], d_n_delays[m]+1) << "\n"; - } } } @@ -604,16 +609,12 @@ code_convolutional_trellis::mux_state { // mux bits for the given memory states in d_memory // assumes state bits start after the LSB (not at &1) + memory_t t_state = 0; size_t shift = 0; for (size_t m = 0; m < d_n_memories; m++) { t_state |= (memories[m] >> 1) << shift; shift += d_n_delays[m]; - if (DO_PRINT_DEBUG_ENCODE) { - std::cout << " #d = " << d_n_delays[m] << ", mem[" << m << "] = " << - n2bs(memories[m], d_n_delays[m]+1) << " -> st = " << - n2bs(t_state, d_total_n_delays) << "\n"; - } } return (t_state); } @@ -623,6 +624,9 @@ code_convolutional_trellis::demux_inputs (memory_t inputs, std::vector<char>& in_vec) { + // de-mux bits for the given inputs; + // copy them into the provided vector; + for (size_t m = 0; m < d_n_code_inputs; m++, inputs >>= 1) { in_vec[m] = (char)(inputs & 1); } @@ -632,6 +636,8 @@ memory_t code_convolutional_trellis::mux_inputs (const std::vector<char>& in_vec) { + // mux bits for the given inputs + size_t bit_shift = 0; memory_t inputs = 0; for (size_t m = 0; m < in_vec.size(); m++, bit_shift++) { @@ -645,6 +651,9 @@ code_convolutional_trellis::demux_outputs (memory_t outputs, std::vector<char>& out_vec) { + // de-mux bits for the given outputs; + // copy them into the provided vector; + for (size_t m = 0; m < d_n_code_outputs; m++, outputs >>= 1) { out_vec[m] = (char)(outputs & 1); } @@ -654,6 +663,8 @@ memory_t code_convolutional_trellis::mux_outputs (const std::vector<char>& out_vec) { + // mux bits for the given outputs + size_t bit_shift = 0; memory_t outputs = 0; for (size_t m = 0; m < out_vec.size(); m++, bit_shift++) { @@ -702,9 +713,19 @@ code_convolutional_trellis::encode_lookup const std::vector<char>& inputs, memory_t& out_bits) { + if (DO_PRINT_DEBUG_LOOKUP) { + std::cout << "e_l: in_st = " << n2bs(state,d_total_n_delays) << + ", in = " << n2bs(mux_inputs(inputs),d_n_code_inputs); + } + connection_t_ptr t_connection = &(d_trellis[state][mux_inputs(inputs)]); state = t_connection->d_to_state; out_bits = t_connection->d_output_bits; + + if (DO_PRINT_DEBUG_LOOKUP) { + std::cout << " -> out_st = " << n2bs(state,d_total_n_delays) << + ", out = " << n2bs(out_bits, d_n_code_outputs) << "\n"; + } } void @@ -713,25 +734,20 @@ code_convolutional_trellis::encode_lookup const std::vector<char>& inputs, std::vector<char>& out_bits) { + if (DO_PRINT_DEBUG_LOOKUP) { + std::cout << "e_l: in_st = " << n2bs(state,d_total_n_delays) << + ", in = " << n2bs(mux_inputs(inputs),d_n_code_inputs); + } + connection_t_ptr t_connection = &(d_trellis[state][mux_inputs(inputs)]); state = t_connection->d_to_state; demux_outputs (t_connection->d_output_bits, out_bits); -} -void -code_convolutional_trellis::get_termination_inputs -(memory_t term_start_state, - size_t bit_num, - std::vector<char>& inputs) -{ -#if 1 - // for now, just assign all 0's - inputs.assign (d_n_code_inputs, 0); -#else - for (size_t m = 0; m < d_n_code_inputs; m++) { - inputs[m] = ((d_term_inputs[term_start_state][m]) >> bit_num) & 1; + if (DO_PRINT_DEBUG_LOOKUP) { + std::cout << " -> out_st = " << n2bs(state,d_total_n_delays) << + ", out = " << n2bs(t_connection->d_output_bits, + d_n_code_outputs) << "\n"; } -#endif } void @@ -747,7 +763,6 @@ code_convolutional_trellis::create_termination_table // particular state, listed in order from LSB for the first input // bit to the MSB for the last input bit. -#if 0 // create a reverse trellis // it's temporary, just for doing the termination, so just do it locally @@ -758,62 +773,214 @@ code_convolutional_trellis::create_termination_table t_trellis.resize (d_n_states); // second dimension (one per first dimension) is the number of input - // combinations + // combinations; reserve so that the size() can be used for adding new for (size_t m = 0; m < d_n_states; m++) { - t_trellis[m].resize (d_n_input_combinations); + t_trellis[m].reserve (d_n_input_combinations); } - std::vector<char> outputs (d_n_code_outputs); - memory_t to_state; + std::vector<memory_t> tmp(d_n_memories); + demux_state (end_memory_state, tmp); - // fill in the trellis + memory_t to_state, outputs; + connection_t t_conn; - for (memory_t m = 0; m < d_n_states; m++) { - for (memory_t n = 0; n < d_n_input_combinations; n++) { - encode_single (m, n, to_state, outputs); + // fill in the trellis; discard the outputs + // set the trellis node's output bits to the input - connection_t_ptr t_connection = &(t_trellis[to_state][n]); - t_connection->d_to_state = m; -#if 0 - t_connection->d_output_bits.resize (d_n_code_outputs); - t_connection->d_output_bits = outputs; -#endif + for (size_t m = 0; m < d_n_states; m++) { + for (size_t n = 0; n < d_n_input_combinations; n++) { + to_state = outputs = 0; + + encode_single ((memory_t) m, + (memory_t) n, + to_state, + outputs); + + t_conn.d_to_state = (memory_t) m; + t_conn.d_output_bits = (memory_t) n; + t_trellis[to_state].push_back (t_conn); + + if (DO_PRINT_DEBUG_TERM) { + std::cout << "[" << n2bs(m,d_total_n_delays) << "][" << + n2bs(n,d_n_code_inputs) << "] -> " << + n2bs(to_state, d_total_n_delays) << "\n"; + } } } - // create the output vectors + if (DO_PRINT_DEBUG_TERM) { + std::cout << "Trellis:\n"; - term_input_t t_term_inputs; - t_term_inputs.resize (d_n_states); + for (size_t m = 0; m < d_n_states; m++) { + for (size_t n = 0; n < d_n_input_combinations; n++) { + std::cout << "[" << n2bs(t_trellis[m][n].d_to_state, + d_total_n_delays) << "] : [" << + n2bs(t_trellis[m][n].d_output_bits, d_n_code_inputs) << "] -> " << + n2bs(m, d_total_n_delays) << "\n"; + } + } + } + + // need 2 of most buffers: one for the current-in-use variables, and + // one for the to-be-determined variables + + // create the term input bit vectors + + term_input_t t_term_inputs[2]; + t_term_inputs[0].resize (d_n_states); + for (size_t m = 0; m < d_n_states; m++) { + t_term_inputs[0][m].assign (d_n_code_inputs, 0); + } + t_term_inputs[1].resize (d_n_states); for (size_t m = 0; m < d_n_states; m++) { - t_term_inputs[m].assign (d_n_code_inputs, 0); + t_term_inputs[1][m].assign (d_n_code_inputs, 0); } + // create the list of "in-use" states for the current t_term_inputs - std::vector<memory_t> t_used_states; - t_used_states.assign (d_n_states, 0); + std::vector<size_t> t_used_states_ndx[2]; + t_used_states_ndx[0].assign (d_n_states, 0); + t_used_states_ndx[1].assign (d_n_states, 0); + + std::vector<bool> t_in_use_states[2]; + t_in_use_states[0].assign (d_n_states, false); + t_in_use_states[1].assign (d_n_states, false); + + // termporary 'inputs' place holder, in order to use the class's + // built-in inputs demux'er. + + std::vector<char> t_inputs; + t_inputs.assign (d_n_code_inputs, 0); // setup the first state - t_states[0] = end_memory_state; - size_t n_states = 1; + size_t t_which_input = 0; + t_used_states_ndx[t_which_input][0] = (size_t) end_memory_state; + t_in_use_states[t_which_input][(size_t) end_memory_state] = true; + size_t n_states_used[2]; + n_states_used[t_which_input] = 1; + n_states_used[t_which_input^1] = 0; - for (size_t m = 0; m < d_total_n_delays; m++) { - for (size_t n = 0; n < n_states; n++) { - memory_t t_end_state = t_states[n]; - for (size_t p = 0; p < d_n_code_inputs; p++) { - connection_t_ptr t_connection = &(t_trellis[t_end_state][p]); - memory_t_ptr t_mem = &(t_term_inputs[t_end_state][p]); + // loop until either the number of states has been reached, or the + // number of input term bits (per stream) is too large (in which + // case this code can't be terminated ... shouldn't happen, but it's + // here just in case. + size_t n_input_term_bits = 0; + while ((n_states_used[t_which_input] < d_n_states) & + (n_input_term_bits < 2*d_total_n_delays)) { - + if (DO_PRINT_DEBUG_TERM) { + std::cout << "Starting loop:\n# states in use = " << + n_states_used[t_which_input] << " (of " << d_n_states << + "), # term bits = " << n_input_term_bits << " (of between " << + d_total_n_delays << " and " << (2*d_total_n_delays) << ")\n"; } + + // loop over all current in-use states + + for (size_t m = 0; m < n_states_used[t_which_input]; m++) { + + // get the current state to work with + + size_t t_state_ndx = t_used_states_ndx[t_which_input][m]; + + for (size_t p = 0; p < d_n_input_combinations; p++) { + memory_t t_from_state = t_trellis[t_state_ndx][p].d_to_state; + if (t_in_use_states[t_which_input^1][t_from_state] == false) { + // not currently in use; make use of it + // if it's already in use, then why duplicate the inputs? + + memory_t t_input = t_trellis[t_state_ndx][p].d_output_bits; + + if (DO_PRINT_DEBUG_TERM) { + std::cout << "doing st[" << n2bs(t_state_ndx,d_total_n_delays) << + "] <- [" << n2bs(t_from_state,d_total_n_delays) << "]: in = " << + n2bs(t_input, d_n_code_inputs) << "\n"; + } + + // copy over the current state's input bits to the 'from' + // state's input bits, in the "current" term inputs + + t_term_inputs[t_which_input^1][t_from_state] = + t_term_inputs[t_which_input][t_state_ndx]; + + // update the copied bits with the current inputs, in the + // correct bit position: LSB (&1) -> first input, LSB+1 (&2) + // -> second input, etc... + + demux_inputs (t_input, t_inputs); + + for (size_t n = 0; n < d_n_code_inputs; n++) { + memory_t t_term = t_term_inputs[t_which_input^1][t_from_state][n]; + t_term <<= 1; + t_term |= ((memory_t)(t_inputs[n] & 1)); + t_term_inputs[t_which_input^1][t_from_state][n] = t_term; + } + + // add this from state to the list of states for the next run + + t_used_states_ndx[t_which_input^1][n_states_used[t_which_input^1]] = + t_from_state; + + // and set that this state is in use + + t_in_use_states[t_which_input^1][t_from_state] = true; + + // increase the number of next used states + + n_states_used[t_which_input^1] += 1; + } + } + } + + // update / reset variables for this run-through + + // swap buffers ("^1" is always the next set of buffers) + + t_which_input ^= 1; + + // zero the next # of states used + + n_states_used[t_which_input^1] = 0; + + // reset the next 'in use' buffer + + t_in_use_states[t_which_input^1].assign (d_n_states, false); + + // increase the number of required term bits (per stream) + + n_input_term_bits++; } - t_inputs[0] = t_trellis -#endif + if (n_states_used[t_which_input] != d_n_states) { + std::cerr << "code_convolutional_trellis::create_termination_table: " + "Warning: Unable to determine all required termination inputs for the " + "provided termination state. Turning termination off.\n"; + d_do_termination = false; + } else { + d_n_bits_to_term = n_input_term_bits; + + d_term_inputs.resize (d_n_states); + for (size_t m = 0; m < d_n_states; m++) { + d_term_inputs[m].assign (d_n_code_inputs, 0); + } + + d_term_inputs = t_term_inputs[t_which_input]; + + if (DO_PRINT_DEBUG_TERM_END) { + std::cout << "# Term inputs / stream = " << d_n_bits_to_term << "\n"; + + for (size_t m = 0; m < d_n_states; m++) { + for (size_t n = 0; n < d_n_code_inputs; n++) { + std::cout << " [" << n2bs(m,d_total_n_delays) << "][" << n << + "] = " << n2bs(d_term_inputs[m][n], d_n_bits_to_term) << "\n"; + } + } + } + } } void @@ -909,13 +1076,15 @@ code_convolutional_trellis::encode_single_soai_fb for (size_t p = 0; p < d_n_memories; p++) { if (DO_PRINT_DEBUG) { - std::cout << "m_i[" << p << "] = " << d_memory[p]; + std::cout << "m_i[" << p << "] = " << + n2bs(d_memory[p], 1+d_n_delays[p]); } d_memory[p] >>= 1; if (DO_PRINT_DEBUG) { - std::cout << " -> " << d_memory[p] << "\n"; + std::cout << " >>= 1 -> " << + n2bs(d_memory[p], 1+d_n_delays[p]) << "\n"; } } @@ -923,9 +1092,26 @@ code_convolutional_trellis::encode_single_soai_fb // generators into the correct state's memory. for (size_t m = 0; m < d_n_code_inputs; m++) { + if (DO_PRINT_DEBUG) { + std::cout << "in[" << m << "] = " << ((int)d_current_inputs[m]) << "\n"; + } + if (d_current_inputs[m] == 1) { for (size_t n = 0; n < d_n_code_outputs; n++) { + if (DO_PRINT_DEBUG) { + size_t p = d_states_ndx[maio(m,n)]; + std::cout << "d_m[" << p << "] = " << + n2bs(d_memory[p], 1+d_n_delays[p]) << + " ^= c_g[" << maio(m,n) << "] = " << + n2bs(d_code_generators[maio(m,n)],1+d_n_delays[p]); + } + d_memory[d_states_ndx[maio(m,n)]] ^= d_code_generators[maio(m,n)]; + + if (DO_PRINT_DEBUG) { + size_t p = d_states_ndx[maio(m,n)]; + std::cout << " -> " << n2bs(d_memory[p],1+d_n_delays[p]) << "\n"; + } } } } @@ -938,7 +1124,18 @@ code_convolutional_trellis::encode_single_soai_fb // memory(ies) into the correct output bit for (size_t p = 0; p < d_n_memories; p++) { - d_current_outputs[d_io_num[p]] ^= ((char)(d_memory[p] & 1)); + if (DO_PRINT_DEBUG) { + std::cout << "c_o[" << d_io_num[p] << "] = " << + n2bs(d_current_outputs[d_io_num[p]],1) << " ^= m[" << + p << "]&1 = " << n2bs(d_memory[p],1); + } + + d_ind_outputs[p] = ((char)(d_memory[p] & 1)); + d_current_outputs[d_io_num[p]] ^= d_ind_outputs[p]; + + if (DO_PRINT_DEBUG) { + std::cout << " -> " << n2bs(d_current_outputs[d_io_num[p]],1) << "\n"; + } } // now that the output bits are fully created, XOR the FB back @@ -946,13 +1143,28 @@ code_convolutional_trellis::encode_single_soai_fb // off already so that it doesn't contribute. for (size_t p = 0; p < d_n_memories; p++) { - if (d_current_outputs[d_io_num[p]] == 1) { + if (DO_PRINT_DEBUG) { + std::cout << "i_o[" << p << "] = " << + n2bs(d_ind_outputs[p],1) << ", m[" << p << "] = " << + n2bs(d_memory[p],1+d_n_delays[p]); + } + + if (d_ind_outputs[p] == 1) { d_memory[p] ^= d_code_feedback[p]; + + if (DO_PRINT_DEBUG) { + std::cout << " ^= c_f[" << p << "] = " << + n2bs(d_code_feedback[p],1+d_n_delays[p]) << + " -> " << n2bs(d_memory[p],1+d_n_delays[p]); + } + } + if (DO_PRINT_DEBUG) { + std::cout << "\n"; } } if (DO_PRINT_DEBUG) { - std::cout << "ending encode_single_soai.\n"; + std::cout << "ending encode_single_soai_fb.\n"; } } diff --git a/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.h b/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.h index 3aee1a0a6..86165da32 100644 --- a/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.h +++ b/gr-error-correcting-codes/src/lib/libecc/code_convolutional_trellis.h @@ -156,16 +156,24 @@ public: inline const size_t n_code_inputs () {return (d_n_code_inputs);}; inline const size_t n_code_outputs () {return (d_n_code_outputs);}; inline const size_t n_states () {return (d_n_states);}; - inline const size_t n_input_combinations () {return (d_n_input_combinations);}; + inline const size_t n_input_combinations () + {return (d_n_input_combinations);}; inline const bool do_termination () {return (d_do_termination);}; inline const bool do_feedback () {return (d_do_feedback);}; inline const bool do_streaming () {return (d_do_streaming);}; + inline const bool do_encode_soai () {return (d_do_encode_soai);}; inline const size_t total_n_delays () {return (d_total_n_delays);}; + inline const size_t n_bits_to_term () {return (d_n_bits_to_term);}; virtual char sum_bits_mod2 (memory_t in_mem, size_t max_memory); void get_termination_inputs (memory_t term_start_state, size_t bit_num, - std::vector<char>& inputs); + std::vector<char>& inputs) { + // no error checking ... be careful! + for (size_t m = 0; m < d_n_code_inputs; m++) { + inputs[m] = ((d_term_inputs[term_start_state][m]) >> bit_num) & 1; + } + }; // encode_lookup: given the starting state and inputs, return the // resulting state and output bits. Two versions: the first is @@ -299,7 +307,6 @@ protected: bool d_do_streaming, d_do_termination, d_do_feedback, d_do_encode_soai; // "max_delay" is the max # of delays for all unique generators (ff and fb), - // needed to determine (e.g.) termination size_t d_max_delay; @@ -312,7 +319,7 @@ protected: // "total_n_delays" is the total # of delays, needed to determine the // # of states in the decoder - // "n_states" = (2^n_delays) - 1 .. the number of memory states + // "n_states" = (2^total_n_delays) - 1 .. the number of memory states size_t d_total_n_delays, d_n_states; @@ -363,11 +370,18 @@ protected: // first dimension is the memory state #; // second dimension is the input stream #; // bits are packed, with the first input being the LSB and the last - // input being closest to the MSB. + // input being farthest away from the LSB. typedef std::vector<std::vector<memory_t> > term_input_t; term_input_t d_term_inputs; + // "n_bits_to_term" is the number of bits to terminate the trellis + // to the desired state, as determined by the termination table. + // d_max_delay <= d_n_bits_to_term <= d_total_n_delays + // These numbers will vary depending on the realization. + + size_t d_n_bits_to_term; + // "inputs" are the current input bits, in the LSB (&1) of each "char" std::vector<char> d_current_inputs; @@ -376,6 +390,12 @@ protected: std::vector<char> d_current_outputs; + // "ind_outputs" are the current output bits, in the LSB (&1) of + // each "char", for each individual memory's computations; needed + // for soai-type feedback only + + std::vector<char> d_ind_outputs; + // "trellis" is the single-stage memory state transition ("trellis") // representation for this code; forward paths only diff --git a/gr-error-correcting-codes/src/lib/libecc/decoder.cc b/gr-error-correcting-codes/src/lib/libecc/decoder.cc index 256880e13..ff4889b23 100644 --- a/gr-error-correcting-codes/src/lib/libecc/decoder.cc +++ b/gr-error-correcting-codes/src/lib/libecc/decoder.cc @@ -69,7 +69,7 @@ decoder::decode if (d_out_buf->n_items_left() < n_bits_to_output) { std::cerr << "encoder::encode: Warning: output buffer size (" << - d_out_buf->n_items_left() << "is less than the desired number " + d_out_buf->n_items_left() << ") is less than the desired number " "of output items (" << n_bits_to_output << ") ... using lower number.\n"; n_bits_to_output = d_out_buf->n_items_left(); @@ -81,7 +81,7 @@ decoder::decode if (d_in_buf->n_items_left() < n_items_to_input) { std::cerr << "encoder::encode: Warning: input buffer size (" << - d_in_buf->n_items_left() << "is less than the computed number " + d_in_buf->n_items_left() << ") is less than the computed number " "of required input items (" << n_items_to_input << ") ... using lower number.\n"; n_items_to_input = d_in_buf->n_items_left(); @@ -156,7 +156,7 @@ decoder::decode if (d_in_buf->n_items_left() < n_items_to_input) { std::cerr << "encoder::encode: Warning: input buffer size (" << - d_in_buf->n_items_left() << "is less than the desired number " + d_in_buf->n_items_left() << ") is less than the desired number " "of input items (" << n_items_to_input << ") ... using lower number.\n"; n_items_to_input = d_in_buf->n_items_left(); @@ -168,7 +168,7 @@ decoder::decode if (d_out_buf->n_items_left() < n_bits_to_output) { std::cerr << "encoder::encode: Warning: output buffer size (" << - d_out_buf->n_items_left() << "is less than the computed number " + d_out_buf->n_items_left() << ") is less than the computed number " "of required output items (" << n_bits_to_output << ") ... using lower number.\n"; n_bits_to_output = d_out_buf->n_items_left(); diff --git a/gr-error-correcting-codes/src/lib/libecc/encoder.cc b/gr-error-correcting-codes/src/lib/libecc/encoder.cc index 967000fd0..7e7718af1 100644 --- a/gr-error-correcting-codes/src/lib/libecc/encoder.cc +++ b/gr-error-correcting-codes/src/lib/libecc/encoder.cc @@ -47,15 +47,18 @@ encoder::encode size_t n_bits_to_output) { if (in_buf == 0) { - std::cerr << "encoder::encode: Error: input buffer is NULL.\n"; + std::cerr << "encoder::encode{output}: Error: " + "input buffer is NULL.\n"; assert (0); } if (out_buf == 0) { - std::cerr << "encoder::encode: Error: output buffer is NULL.\n"; + std::cerr << "encoder::encode{output}: Error: " + "output buffer is NULL.\n"; assert (0); } if (n_bits_to_output == 0) { - std::cerr << "encoder::encode: Warning: no output bits requested.\n"; + std::cerr << "encoder::encode{output}: Warning: " + "no output bits requested.\n"; return (0); } @@ -68,10 +71,10 @@ encoder::encode // check that there are enough output buffer items if (d_out_buf->n_items_left() < n_bits_to_output) { - std::cerr << "encoder::encode: Warning: output buffer size (" << - d_out_buf->n_items_left() << "is less than the desired number " - "of output items (" << n_bits_to_output << - ") ... using lower number.\n"; + std::cerr << "encoder::encode{output}: Warning: " + "output buffer size (" << d_out_buf->n_items_left() << + ") is less than the desired number of output items (" << + n_bits_to_output << ") ... using lower number.\n"; n_bits_to_output = d_out_buf->n_items_left(); } @@ -80,18 +83,26 @@ encoder::encode size_t n_bits_to_input = compute_n_input_bits (n_bits_to_output); if (d_in_buf->n_items_left() < n_bits_to_input) { - std::cerr << "encoder::encode: Warning: input buffer size (" << - d_in_buf->n_items_left() << "is less than the computed number " + std::cerr << "encoder::encode{output}: Warning: input buffer size (" << + d_in_buf->n_items_left() << ") is less than the computed number " "of required input items (" << n_bits_to_input << ") ... using lower number.\n"; n_bits_to_input = d_in_buf->n_items_left(); n_bits_to_output = compute_n_output_bits (n_bits_to_input); } + // set the correct number of I/O bits + + d_n_bits_to_input = n_bits_to_input; + d_n_bits_to_output = n_bits_to_output; + if (DO_PRINT_DEBUG) { std::cout << - "# output bits = " << n_bits_to_output << "\n" - "# input bits = " << n_bits_to_input << "\n"; + "Before Encoding{output}:\n" + " # output bits = " << d_n_bits_to_output << "\n" + " # input bits = " << d_n_bits_to_input << "\n" + " # output bits used = " << d_out_buf->n_items_used() << "\n" + " # input bits used = " << d_in_buf->n_items_used() << "\n"; } // call the private encode function @@ -100,20 +111,16 @@ encoder::encode if (DO_PRINT_DEBUG) { std::cout << - "# input bits used = " << d_in_buf->n_items_used() << "\n" - "# output bits used = " << d_out_buf->n_items_used() << "\n"; + "After Encoding{output}:\n" + " # output bits = " << d_n_bits_to_output << "\n" + " # input bits = " << d_n_bits_to_input << "\n" + " # output bits used = " << d_out_buf->n_items_used() << "\n" + " # input bits used = " << d_in_buf->n_items_used() << "\n"; } - size_t n_items_used = d_in_buf->n_items_used (); - - // clear these buffers, just in case - - d_in_buf = 0; - d_out_buf = 0; - // return the actual number of input bits used - return (n_items_used); + return (n_bits_to_input - d_n_bits_to_input); } /* @@ -134,15 +141,15 @@ encoder::encode code_output_ptr out_buf) { if (in_buf == 0) { - std::cerr << "encoder::encode: Error: input buffer is NULL.\n"; + std::cerr << "encoder::encode{input}: Error: input buffer is NULL.\n"; assert (0); } if (out_buf == 0) { - std::cerr << "encoder::encode: Error: output buffer is NULL.\n"; + std::cerr << "encoder::encode{input}: Error: output buffer is NULL.\n"; assert (0); } if (n_bits_to_input == 0) { - std::cerr << "encoder::encode: Warning: no input bits requested.\n"; + std::cerr << "encoder::encode{input}: Warning: no input bits requested.\n"; return (0); } @@ -155,8 +162,8 @@ encoder::encode // check that there are enough input buffer items if (d_in_buf->n_items_left() < n_bits_to_input) { - std::cerr << "encoder::encode: Warning: input buffer size (" << - d_in_buf->n_items_left() << "is less than the desired number " + std::cerr << "encoder::encode{input}: Warning: input buffer size (" << + d_in_buf->n_items_left() << ") is less than the desired number " "of input items (" << n_bits_to_input << ") ... using lower number.\n"; n_bits_to_input = d_in_buf->n_items_left(); @@ -167,18 +174,26 @@ encoder::encode size_t n_bits_to_output = compute_n_output_bits (n_bits_to_input); if (d_out_buf->n_items_left() < n_bits_to_output) { - std::cerr << "encoder::encode: Warning: output buffer size (" << - d_out_buf->n_items_left() << "is less than the computed number " + std::cerr << "encoder::encode{input}: Warning: output buffer size (" << + d_out_buf->n_items_left() << ") is less than the computed number " "of required output items (" << n_bits_to_output << ") ... using lower number.\n"; n_bits_to_output = d_out_buf->n_items_left(); n_bits_to_input = compute_n_input_bits (n_bits_to_output); } + // set the correct number of I/O bits + + d_n_bits_to_input = n_bits_to_input; + d_n_bits_to_output = n_bits_to_output; + if (DO_PRINT_DEBUG) { std::cout << - "# output bits = " << n_bits_to_output << "\n" - "# input bits = " << n_bits_to_input << "\n"; + "Before Encoding{input}:\n" + " # output bits = " << d_n_bits_to_output << "\n" + " # input bits = " << d_n_bits_to_input << "\n" + " # output bits used = " << d_out_buf->n_items_used() << "\n" + " # input bits used = " << d_in_buf->n_items_used() << "\n"; } // call the private encode function @@ -187,18 +202,14 @@ encoder::encode if (DO_PRINT_DEBUG) { std::cout << - "# input bits used = " << d_in_buf->n_items_used() << "\n" - "# output bits used = " << d_out_buf->n_items_used() << "\n"; + "After Encoding{input}:\n" + " # output bits = " << d_n_bits_to_output << "\n" + " # input bits = " << d_n_bits_to_input << "\n" + " # output bits used = " << d_out_buf->n_items_used() << "\n" + " # input bits used = " << d_in_buf->n_items_used() << "\n"; } - size_t n_items_used = d_out_buf->n_items_used(); - - // clear these buffers, just in case - - d_in_buf = 0; - d_out_buf = 0; - // return the actual number of output bits written - return (n_items_used); + return (n_bits_to_output - d_n_bits_to_output); } diff --git a/gr-error-correcting-codes/src/lib/libecc/encoder.h b/gr-error-correcting-codes/src/lib/libecc/encoder.h index 96ff9f411..b0f1a34bd 100644 --- a/gr-error-correcting-codes/src/lib/libecc/encoder.h +++ b/gr-error-correcting-codes/src/lib/libecc/encoder.h @@ -82,7 +82,7 @@ protected: virtual void encode_private () = 0; size_t d_block_size_bits, d_n_code_inputs, d_n_code_outputs; - size_t d_total_n_enc_bits; + size_t d_total_n_enc_bits, d_n_bits_to_input, d_n_bits_to_output; code_input_ptr d_in_buf; code_output_ptr d_out_buf; }; diff --git a/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.cc b/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.cc index a4634503b..b45f4c4aa 100644 --- a/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.cc +++ b/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.cc @@ -29,9 +29,9 @@ #include <iostream> #define DO_TIME_THOUGHPUT 0 +#define DO_PRINT_DEBUG_FSM 0 #include <mld/mld_timer.h> -//#include <mld/n2bs.h> void encoder_convolutional::encoder_convolutional_init @@ -67,6 +67,7 @@ encoder_convolutional::encoder_convolutional_init // set the initial FSM state to 'init' d_fsm_state = fsm_enc_conv_init; + d_n_enc_bits = 0; // create the class block variables @@ -76,15 +77,17 @@ encoder_convolutional::encoder_convolutional_init d_do_streaming = d_trellis->do_streaming (); d_do_termination = d_trellis->do_termination (); d_total_n_delays = d_trellis->total_n_delays (); + d_n_bits_to_term = d_trellis->n_bits_to_term (); // parse the init state - memory_t t_mask = (memory_t)((2 << d_total_n_delays) - 1); + memory_t t_mask = (memory_t)((1 << d_total_n_delays) - 1); size_t t_n_states = (1 << d_total_n_delays); + memory_t t_start_memory_state = (memory_t) start_memory_state; - if (start_memory_state & t_mask) { + if (t_start_memory_state != (t_start_memory_state & t_mask)) { std::cout << "encoder_convolutional: Warning: " << - "provided end memory state out (" << end_memory_state << + "provided start memory state (" << start_memory_state << ") is out of the state range [0, " << (t_n_states-1) << "]; masking off the unused bits.\n"; @@ -115,8 +118,9 @@ encoder_convolutional::encode_private // while there are inputs and outputs left to process ... - while ((d_in_buf->n_items_left() != 0) & - (d_out_buf->n_items_left() != 0)) { + while ((d_n_bits_to_input != 0) | + (d_n_bits_to_output != 0) | + (d_fsm_state == fsm_enc_conv_init)) { // jump to the correct state in the fsm @@ -124,6 +128,9 @@ encoder_convolutional::encode_private case fsm_enc_conv_init: + if (DO_PRINT_DEBUG_FSM) + std::cout << "Starting FSM Doing Init\n"; + // copy the init states to the current memory d_memory = d_init_state; @@ -141,16 +148,24 @@ encoder_convolutional::encode_private // move to the 'input' state d_fsm_state = fsm_enc_conv_doing_input; + + if (DO_PRINT_DEBUG_FSM) + std::cout << "FSM State set to Doing Input\n" + "Ending FSM Doing Init\n"; + break; case fsm_enc_conv_doing_input: + if (DO_PRINT_DEBUG_FSM) + std::cout << "Starting FSM Doing Input\n"; + // working through the trellis section which requires input bits // from external sources; loop up to the block size (before // termination bits, if any), counting down the number of // available input bits. - encode_loop (d_in_buf->n_items_left(), d_block_size_bits); + encode_loop (d_n_bits_to_input, d_block_size_bits); // finished this loop; check for jumping to the next state @@ -161,14 +176,28 @@ encoder_convolutional::encode_private if (d_do_termination == true) { d_n_enc_bits = 0; d_fsm_state = fsm_enc_conv_doing_term; + + if (DO_PRINT_DEBUG_FSM) + std::cout << "FSM State set to Doing Term\n"; + } else { d_fsm_state = fsm_enc_conv_init; + + if (DO_PRINT_DEBUG_FSM) + std::cout << "FSM State set to Init\n"; } } + + if (DO_PRINT_DEBUG_FSM) + std::cout << "Ending FSM Doing Input\n"; + break; case fsm_enc_conv_doing_term: + if (DO_PRINT_DEBUG_FSM) + std::cout << "Starting FSM Doing Term\n"; + // terminating the trellis, trying to get to a specific state; // better get here only when do_termination is true, but check // just in case; lop up to the max memory, counting down the @@ -180,17 +209,24 @@ encoder_convolutional::encode_private d_term_state = d_memory; } - encode_loop (d_out_buf->n_items_left(), d_total_n_delays); + encode_loop (d_n_bits_to_output, d_n_bits_to_term); // finished this loop; check for jumping to the next state - if (d_n_enc_bits == d_total_n_delays) + if (d_n_enc_bits == d_n_bits_to_term) { d_fsm_state = fsm_enc_conv_init; + if (DO_PRINT_DEBUG_FSM) + std::cout << "FSM State set to Init\n"; + } } else { // should never get here! assert (0); } + + if (DO_PRINT_DEBUG_FSM) + std::cout << "Ending FSM Doing Term\n"; + break; default: @@ -216,7 +252,7 @@ encoder_convolutional::encode_private void encoder_convolutional::encode_loop -(const size_t& which_counter, +(size_t& which_counter, size_t how_many) { // generic encode_loop @@ -254,28 +290,28 @@ encoder_convolutional::compute_n_output_bits t_n_output_bits = t_n_input_bits = n_input_bits; if (d_do_termination == true) { - // not streaming, doing termination; find the number of bits // currently available with no required inputs, if any - size_t n_extra = 0; + size_t t_n_blocks, t_n_extra; + t_n_blocks = t_n_extra = 0; + if (d_fsm_state == fsm_enc_conv_doing_term) { - n_extra = d_total_n_delays - d_n_enc_bits; - } - t_n_output_bits += n_extra; + t_n_extra = d_n_bits_to_term - d_n_enc_bits; + t_n_blocks = t_n_input_bits / d_block_size_bits; - // find the number of blocks using just input bits, - // as well as the number of leftover bits + } else { + // find the number of blocks which will be completed by the + // additional inputs - size_t t_n_blocks = t_n_input_bits / d_block_size_bits; - size_t t_leftover_bits = t_n_input_bits % d_block_size_bits; + t_n_blocks = (d_n_enc_bits + t_n_input_bits) / d_block_size_bits; + } - // add the number of bits*blocks to the number of output bits, as - // well as the number of leftover bits which are not a whole block + // add the number of term_bits*blocks to the number of output bits - t_n_output_bits += (t_n_blocks * (d_block_size_bits + d_total_n_delays)); - t_n_output_bits += t_leftover_bits; + t_n_output_bits += (t_n_blocks * d_n_bits_to_term); + t_n_output_bits += t_n_extra; } return (t_n_output_bits); @@ -295,7 +331,7 @@ encoder_convolutional::compute_n_input_bits size_t n_extra = 0; if (d_fsm_state == fsm_enc_conv_doing_term) { - n_extra = d_total_n_delays - d_n_enc_bits; + n_extra = d_n_bits_to_term - d_n_enc_bits; } // check to see if this is enough; return 0 if it is. @@ -306,25 +342,33 @@ encoder_convolutional::compute_n_input_bits // remove those which require no input t_n_output_bits -= n_extra; + t_n_input_bits -= n_extra; - // find the number of blocks of data which could be processed + // add into the output bits the number of currently encoded input bits - size_t t_n_output_bits_per_block = d_block_size_bits + d_total_n_delays; + if (d_fsm_state == fsm_enc_conv_doing_input) + t_n_output_bits += d_n_enc_bits; - // get the base number of input items required for the given - // number of blocks to be generated + // find the number of blocks of data which will create the + // remaining number of output bits, though possibly not the + // termination bits of a final block (done later) + size_t t_n_output_bits_per_block = d_block_size_bits + d_n_bits_to_term; size_t t_n_blocks = t_n_output_bits / t_n_output_bits_per_block; - t_n_input_bits = t_n_blocks * d_block_size_bits; - // add to that the number of leftover inputs needed to generate - // the remainder of the outputs within the remaining block, up to - // the given block size (since anything beyond that within this - // block requires no inputs) + // remove the termination bits from the remaining # of input bits + + t_n_input_bits -= (t_n_blocks * d_n_bits_to_term); + + // do the remaining inputs / outputs create at least 1 + // block_size_bits (but less than a full block + termination bits) - size_t t_leftover_bits = t_n_output_bits % t_n_output_bits_per_block; - t_n_input_bits += ((t_leftover_bits > d_block_size_bits) ? - d_block_size_bits : t_leftover_bits); + t_n_output_bits -= (t_n_blocks * t_n_output_bits_per_block); + + if (t_n_output_bits >= d_block_size_bits) { + n_extra = t_n_output_bits - d_block_size_bits; + t_n_input_bits -= n_extra; + } } return (t_n_input_bits); diff --git a/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.h b/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.h index 11c8b4e69..908ff416d 100644 --- a/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.h +++ b/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.h @@ -154,8 +154,10 @@ public: inline const bool do_termination () {return (d_do_termination);}; inline const bool do_feedback () {return (d_trellis->do_feedback());}; + inline const bool do_encode_soai () {return (d_trellis->do_encode_soai());}; inline const bool do_streaming () {return (d_do_streaming);}; inline const size_t total_n_delays () {return (d_total_n_delays);}; + inline const size_t n_bits_to_term () {return (d_n_bits_to_term);}; inline const code_convolutional_trellis* trellis() {return (d_trellis);}; protected: @@ -187,7 +189,7 @@ protected: int end_memory_state); virtual void encode_private (); - virtual void encode_loop (const size_t& which_counter, size_t how_many); + virtual void encode_loop (size_t& which_counter, size_t how_many); inline void get_next_inputs () { switch (d_fsm_state) { @@ -206,6 +208,7 @@ protected: inline virtual void get_next_inputs__input () { d_in_buf->read_items ((void*)(&(d_current_inputs[0]))); d_in_buf->increment_indices (); + d_n_bits_to_input--; }; inline virtual void get_next_inputs__term () { @@ -217,6 +220,7 @@ protected: inline virtual void write_output_bits () { d_out_buf->write_items ((const void*)(&(d_current_outputs[0]))); d_out_buf->increment_indices (); + d_n_bits_to_output--; }; void get_memory_requirements (size_t m, @@ -247,6 +251,13 @@ protected: std::vector<char> d_current_outputs; + // "n_bits_to_term" is the number of bits to terminate the trellis + // to the desired state, as determined by the termination table. + // d_max_delay <= d_n_bits_to_term <= d_total_n_delays + // These numbers will vary depending on the realization. + + size_t d_n_bits_to_term; + // "trellis" is the code trellis for the given input parameters code_convolutional_trellis* d_trellis; diff --git a/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.cc b/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.cc index e9c25794b..64c0cf16e 100644 --- a/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.cc +++ b/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.cc @@ -22,9 +22,8 @@ #include <n2bs.h> #include <iostream> -#include "../code_types.h" -const int g_num_bits_per_byte = 8; +static const int g_num_bits_per_byte = 8; std::string DoIt (int64_t number, size_t digits) { @@ -39,10 +38,10 @@ std::string DoIt (int64_t number, size_t digits) return (retVal); } -std::string n2bs (u_int8_t number, size_t digits) +std::string n2bs (int8_t number, size_t digits) { - if (digits > (sizeof (u_int8_t) * g_num_bits_per_byte)) - digits = sizeof (u_int8_t); + if (digits > (sizeof (int8_t) * g_num_bits_per_byte)) + digits = sizeof (int8_t); return DoIt ((int64_t) number, digits); } std::string n2bs (int16_t number, size_t digits) @@ -63,12 +62,10 @@ std::string n2bs (int64_t number, size_t digits) digits = sizeof (int64_t); return DoIt (number, digits); } - - -std::string n2bs (int8_t number, size_t digits) +std::string n2bs (u_int8_t number, size_t digits) { - if (digits > (sizeof (int8_t) * g_num_bits_per_byte)) - digits = sizeof (int8_t); + if (digits > (sizeof (u_int8_t) * g_num_bits_per_byte)) + digits = sizeof (u_int8_t); return DoIt ((int64_t) number, digits); } std::string n2bs (u_int16_t number, size_t digits) @@ -89,9 +86,3 @@ std::string n2bs (u_int64_t number, size_t digits) digits = sizeof (u_int64_t); return DoIt ((int64_t) number, digits); } - -void cout_binary (int number, int digits) -{ - while (digits-- > 0) - std::cout << ((number >> digits) & 1); -} diff --git a/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.cc b/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.cc index 7e9e1c37c..bba7dce7c 100644 --- a/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.cc +++ b/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.cc @@ -28,22 +28,36 @@ #include <iomanip> #include <stdio.h> +#define DO_PRINT_DEBUG 0 + +// test number counter + +static size_t g_t_num = 0; + void qa_encoder_convolutional_ic1_ic1::do_encoder_check -(int test_n, +(bool use_encode_in_or_out, const char** c_in, const char** c_res, - int n_input_items, - int n_output_items, - int block_size_bits, - int n_code_inputs, - int n_code_outputs, + const size_t n_io_items, + const size_t* n_input_items, + const size_t* n_output_items, + const size_t block_size_bits, + const size_t n_code_inputs, + const size_t n_code_outputs, const int* code_generators, - const int* code_feedback) + const int* code_feedback, + const bool do_termination, + const size_t start_state, + const size_t term_state, + const int encode_soai) { + if (DO_PRINT_DEBUG) + std::cout << "Starting Test " << g_t_num << "\n"; + std::vector<int> t_code_generators; t_code_generators.assign (n_code_inputs * n_code_outputs, 0); - for (int m = 0; m < n_code_inputs * n_code_outputs; m++) + for (size_t m = 0; m < (n_code_inputs * n_code_outputs); m++) t_code_generators[m] = code_generators[m]; encoder_convolutional* t_encoder; @@ -51,7 +65,7 @@ qa_encoder_convolutional_ic1_ic1::do_encoder_check if (code_feedback) { std::vector<int> t_code_feedback; t_code_feedback.assign (n_code_inputs * n_code_outputs, 0); - for (int m = 0; m < n_code_inputs * n_code_outputs; m++) + for (size_t m = 0; m < (n_code_inputs * n_code_outputs); m++) t_code_feedback[m] = code_feedback[m]; t_encoder = new encoder_convolutional @@ -59,39 +73,87 @@ qa_encoder_convolutional_ic1_ic1::do_encoder_check n_code_inputs, n_code_outputs, t_code_generators, - t_code_feedback); + t_code_feedback, + do_termination, + start_state, + term_state); } else { t_encoder = new encoder_convolutional (block_size_bits, n_code_inputs, n_code_outputs, - t_code_generators); + t_code_generators, + do_termination, + start_state, + term_state); + } + + size_t t_total_n_input_items = 0; + size_t t_total_n_output_items = 0; + for (size_t m = 0; m < n_io_items; m++) { + t_total_n_input_items += n_input_items[m]; + t_total_n_output_items += n_output_items[m]; } code_input_ic1l* t_c_in = new code_input_ic1l (n_code_inputs); - t_c_in->set_buffer ((void**) c_in, n_input_items); + t_c_in->set_buffer ((void**) c_in, t_total_n_input_items); char** t_out = new char*[n_code_outputs]; - for (int m = 0; m < n_code_outputs; m++) { - t_out[m] = new char[n_output_items]; + for (size_t m = 0; m < n_code_outputs; m++) { + t_out[m] = new char[t_total_n_output_items]; } code_output_ic1l* t_c_out = new code_output_ic1l (n_code_outputs); - t_c_out->set_buffer ((void**) t_out, n_output_items); + t_c_out->set_buffer ((void**) t_out, t_total_n_output_items); - t_encoder->encode (t_c_in, t_c_out, n_output_items); + bool t_errors = false; + + for (size_t m = 0; m < n_io_items; m++) { + if (use_encode_in_or_out == true) { + size_t t_n_output_items_used = t_encoder->encode (t_c_in, + n_input_items[m], + t_c_out); + if (t_n_output_items_used != n_output_items[m]) { + std::cout << "Test " << g_t_num << ": Encode[" << m << + "]{input}: Warning: Number of returned output items (" << + t_n_output_items_used << ") is not as expected (" << + n_output_items[m] << ").\n"; + t_errors = true; + } + } else { + size_t t_n_input_items_used = t_encoder->encode (t_c_in, + t_c_out, + n_output_items[m]); + if (t_n_input_items_used != n_input_items[m]) { + std::cout << "Test " << g_t_num << ": Encode[" << m << + "]{output}: Warning: Number of returned output items (" << + t_n_input_items_used << ") is not as expected (" << + n_input_items[m] << ").\n"; + t_errors = true; + } + } + } - for (int m = 0; m < n_code_outputs; m++) { - for (int n = 0; n < n_output_items; n++) { + for (size_t m = 0; m < n_code_outputs; m++) { + for (size_t n = 0; n < t_total_n_output_items; n++) { if (c_res[m][n] != t_out[m][n]) { - std::cout << "Test " << test_n << ": Item [" << m << + std::cout << "Test " << g_t_num << ": Item [" << m << "][" << n << "] not equal: des = " << (int)(c_res[m][n]) << ", act = " << (int)(t_out[m][n]) << "\n"; + t_errors = true; } - CPPUNIT_ASSERT_EQUAL (c_res[m][n], t_out[m][n]); } } + if (encode_soai != -1) { + // verify that the internal realization is correct + if (encode_soai != t_encoder->do_encode_soai ()) { + t_errors = true; + } + } + + CPPUNIT_ASSERT_EQUAL (t_errors, false); + delete t_c_out; t_c_out = 0; delete t_c_in; @@ -99,203 +161,242 @@ qa_encoder_convolutional_ic1_ic1::do_encoder_check delete t_encoder; t_encoder = 0; - for (int m = 0; m < n_code_outputs; m++) { + for (size_t m = 0; m < n_code_outputs; m++) { delete [] t_out[m]; t_out[m] = 0; } delete [] t_out; t_out = 0; + + // increment the test number + + g_t_num++; } +// TESTS 0 through 22 use do_encode_in_or_out as false + +static const bool g_do_encode_in_or_out_0_22 = false; + // TEST 0 // -// checking for SOAI realization (implicitely) -// no feedback, no termination +// checking for: +// SIAO realization (implicitely) +// start state is 0, no feedback, no termination -const static int t0_code_generator[6] = {1, 0, 5, 0, 1, 6}; -const static int t0_n_code_inputs = 3; -const static int t0_n_code_outputs = 2; -const static int t0_n_input_items = 10; -const static int t0_n_output_items = 10; +const static int t0_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static size_t t0_encode_soai = 0; -const static char t0_in_0[t0_n_input_items] = +const static char t0_in_0[] = {0, 1, 0, 0, 1, 0, 1, 0, 0, 0}; -const static char t0_in_1[t0_n_input_items] = +const static char t0_in_1[] = {0, 1, 0, 0, 0, 1, 1, 0, 0, 0}; -const static char t0_in_2[t0_n_input_items] = +const static char t0_in_2[] = {0, 0, 1, 1, 1, 1, 1, 0, 0, 0}; -const static char* t0_in[t0_n_code_inputs] = +const static char* t0_in[] = {t0_in_0, t0_in_1, t0_in_2}; -const static char t0_res_0[t0_n_output_items] = +const static size_t t0_n_input_items = sizeof (t0_in_0); +const static size_t t0_n_code_inputs = sizeof (t0_in) / sizeof (char*); + +const static char t0_res_0[] = {0, 1, 1, 1, 1, 0, 1, 1, 1, 0}; -const static char t0_res_1[t0_n_output_items] = +const static char t0_res_1[] = {0, 1, 0, 1, 0, 1, 1, 0, 1, 0}; -const static char* t0_res[t0_n_code_outputs] = +const static char* t0_res[] = {t0_res_0, t0_res_1}; +const static size_t t0_n_output_items = sizeof (t0_res_0); +const static size_t t0_n_code_outputs = sizeof (t0_res) / sizeof (char*); + void qa_encoder_convolutional_ic1_ic1::t0 () { - do_encoder_check (0, (const char**) t0_in, (const char**) t0_res, - t0_n_input_items, t0_n_output_items, 100, + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t0_in, (const char**) t0_res, + 1, (const size_t*) &t0_n_input_items, + (const size_t*) &t0_n_output_items, 100, t0_n_code_inputs, t0_n_code_outputs, - (const int*) t0_code_generator); + (const int*) t0_code_generator, + 0, true, 0, 0, t0_encode_soai); } // TEST 1 // // checking for SIAO realization (implicitely) -// no feedback, no termination +// start state is 0, no feedback, no termination -const static int t1_code_generator[6] = {1, 0, 0, 1, 5, 6}; -const static int t1_n_code_inputs = 2; -const static int t1_n_code_outputs = 3; -const static int t1_n_input_items = 9; -const static int t1_n_output_items = 9; +const static int t1_code_generator[] = {1, 0, 0, 1, 5, 6}; +const static size_t t1_encode_soai = 1; -const static char t1_in_0[t1_n_input_items] = +const static char t1_in_0[] = {0, 1, 1, 1, 0, 0, 0, 1, 0}; -const static char t1_in_1[t1_n_input_items] = +const static char t1_in_1[] = {0, 0, 0, 0, 0, 1, 1, 1, 0}; -const static char* t1_in[t1_n_code_inputs] = +const static char* t1_in[] = {t1_in_0, t1_in_1}; -const static char t1_res_0[t1_n_output_items] = +const static size_t t1_n_input_items = sizeof (t1_in_0); +const static size_t t1_n_code_inputs = sizeof (t1_in) / sizeof (char*); + +const static char t1_res_0[] = {0, 1, 1, 1, 0, 0, 0, 1, 0}; -const static char t1_res_1[t1_n_output_items] = +const static char t1_res_1[] = {0, 0, 0, 0, 0, 1, 1, 1, 0}; -const static char t1_res_2[t1_n_output_items] = +const static char t1_res_2[] = {0, 1, 1, 0, 1, 1, 1, 1, 0}; -const static char* t1_res[t1_n_code_outputs] = +const static char* t1_res[] = {t1_res_0, t1_res_1, t1_res_2}; +const static size_t t1_n_output_items = sizeof (t1_res_0); +const static size_t t1_n_code_outputs = sizeof (t1_res) / sizeof (char*); + void qa_encoder_convolutional_ic1_ic1::t1 () { - do_encoder_check (1, (const char**) t1_in, (const char**) t1_res, - t1_n_input_items, t1_n_output_items, 100, + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t1_in, (const char**) t1_res, + 1, (const size_t*) &t1_n_input_items, + (const size_t*) &t1_n_output_items, 100, t1_n_code_inputs, t1_n_code_outputs, - (const int*) t1_code_generator); + (const int*) t1_code_generator, + 0, true, 0, 0, t1_encode_soai); } // TEST 2 // -// checking for SIAO realization (implicitely) -// with same feedback, no termination +// checking for SOAI realization (implicitely) +// start state is 0, same feedback, no termination -const static int t2_code_generator[6] = {1, 0, 0, 1, 5, 6}; -const static int t2_code_feedback[6] = {0, 0, 0, 0, 7, 7}; -const static int t2_n_code_inputs = 2; -const static int t2_n_code_outputs = 3; -const static int t2_n_input_items = 19; -const static int t2_n_output_items = 19; +const static int t2_code_generator[] = {1, 0, 0, 1, 5, 6}; +const static size_t t2_code_feedback[] = {0, 0, 0, 0, 7, 7}; +const static int t2_encode_soai = 1; -const static char t2_in_0[t2_n_input_items] = +const static char t2_in_0[] = {0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0}; -const static char t2_in_1[t2_n_input_items] = +const static char t2_in_1[] = {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0}; -const static char* t2_in[t2_n_code_inputs] = +const static char* t2_in[] = {t2_in_0, t2_in_1}; -const static char t2_res_0[t2_n_output_items] = +const static size_t t2_n_input_items = sizeof (t2_in_0); +const static size_t t2_n_code_inputs = sizeof (t2_in) / sizeof (char*); + +const static char t2_res_0[] = {0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0}; -const static char t2_res_1[t2_n_output_items] = +const static char t2_res_1[] = {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0}; -const static char t2_res_2[t2_n_output_items] = +const static char t2_res_2[] = {0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0}; -const static char* t2_res[t2_n_code_outputs] = +const static char* t2_res[] = {t2_res_0, t2_res_1, t2_res_2}; +const static size_t t2_n_output_items = sizeof (t2_res_0); +const static size_t t2_n_code_outputs = sizeof (t2_res) / sizeof (char*); + void qa_encoder_convolutional_ic1_ic1::t2 () { - do_encoder_check (2, (const char**) t2_in, (const char**) t2_res, - t2_n_input_items, t2_n_output_items, 100, + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t2_in, (const char**) t2_res, + 1, (const size_t*) &t2_n_input_items, + (const size_t*) &t2_n_output_items, 100, t2_n_code_inputs, t2_n_code_outputs, (const int*) t2_code_generator, - (const int*) t2_code_feedback); + (const int*) t2_code_feedback, + true, 0, 0, t2_encode_soai); } // TEST 3 // -// checking for SOAI realization (implicitely) -// with same feedback, no termination +// checking for SIAO realization (implicitely) +// start state is 0, same feedback, no termination -const static int t3_code_generator[6] = {1, 0, 5, 0, 1, 6}; -const static int t3_code_feedback[6] = {0, 0, 7, 0, 0, 7}; -const static int t3_n_code_inputs = 3; -const static int t3_n_code_outputs = 2; -const static int t3_n_input_items = 17; -const static int t3_n_output_items = 17; +const static int t3_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t3_code_feedback[] = {0, 0, 7, 0, 0, 7}; +const static int t3_encode_soai = 0; -const static char t3_in_0[t3_n_input_items] = +const static char t3_in_0[] = {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0}; -const static char t3_in_1[t3_n_input_items] = +const static char t3_in_1[] = {0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const static char t3_in_2[t3_n_input_items] = +const static char t3_in_2[] = {0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0}; -const static char* t3_in[t3_n_code_inputs] = +const static char* t3_in[] = {t3_in_0, t3_in_1, t3_in_2}; -const static char t3_res_0[t3_n_output_items] = +const static size_t t3_n_input_items = sizeof (t3_in_0); +const static size_t t3_n_code_inputs = sizeof (t3_in) / sizeof (char*); + +const static char t3_res_0[] = {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0}; -const static char t3_res_1[t3_n_output_items] = +const static char t3_res_1[] = {0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0}; -const static char* t3_res[t3_n_code_outputs] = +const static char* t3_res[] = {t3_res_0, t3_res_1}; +const static size_t t3_n_output_items = sizeof (t3_res_0); +const static size_t t3_n_code_outputs = sizeof (t3_res) / sizeof (char*); + void qa_encoder_convolutional_ic1_ic1::t3 () { - do_encoder_check (3, (const char**) t3_in, (const char**) t3_res, - t3_n_input_items, t3_n_output_items, 100, + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t3_in, (const char**) t3_res, + 1, (const size_t*) &t3_n_input_items, + (const size_t*) &t3_n_output_items, 100, t3_n_code_inputs, t3_n_code_outputs, (const int*) t3_code_generator, - (const int*) t3_code_feedback); + (const int*) t3_code_feedback, + true, 0, 0, t3_encode_soai); } // TEST 4 // // checking for SIAO realization (implicitely), -// with different feedbacks, no termination +// start state is 0, different feedbacks, no termination -const static int t4_code_generator[6] = {1, 4, 0, 3, 1, 6}; -const static int t4_code_feedback[6] = {0, 7, 0, 5, 0, 5}; -const static int t4_n_code_inputs = 2; -const static int t4_n_code_outputs = 3; -const static int t4_n_input_items = 20; -const static int t4_n_output_items = 20; +const static int t4_code_generator[] = {1, 4, 0, 3, 1, 6}; +const static int t4_code_feedback[] = {0, 7, 0, 5, 0, 5}; +const static int t4_encode_soai = 0; -const static char t4_in_0[t4_n_input_items] = +const static char t4_in_0[] = {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0}; -const static char t4_in_1[t4_n_input_items] = +const static char t4_in_1[] = {0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0}; -const static char* t4_in[t4_n_code_inputs] = +const static char* t4_in[] = {t4_in_0, t4_in_1}; -const static char t4_res_0[t4_n_output_items] = +const static size_t t4_n_input_items = sizeof (t4_in_0); +const static size_t t4_n_code_inputs = sizeof (t4_in) / sizeof (char*); + +const static char t4_res_0[] = {0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0}; -const static char t4_res_1[t4_n_output_items] = +const static char t4_res_1[] = {0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0}; -const static char t4_res_2[t4_n_output_items] = +const static char t4_res_2[] = {0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0}; -const static char* t4_res[t4_n_code_outputs] = +const static char* t4_res[] = {t4_res_0, t4_res_1, t4_res_2}; +const static size_t t4_n_output_items = sizeof (t4_res_0); +const static size_t t4_n_code_outputs = sizeof (t4_res) / sizeof (char*); + void qa_encoder_convolutional_ic1_ic1::t4 () { - do_encoder_check (4, (const char**) t4_in, (const char**) t4_res, - t4_n_input_items, t4_n_output_items, 100, + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t4_in, (const char**) t4_res, + 1, (const size_t*) &t4_n_input_items, + (const size_t*) &t4_n_output_items, 100, t4_n_code_inputs, t4_n_code_outputs, (const int*) t4_code_generator, - (const int*) t4_code_feedback); + (const int*) t4_code_feedback, + true, 0, 0, t4_encode_soai); } // TEST 5 @@ -303,150 +404,1895 @@ qa_encoder_convolutional_ic1_ic1::t4 // checking for SOAI realization (implicitely), // with different feedbacks, no termination -const static int t5_code_generator[6] = {1, 0, 0, 1, 5, 7}; -const static int t5_code_feedback[6] = {0, 0, 0, 0, 7, 3}; -const static int t5_n_code_inputs = 2; -const static int t5_n_code_outputs = 3; -const static int t5_n_input_items = 19; -const static int t5_n_output_items = 19; +const static int t5_code_generator[] = {1, 0, 1, 4, 3, 6}; +const static int t5_code_feedback[] = {0, 0, 0, 5, 7, 7}; +const static int t5_encode_soai = 1; -const static char t5_in_0[t5_n_input_items] = - {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0}; -const static char t5_in_1[t5_n_input_items] = - {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0}; -const static char* t5_in[t5_n_code_inputs] = - {t5_in_0, t5_in_1}; +const static char t5_in_0[] = + {0, 1, 0, 0, 0, 1, 0, 0, 1}; +const static char t5_in_1[] = + {0, 0, 1, 0, 1, 1, 0, 0, 1}; +const static char t5_in_2[] = + {0, 0, 0, 1, 0, 0, 0, 0, 1}; +const static char* t5_in[] = + {t5_in_0, t5_in_1, t5_in_2}; -const static char t5_res_0[t5_n_output_items] = - {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0}; -const static char t5_res_1[t5_n_output_items] = - {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0}; -const static char t5_res_2[t5_n_output_items] = - {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0}; -const static char* t5_res[t5_n_code_outputs] = - {t5_res_0, t5_res_1, t5_res_2}; +const static size_t t5_n_input_items = sizeof (t5_in_0); +const static size_t t5_n_code_inputs = sizeof (t5_in) / sizeof (char*); + +const static char t5_res_0[] = + {0, 1, 0, 1, 0, 1, 0, 0, 0}; +const static char t5_res_1[] = + {0, 0, 1, 1, 1, 1, 0, 0, 1}; +const static char* t5_res[] = + {t5_res_0, t5_res_1}; + +const static size_t t5_n_output_items = sizeof (t5_res_0); +const static size_t t5_n_code_outputs = sizeof (t5_res) / sizeof (char*); void qa_encoder_convolutional_ic1_ic1::t5 () { -#if 0 - do_encoder_check (5, (const char**) t5_in, (const char**) t5_res, - t5_n_input_items, t5_n_output_items, 100, + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t5_in, (const char**) t5_res, + 1, (const size_t*) &t5_n_input_items, + (const size_t*) &t5_n_output_items, 100, t5_n_code_inputs, t5_n_code_outputs, - (const int*) t5_code_generator); -#endif + (const int*) t5_code_generator, + (const int*) t5_code_feedback, true, + 0, 0, t5_encode_soai); } // TEST 6 // -// checking for termination, no feedback +// checking for: +// start state is 0, no feedback, termination to 0 state -const static int t6_code_generator[6] = {1, 0, 5, 0, 1, 6}; -const static int t6_n_code_inputs = 3; -const static int t6_n_code_outputs = 2; -const static int t6_n_input_items = 6; -const static int t6_n_output_items = 8; +const static int t6_code_generator[] = {1, 0, 5, 0, 1, 6}; -const static char t6_in_0[t6_n_input_items] = +const static char t6_in_0[] = {0, 1, 0, 0, 1, 0}; -const static char t6_in_1[t6_n_input_items] = +const static char t6_in_1[] = {0, 1, 0, 0, 0, 0}; -const static char t6_in_2[t6_n_input_items] = +const static char t6_in_2[] = {0, 0, 1, 1, 1, 0}; -const static char* t6_in[t6_n_code_inputs] = +const static char* t6_in[] = {t6_in_0, t6_in_1, t6_in_2}; -const static char t6_res_0[t6_n_output_items] = +const static size_t t6_n_input_items = sizeof (t6_in_0); +const static size_t t6_n_code_inputs = sizeof (t6_in) / sizeof (char*); + +const static char t6_res_0[] = {0, 1, 1, 1, 1, 1, 1, 0}; -const static char t6_res_1[t6_n_output_items] = +const static char t6_res_1[] = {0, 1, 0, 1, 0, 0, 1, 0}; -const static char* t6_res[t6_n_code_outputs] = +const static char* t6_res[] = {t6_res_0, t6_res_1}; +const static size_t t6_n_output_items = sizeof (t6_res_0); +const static size_t t6_n_code_outputs = sizeof (t6_res) / sizeof (char*); + void qa_encoder_convolutional_ic1_ic1::t6 () { - do_encoder_check (6, (const char**) t6_in, (const char**) t6_res, - t6_n_input_items, t6_n_output_items, 5, t6_n_code_inputs, + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t6_in, (const char**) t6_res, + 1, (const size_t*) &t6_n_input_items, + (const size_t*) &t6_n_output_items, 5, t6_n_code_inputs, t6_n_code_outputs, (const int*) t6_code_generator); } // TEST 7 // -// checking for termination, with same feedback +// checking for: +// start state is 0, same feedback, termination to 0 state +// # of termination bits = 2 -const static int t7_code_generator[6] = {1, 0, 5, 0, 1, 6}; -const static int t7_code_feedback[6] = {0, 0, 7, 0, 0, 7}; -const static int t7_n_code_inputs = 3; -const static int t7_n_code_outputs = 2; -const static int t7_n_input_items = 17; -const static int t7_n_output_items = 17; +const static int t7_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t7_code_feedback[] = {0, 0, 7, 0, 0, 7}; -const static char t7_in_0[t7_n_input_items] = - {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0}; -const static char t7_in_1[t7_n_input_items] = - {0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const static char t7_in_2[t7_n_input_items] = - {0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0}; -const static char* t7_in[t7_n_code_inputs] = +const static char t7_in_0[] = + {0, 1, 1, 0, 0, 0, 0}; +const static char t7_in_1[] = + {0, 1, 0, 1, 0, 0, 0}; +const static char t7_in_2[] = + {0, 0, 0, 0, 1, 0, 1}; +const static char* t7_in[] = {t7_in_0, t7_in_1, t7_in_2}; -const static char t7_res_0[t7_n_output_items] = - {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0}; -const static char t7_res_1[t7_n_output_items] = - {0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0}; -const static char* t7_res[t7_n_code_outputs] = +const static size_t t7_n_input_items = sizeof (t7_in_0); +const static size_t t7_n_code_inputs = sizeof (t7_in) / sizeof (char*); + +const static char t7_res_0[] = + {0, 1, 1, 0, 1, 0, 1, 0, 1}; +const static char t7_res_1[] = + {0, 1, 0, 1, 0, 1, 1, 0, 0}; +const static char* t7_res[] = {t7_res_0, t7_res_1}; +const static size_t t7_n_output_items = sizeof (t7_res_0); +const static size_t t7_n_code_outputs = sizeof (t7_res) / sizeof (char*); + void qa_encoder_convolutional_ic1_ic1::t7 () { -#if 0 - do_encoder_check (7, (const char**) t7_in, (const char**) t7_res, - t7_n_input_items, t7_n_output_items, 5, t7_n_code_inputs, + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t7_in, (const char**) t7_res, + 1, (const size_t*) &t7_n_input_items, + (const size_t*) &t7_n_output_items, 5, t7_n_code_inputs, t7_n_code_outputs, (const int*) t7_code_generator, (const int*) t7_code_feedback); -#endif } // TEST 8 // -// checking for termination, with different feedback +// checking for: +// state state is 0, different feedbacks, termination to 0 state +// # of term bits will be 4 + +const static int t8_code_generator[] = {1, 4, 0, 3, 1, 6}; +const static int t8_code_feedback[] = {0, 5, 0, 7, 0, 7}; + +const static char t8_in_0[] = + {0, 1, 0, 0, 0, 1, 0, 1, 1}; +const static char t8_in_1[] = + {0, 0, 0, 1, 1, 1, 0, 1, 0}; +const static char* t8_in[] = + {t8_in_0, t8_in_1}; + +const static size_t t8_n_input_items = sizeof (t8_in_0); +const static size_t t8_n_code_inputs = sizeof (t8_in) / sizeof (char*); + +const static char t8_res_0[] = + {0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1}; +const static char t8_res_1[] = + {0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0}; +const static char t8_res_2[] = + {0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; +const static char* t8_res[] = + {t8_res_0, t8_res_1, t8_res_2}; + +const static size_t t8_n_output_items = sizeof (t8_res_0); +const static size_t t8_n_code_outputs = sizeof (t8_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t8 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t8_in, (const char**) t8_res, + 1, (const size_t*) &t8_n_input_items, + (const size_t*) &t8_n_output_items, 6, t8_n_code_inputs, + t8_n_code_outputs, (const int*) t8_code_generator, + (const int*) t8_code_feedback); +} + +// TEST 9 +// +// checking for: +// start state is 0, different feedbacks, termination to non-0 state +// # of term bits will be 2 + +const static int t9_code_generator[] = {1, 0, 1, 4, 3, 6}; +const static int t9_code_feedback[] = {0, 0, 0, 5, 7, 7}; +const static size_t t9_term_state = 4; + +const static char t9_in_0[] = + {0, 1, 0, 0, 0, 0, 1}; +const static char t9_in_1[] = + {0, 0, 1, 0, 1, 0, 1}; +const static char t9_in_2[] = + {0, 0, 0, 1, 0, 0, 1}; +const static char* t9_in[] = + {t9_in_0, t9_in_1, t9_in_2}; + +const static size_t t9_n_input_items = sizeof (t9_in_0); +const static size_t t9_n_code_inputs = sizeof (t9_in) / sizeof (char*); + +const static char t9_res_0[] = + {0, 1, 0, 1, 0, 1, 1, 0, 0}; +const static char t9_res_1[] = + {0, 0, 1, 1, 1, 1, 1, 0, 1}; +const static char* t9_res[] = + {t9_res_0, t9_res_1}; + +const static size_t t9_n_output_items = sizeof (t9_res_0); +const static size_t t9_n_code_outputs = sizeof (t9_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t9 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t9_in, (const char**) t9_res, + 1, (const size_t*) &t9_n_input_items, + (const size_t*) &t9_n_output_items, 5, t9_n_code_inputs, + t9_n_code_outputs, (const int*) t9_code_generator, + (const int*) t9_code_feedback, true, 0, t9_term_state); +} + +// TEST 10 +// +// checking for termination to non-0 state, no feedback + +const static int t10_code_generator[] = {1, 0, 3, 0, 1, 6}; +const static size_t t10_term_state = 2; + +const static char t10_in_0[] = + {0, 1, 0, 1, 0, 0, 1, 1}; +const static char t10_in_1[] = + {0, 1, 0, 0, 1, 0, 1, 1}; +const static char t10_in_2[] = + {0, 1, 0, 1, 1, 0, 0, 1}; +const static char* t10_in[] = + {t10_in_0, t10_in_1, t10_in_2}; + +const static size_t t10_n_input_items = sizeof (t10_in_0); +const static size_t t10_n_code_inputs = sizeof (t10_in) / sizeof (char*); + +const static char t10_res_0[] = + {0, 0, 1, 0, 0, 0, 1, 0, 1, 0}; +const static char t10_res_1[] = + {0, 1, 1, 1, 0, 0, 0, 0, 1, 1}; +const static char* t10_res[] = + {t10_res_0, t10_res_1}; + +const static size_t t10_n_output_items = sizeof (t10_res_0); +const static size_t t10_n_code_outputs = sizeof (t10_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t10 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t10_in, (const char**) t10_res, + 1, (const size_t*) &t10_n_input_items, + (const size_t*) &t10_n_output_items, 5, + t10_n_code_inputs, t10_n_code_outputs, + (const int*) t10_code_generator, + 0, true, 0, t10_term_state); +} + +// TEST 11 +// +// checking for: +// start state is not 0, no feedback, terminating to 0 state + +const static int t11_code_generator[] = {1, 0, 3, 0, 1, 6}; +const static size_t t11_start_state = 1; + +const static char t11_in_0[] = + {0, 1, 0, 0, 0, 1, 0}; +const static char t11_in_1[] = + {0, 0, 1, 0, 0, 1, 0}; +const static char t11_in_2[] = + {0, 1, 1, 1, 0, 1, 1}; +const static char* t11_in[] = + {t11_in_0, t11_in_1, t11_in_2}; + +const static size_t t11_n_input_items = sizeof (t11_in_0); +const static size_t t11_n_code_inputs = sizeof (t11_in) / sizeof (char*); + +const static char t11_res_0[] = + {1, 0, 0, 0, 1, 0, 0, 1, 0}; +const static char t11_res_1[] = + {1, 1, 0, 0, 0, 1, 0, 0, 0}; +const static char* t11_res[] = + {t11_res_0, t11_res_1}; + +const static size_t t11_n_output_items = sizeof (t11_res_0); +const static size_t t11_n_code_outputs = sizeof (t11_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t11 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t11_in, (const char**) t11_res, + 1, (const size_t*) &t11_n_input_items, + (const size_t*) &t11_n_output_items, 5, + t11_n_code_inputs, t11_n_code_outputs, + (const int*) t11_code_generator, + 0, true, t11_start_state); +} + +// TEST 12 +// +// checking for: +// start state is not 0, no feedback, terminating to non-0 state + +const static int t12_code_generator[] = {1, 0, 3, 0, 1, 6}; +const static size_t t12_start_state = 2; +const static size_t t12_term_state = 2; + +const static char t12_in_0[] = + {0, 1, 1, 1, 0, 1, 0}; +const static char t12_in_1[] = + {0, 1, 0, 0, 0, 0, 1}; +const static char t12_in_2[] = + {0, 1, 1, 0, 1, 0, 1}; +const static char* t12_in[] = + {t12_in_0, t12_in_1, t12_in_2}; + +const static size_t t12_n_input_items = sizeof (t12_in_0); +const static size_t t12_n_code_inputs = sizeof (t12_in) / sizeof (char*); + +const static char t12_res_0[] = + {0, 0, 1, 0, 1, 0, 1, 1, 1}; +const static char t12_res_1[] = + {1, 1, 1, 0, 1, 1, 0, 1, 1}; +const static char* t12_res[] = + {t12_res_0, t12_res_1}; + +const static size_t t12_n_output_items = sizeof (t12_res_0); +const static size_t t12_n_code_outputs = sizeof (t12_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t12 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t12_in, (const char**) t12_res, + 1, (const size_t*) &t12_n_input_items, + (const size_t*) &t12_n_output_items, 5, t12_n_code_inputs, + t12_n_code_outputs, (const int*) t12_code_generator, + 0, true, t12_start_state, t12_term_state); +} + +// TEST 13 +// +// checking for: +// start state is not 0, any feedback, termination to 0 state + +const static int t13_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t13_code_feedback[] = {0, 0, 7, 0, 0, 7}; +const static size_t t13_start_state = 2; +const static size_t t13_term_state = 0; + +const static char t13_in_0[] = + {0, 1, 0, 0, 0, 1, 0}; +const static char t13_in_1[] = + {0, 0, 1, 1, 0, 1, 0}; +const static char t13_in_2[] = + {0, 0, 0, 0, 1, 0, 0}; +const static char* t13_in[] = + {t13_in_0, t13_in_1, t13_in_2}; + +const static size_t t13_n_input_items = sizeof (t13_in_0); +const static size_t t13_n_code_inputs = sizeof (t13_in) / sizeof (char*); + +const static char t13_res_0[] = + {0, 0, 1, 0, 0, 1, 0, 1, 1}; +const static char t13_res_1[] = + {1, 1, 1, 0, 1, 1, 0, 0, 1}; +const static char* t13_res[] = + {t13_res_0, t13_res_1}; + +const static size_t t13_n_output_items = sizeof (t13_res_0); +const static size_t t13_n_code_outputs = sizeof (t13_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t13 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t13_in, (const char**) t13_res, + 1, (const size_t*) &t13_n_input_items, + (const size_t*) &t13_n_output_items, 5, + t13_n_code_inputs, t13_n_code_outputs, + (const int*) t13_code_generator, + (const int*) t13_code_feedback, + true, t13_start_state, t13_term_state); +} + +// TEST 14 +// +// checking for: +// start state is not 0, any feedback, termination to non-zero state + +const static int t14_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t14_code_feedback[] = {0, 0, 7, 0, 0, 7}; +const static size_t t14_start_state = 1; +const static size_t t14_term_state = 2; + +const static char t14_in_0[] = + {0, 1, 0, 1, 0, 1, 0}; +const static char t14_in_1[] = + {0, 0, 0, 0, 1, 1, 0}; +const static char t14_in_2[] = + {0, 1, 0, 0, 0, 1, 1}; +const static char* t14_in[] = + {t14_in_0, t14_in_1, t14_in_2}; + +const static size_t t14_n_input_items = sizeof (t14_in_0); +const static size_t t14_n_code_inputs = sizeof (t14_in) / sizeof (char*); + +const static char t14_res_0[] = + {1, 1, 1, 1, 1, 0, 1, 1, 1}; +const static char t14_res_1[] = + {1, 0, 0, 1, 0, 0, 0, 0, 1}; +const static char* t14_res[] = + {t14_res_0, t14_res_1}; + +const static size_t t14_n_output_items = sizeof (t14_res_0); +const static size_t t14_n_code_outputs = sizeof (t14_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t14 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t14_in, (const char**) t14_res, + 1, (const size_t*) &t14_n_input_items, + (const size_t*) &t14_n_output_items, 5, + t14_n_code_inputs, t14_n_code_outputs, + (const int*) t14_code_generator, + (const int*) t14_code_feedback, + true, t14_start_state, t14_term_state); +} + +// TEST 15 +// +// checking for: +// no feedback, block coding but no termination + +const static int t15_code_generator[] = {1, 0, 3, 0, 1, 6}; + +const static char t15_in_0[] = + {0, 1, 0, 1, 0, 0, 1, 1}; +const static char t15_in_1[] = + {0, 1, 0, 0, 1, 0, 1, 1}; +const static char t15_in_2[] = + {0, 1, 0, 1, 1, 0, 0, 1}; +const static char* t15_in[] = + {t15_in_0, t15_in_1, t15_in_2}; + +const static size_t t15_n_input_items = sizeof (t15_in_0); +const static size_t t15_n_code_inputs = sizeof (t15_in) / sizeof (char*); + +const static char t15_res_0[] = + {0, 0, 1, 0, 0, 0, 1, 0}; +const static char t15_res_1[] = + {0, 1, 1, 1, 0, 0, 1, 1}; +const static char* t15_res[] = + {t15_res_0, t15_res_1}; + +const static size_t t15_n_output_items = sizeof (t15_res_0); +const static size_t t15_n_code_outputs = sizeof (t15_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t15 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t15_in, (const char**) t15_res, + 1, (const size_t*) &t15_n_input_items, + (const size_t*) &t15_n_output_items, 5, + t15_n_code_inputs, t15_n_code_outputs, + (const int*) t15_code_generator, 0, false); +} + +// TEST 16 +// +// checking for: +// start state is 0, same feedback, block but no termination + +const static int t16_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t16_code_feedback[] = {0, 0, 7, 0, 0, 7}; + +const static char t16_in_0[] = + {0, 1, 1, 0, 0, 0, 0}; +const static char t16_in_1[] = + {0, 1, 0, 1, 0, 0, 0}; +const static char t16_in_2[] = + {0, 0, 0, 0, 1, 0, 1}; +const static char* t16_in[] = + {t16_in_0, t16_in_1, t16_in_2}; + +const static size_t t16_n_input_items = sizeof (t16_in_0); +const static size_t t16_n_code_inputs = sizeof (t16_in) / sizeof (char*); + +const static char t16_res_0[] = + {0, 1, 1, 0, 1, 0, 1}; +const static char t16_res_1[] = + {0, 1, 0, 1, 0, 0, 0}; +const static char* t16_res[] = + {t16_res_0, t16_res_1}; + +const static size_t t16_n_output_items = sizeof (t16_res_0); +const static size_t t16_n_code_outputs = sizeof (t16_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t16 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t16_in, (const char**) t16_res, + 1, (const size_t*) &t16_n_input_items, + (const size_t*) &t16_n_output_items, 5, t16_n_code_inputs, + t16_n_code_outputs, (const int*) t16_code_generator, + (const int*) t16_code_feedback, false); +} + +// TEST 17 +// +// checking for: +// state state is 0, different feedbacks, block but no termination + +const static int t17_code_generator[] = {1, 4, 0, 3, 1, 6}; +const static int t17_code_feedback[] = {0, 5, 0, 7, 0, 7}; + +const static char t17_in_0[] = + {0, 1, 0, 0, 0, 1, 0, 1, 1}; +const static char t17_in_1[] = + {0, 0, 0, 1, 1, 1, 0, 1, 0}; +const static char* t17_in[] = + {t17_in_0, t17_in_1}; + +const static size_t t17_n_input_items = sizeof (t17_in_0); +const static size_t t17_n_code_inputs = sizeof (t17_in) / sizeof (char*); + +const static char t17_res_0[] = + {0, 1, 0, 0, 0, 0, 0, 1, 1}; +const static char t17_res_1[] = + {0, 0, 0, 1, 1, 0, 0, 1, 0}; +const static char t17_res_2[] = + {0, 1, 0, 0, 1, 0, 0, 1, 0}; +const static char* t17_res[] = + {t17_res_0, t17_res_1, t17_res_2}; + +const static size_t t17_n_output_items = sizeof (t17_res_0); +const static size_t t17_n_code_outputs = sizeof (t17_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t17 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t17_in, (const char**) t17_res, + 1, (const size_t*) &t17_n_input_items, + (const size_t*) &t17_n_output_items, 6, t17_n_code_inputs, + t17_n_code_outputs, (const int*) t17_code_generator, + (const int*) t17_code_feedback, false); +} + +// TEST 18 +// +// checking for: +// start state is not 0, no feedback, terminating to non-0 state +// multi-encode, stop output before term bits + +const static int t18_code_generator[] = {1, 0, 3, 0, 1, 6}; +const static size_t t18_start_state = 2; +const static size_t t18_term_state = 2; + +const static char t18_in_0[] = + {0, 1, 1, 1, 0, 1, 0}; +const static char t18_in_1[] = + {0, 1, 0, 0, 0, 0, 1}; +const static char t18_in_2[] = + {0, 1, 1, 0, 1, 0, 1}; +const static char* t18_in[] = + {t18_in_0, t18_in_1, t18_in_2}; + +const static size_t t18_n_input_items[] = {3, 2, 2}; +const static size_t t18_n_io_items = (sizeof (t18_n_input_items) / + sizeof (size_t)); +const static size_t t18_n_code_inputs = sizeof (t18_in) / sizeof (char*); + +const static char t18_res_0[] = + {0, 0, 1, 0, 1, 0, 1, 1, 1}; +const static char t18_res_1[] = + {1, 1, 1, 0, 1, 1, 0, 1, 1}; +const static char* t18_res[] = + {t18_res_0, t18_res_1}; + +const static size_t t18_n_output_items[] = {3, 2, 4}; +const static size_t t18_n_code_outputs = sizeof (t18_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t18 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t18_in, (const char**) t18_res, + t18_n_io_items, (const size_t*) t18_n_input_items, + (const size_t*) t18_n_output_items, 5, t18_n_code_inputs, + t18_n_code_outputs, (const int*) t18_code_generator, + 0, true, t18_start_state, t18_term_state); +} + +// TEST 19 +// +// checking for: +// start state is not 0, any feedback, termination to non-zero state +// multi-encode, stop output in the middle of term bits + +const static int t19_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t19_code_feedback[] = {0, 0, 7, 0, 0, 7}; +const static size_t t19_start_state = 1; +const static size_t t19_term_state = 2; + +const static char t19_in_0[] = + {0, 1, 0, 1, 0, 1, 0}; +const static char t19_in_1[] = + {0, 0, 0, 0, 1, 1, 0}; +const static char t19_in_2[] = + {0, 1, 0, 0, 0, 1, 1}; +const static char* t19_in[] = + {t19_in_0, t19_in_1, t19_in_2}; + +const static size_t t19_n_input_items[] = {2, 2, 1, 1, 1}; +const static size_t t19_n_io_items = (sizeof (t19_n_input_items) / + sizeof (size_t)); +const static size_t t19_n_code_inputs = sizeof (t19_in) / sizeof (char*); + +const static char t19_res_0[] = + {1, 1, 1, 1, 1, 0, 1, 1, 1}; +const static char t19_res_1[] = + {1, 0, 0, 1, 0, 0, 0, 0, 1}; +const static char* t19_res[] = + {t19_res_0, t19_res_1}; + +const static size_t t19_n_output_items[] = {2, 2, 2, 2, 1}; +const static size_t t19_n_code_outputs = sizeof (t19_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t19 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t19_in, (const char**) t19_res, + 1, (const size_t*) &t19_n_input_items, + (const size_t*) &t19_n_output_items, 5, + t19_n_code_inputs, t19_n_code_outputs, + (const int*) t19_code_generator, + (const int*) t19_code_feedback, + true, t19_start_state, t19_term_state); +} + +// TEST 20 +// +// checking for: +// no feedback, block coding but no termination +// multi-encode + +const static int t20_code_generator[] = {1, 0, 3, 0, 1, 6}; + +const static char t20_in_0[] = + {0, 1, 0, 1, 0, 0, 1, 1}; +const static char t20_in_1[] = + {0, 1, 0, 0, 1, 0, 1, 1}; +const static char t20_in_2[] = + {0, 1, 0, 1, 1, 0, 0, 1}; +const static char* t20_in[] = + {t20_in_0, t20_in_1, t20_in_2}; + +const static size_t t20_n_input_items[] = {2, 2, 2, 2}; +const static size_t t20_n_n_input_items = (sizeof (t20_n_input_items) / + sizeof (size_t)); +const static size_t t20_n_code_inputs = sizeof (t20_in) / sizeof (char*); + +const static char t20_res_0[] = + {0, 0, 1, 0, 0, 0, 1, 0}; +const static char t20_res_1[] = + {0, 1, 1, 1, 0, 0, 1, 1}; +const static char* t20_res[] = + {t20_res_0, t20_res_1}; + +const static size_t t20_n_output_items[] = {2, 2, 2, 2}; +const static size_t t20_n_code_outputs = sizeof (t20_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t20 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t20_in, (const char**) t20_res, + t20_n_n_input_items, (const size_t*) t20_n_input_items, + (const size_t*) t20_n_output_items, 5, + t20_n_code_inputs, t20_n_code_outputs, + (const int*) t20_code_generator, 0, false); +} + +// TEST 21 +// +// checking for: +// start state is 0, same feedback, block but no termination +// multi-encode + +const static int t21_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t21_code_feedback[] = {0, 0, 7, 0, 0, 7}; + +const static char t21_in_0[] = + {0, 1, 1, 0, 0, 0, 0}; +const static char t21_in_1[] = + {0, 1, 0, 1, 0, 0, 0}; +const static char t21_in_2[] = + {0, 0, 0, 0, 1, 0, 1}; +const static char* t21_in[] = + {t21_in_0, t21_in_1, t21_in_2}; + +const static size_t t21_n_input_items[] = {5, 1, 1}; +const static size_t t21_n_n_input_items = (sizeof (t21_n_input_items) / + sizeof (size_t)); +const static size_t t21_n_code_inputs = sizeof (t21_in) / sizeof (char*); + +const static char t21_res_0[] = + {0, 1, 1, 0, 1, 0, 1}; +const static char t21_res_1[] = + {0, 1, 0, 1, 0, 0, 0}; +const static char* t21_res[] = + {t21_res_0, t21_res_1}; + +const static size_t t21_n_output_items[] = {5, 1, 1}; +const static size_t t21_n_code_outputs = sizeof (t21_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t21 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t21_in, (const char**) t21_res, + t21_n_n_input_items, (const size_t*) t21_n_input_items, + (const size_t*) t21_n_output_items, 5, t21_n_code_inputs, + t21_n_code_outputs, (const int*) t21_code_generator, + (const int*) t21_code_feedback, false); +} + +// TEST 22 +// +// checking for: +// state state is 0, different feedbacks, block but no termination +// multi-encode + +const static int t22_code_generator[] = {1, 4, 0, 3, 1, 6}; +const static int t22_code_feedback[] = {0, 5, 0, 7, 0, 7}; + +const static char t22_in_0[] = + {0, 1, 0, 0, 0, 1, 0, 1, 1}; +const static char t22_in_1[] = + {0, 0, 0, 1, 1, 1, 0, 1, 0}; +const static char* t22_in[] = + {t22_in_0, t22_in_1}; + +const static size_t t22_n_input_items[] = {5, 4}; +const static size_t t22_n_n_input_items = (sizeof (t22_n_input_items) / + sizeof (size_t)); +const static size_t t22_n_code_inputs = sizeof (t22_in) / sizeof (char*); + +const static char t22_res_0[] = + {0, 1, 0, 0, 0, 0, 0, 1, 1}; +const static char t22_res_1[] = + {0, 0, 0, 1, 1, 0, 0, 1, 0}; +const static char t22_res_2[] = + {0, 1, 0, 0, 1, 0, 0, 1, 0}; +const static char* t22_res[] = + {t22_res_0, t22_res_1, t22_res_2}; + +const static size_t t22_n_output_items[] = {5, 4}; +const static size_t t22_n_code_outputs = sizeof (t22_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t22 +() +{ + do_encoder_check (g_do_encode_in_or_out_0_22, + (const char**) t22_in, (const char**) t22_res, + t22_n_n_input_items, (const size_t*) t22_n_input_items, + (const size_t*) t22_n_output_items, 6, t22_n_code_inputs, + t22_n_code_outputs, (const int*) t22_code_generator, + (const int*) t22_code_feedback, false); +} + +// TESTS 23 through 45 use do_encode_in_or_out as true + +static const bool g_do_encode_in_or_out_23_45 = true; + +// TEST 23 +// +// checking for: +// SIAO realization (implicitely) +// start state is 0, no feedback, no termination + +const static int t23_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static size_t t23_encode_soai = 0; + +const static char t23_in_0[] = + {0, 1, 0, 0, 1, 0, 1, 0, 0, 0}; +const static char t23_in_1[] = + {0, 1, 0, 0, 0, 1, 1, 0, 0, 0}; +const static char t23_in_2[] = + {0, 0, 1, 1, 1, 1, 1, 0, 0, 0}; +const static char* t23_in[] = + {t23_in_0, t23_in_1, t23_in_2}; + +const static size_t t23_n_input_items = sizeof (t23_in_0); +const static size_t t23_n_code_inputs = sizeof (t23_in) / sizeof (char*); + +const static char t23_res_0[] = + {0, 1, 1, 1, 1, 0, 1, 1, 1, 0}; +const static char t23_res_1[] = + {0, 1, 0, 1, 0, 1, 1, 0, 1, 0}; +const static char* t23_res[] = + {t23_res_0, t23_res_1}; + +const static size_t t23_n_output_items = sizeof (t23_res_0); +const static size_t t23_n_code_outputs = sizeof (t23_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t23 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t23_in, (const char**) t23_res, + 1, (const size_t*) &t23_n_input_items, + (const size_t*) &t23_n_output_items, 100, + t23_n_code_inputs, t23_n_code_outputs, + (const int*) t23_code_generator, + 0, true, 0, 0, t23_encode_soai); +} + +// TEST 24 +// +// checking for SIAO realization (implicitely) +// start state is 0, no feedback, no termination + +const static int t24_code_generator[] = {1, 0, 0, 1, 5, 6}; +const static size_t t24_encode_soai = 1; + +const static char t24_in_0[] = + {0, 1, 1, 1, 0, 0, 0, 1, 0}; +const static char t24_in_1[] = + {0, 0, 0, 0, 0, 1, 1, 1, 0}; +const static char* t24_in[] = + {t24_in_0, t24_in_1}; + +const static size_t t24_n_input_items = sizeof (t24_in_0); +const static size_t t24_n_code_inputs = sizeof (t24_in) / sizeof (char*); + +const static char t24_res_0[] = + {0, 1, 1, 1, 0, 0, 0, 1, 0}; +const static char t24_res_1[] = + {0, 0, 0, 0, 0, 1, 1, 1, 0}; +const static char t24_res_2[] = + {0, 1, 1, 0, 1, 1, 1, 1, 0}; +const static char* t24_res[] = + {t24_res_0, t24_res_1, t24_res_2}; + +const static size_t t24_n_output_items = sizeof (t24_res_0); +const static size_t t24_n_code_outputs = sizeof (t24_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t24 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t24_in, (const char**) t24_res, + 1, (const size_t*) &t24_n_input_items, + (const size_t*) &t24_n_output_items, 100, + t24_n_code_inputs, t24_n_code_outputs, + (const int*) t24_code_generator, + 0, true, 0, 0, t24_encode_soai); +} + +// TEST 25 +// +// checking for SOAI realization (implicitely) +// start state is 0, same feedback, no termination + +const static int t25_code_generator[] = {1, 0, 0, 1, 5, 6}; +const static size_t t25_code_feedback[] = {0, 0, 0, 0, 7, 7}; +const static int t25_encode_soai = 1; + +const static char t25_in_0[] = + {0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0}; +const static char t25_in_1[] = + {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0}; +const static char* t25_in[] = + {t25_in_0, t25_in_1}; + +const static size_t t25_n_input_items = sizeof (t25_in_0); +const static size_t t25_n_code_inputs = sizeof (t25_in) / sizeof (char*); + +const static char t25_res_0[] = + {0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0}; +const static char t25_res_1[] = + {0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0}; +const static char t25_res_2[] = + {0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0}; +const static char* t25_res[] = + {t25_res_0, t25_res_1, t25_res_2}; + +const static size_t t25_n_output_items = sizeof (t25_res_0); +const static size_t t25_n_code_outputs = sizeof (t25_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t25 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t25_in, (const char**) t25_res, + 1, (const size_t*) &t25_n_input_items, + (const size_t*) &t25_n_output_items, 100, + t25_n_code_inputs, t25_n_code_outputs, + (const int*) t25_code_generator, + (const int*) t25_code_feedback, + true, 0, 0, t25_encode_soai); +} + +// TEST 26 +// +// checking for SIAO realization (implicitely) +// start state is 0, same feedback, no termination -const static int t8_code_generator[6] = {1, 0, 5, 0, 1, 6}; -const static int t8_code_feedback[6] = {0, 0, 7, 0, 0, 3}; -const static int t8_n_code_inputs = 3; -const static int t8_n_code_outputs = 2; -const static int t8_n_input_items = 17; -const static int t8_n_output_items = 17; +const static int t26_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t26_code_feedback[] = {0, 0, 7, 0, 0, 7}; +const static int t26_encode_soai = 0; -const static char t8_in_0[t8_n_input_items] = +const static char t26_in_0[] = {0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0}; -const static char t8_in_1[t8_n_input_items] = +const static char t26_in_1[] = {0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -const static char t8_in_2[t8_n_input_items] = +const static char t26_in_2[] = {0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0}; -const static char* t8_in[t8_n_code_inputs] = - {t8_in_0, t8_in_1, t8_in_2}; +const static char* t26_in[] = + {t26_in_0, t26_in_1, t26_in_2}; + +const static size_t t26_n_input_items = sizeof (t26_in_0); +const static size_t t26_n_code_inputs = sizeof (t26_in) / sizeof (char*); -const static char t8_res_0[t8_n_output_items] = +const static char t26_res_0[] = {0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0}; -const static char t8_res_1[t8_n_output_items] = +const static char t26_res_1[] = {0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0}; -const static char* t8_res[t8_n_code_outputs] = - {t8_res_0, t8_res_1}; +const static char* t26_res[] = + {t26_res_0, t26_res_1}; + +const static size_t t26_n_output_items = sizeof (t26_res_0); +const static size_t t26_n_code_outputs = sizeof (t26_res) / sizeof (char*); void -qa_encoder_convolutional_ic1_ic1::t8 +qa_encoder_convolutional_ic1_ic1::t26 () { -#if 0 - do_encoder_check (8, (const char**) t8_in, (const char**) t8_res, - t8_n_input_items, t8_n_output_items, 5, t8_n_code_inputs, - t8_n_code_outputs, (const int*) t8_code_generator, - (const int*) t8_code_feedback); -#endif + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t26_in, (const char**) t26_res, + 1, (const size_t*) &t26_n_input_items, + (const size_t*) &t26_n_output_items, 100, + t26_n_code_inputs, t26_n_code_outputs, + (const int*) t26_code_generator, + (const int*) t26_code_feedback, + true, 0, 0, t26_encode_soai); +} + +// TEST 27 +// +// checking for SIAO realization (implicitely), +// start state is 0, different feedbacks, no termination + +const static int t27_code_generator[] = {1, 4, 0, 3, 1, 6}; +const static int t27_code_feedback[] = {0, 7, 0, 5, 0, 5}; +const static int t27_encode_soai = 0; + +const static char t27_in_0[] = + {0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0}; +const static char t27_in_1[] = + {0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0}; +const static char* t27_in[] = + {t27_in_0, t27_in_1}; + +const static size_t t27_n_input_items = sizeof (t27_in_0); +const static size_t t27_n_code_inputs = sizeof (t27_in) / sizeof (char*); + +const static char t27_res_0[] = + {0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0}; +const static char t27_res_1[] = + {0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0}; +const static char t27_res_2[] = + {0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0}; +const static char* t27_res[] = + {t27_res_0, t27_res_1, t27_res_2}; + +const static size_t t27_n_output_items = sizeof (t27_res_0); +const static size_t t27_n_code_outputs = sizeof (t27_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t27 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t27_in, (const char**) t27_res, + 1, (const size_t*) &t27_n_input_items, + (const size_t*) &t27_n_output_items, 100, + t27_n_code_inputs, t27_n_code_outputs, + (const int*) t27_code_generator, + (const int*) t27_code_feedback, + true, 0, 0, t27_encode_soai); } + +// TEST 28 +// +// checking for SOAI realization (implicitely), +// with different feedbacks, no termination + +const static int t28_code_generator[] = {1, 0, 1, 4, 3, 6}; +const static int t28_code_feedback[] = {0, 0, 0, 5, 7, 7}; +const static int t28_encode_soai = 1; + +const static char t28_in_0[] = + {0, 1, 0, 0, 0, 1, 0, 0, 1}; +const static char t28_in_1[] = + {0, 0, 1, 0, 1, 1, 0, 0, 1}; +const static char t28_in_2[] = + {0, 0, 0, 1, 0, 0, 0, 0, 1}; +const static char* t28_in[] = + {t28_in_0, t28_in_1, t28_in_2}; + +const static size_t t28_n_input_items = sizeof (t28_in_0); +const static size_t t28_n_code_inputs = sizeof (t28_in) / sizeof (char*); + +const static char t28_res_0[] = + {0, 1, 0, 1, 0, 1, 0, 0, 0}; +const static char t28_res_1[] = + {0, 0, 1, 1, 1, 1, 0, 0, 1}; +const static char* t28_res[] = + {t28_res_0, t28_res_1}; + +const static size_t t28_n_output_items = sizeof (t28_res_0); +const static size_t t28_n_code_outputs = sizeof (t28_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t28 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t28_in, (const char**) t28_res, + 1, (const size_t*) &t28_n_input_items, + (const size_t*) &t28_n_output_items, 100, + t28_n_code_inputs, t28_n_code_outputs, + (const int*) t28_code_generator, + (const int*) t28_code_feedback, true, + 0, 0, t28_encode_soai); +} + +// TEST 29 +// +// checking for: +// start state is 0, no feedback, termination to 0 state + +const static int t29_code_generator[] = {1, 0, 5, 0, 1, 6}; + +const static char t29_in_0[] = + {0, 1, 0, 0, 1, 0}; +const static char t29_in_1[] = + {0, 1, 0, 0, 0, 0}; +const static char t29_in_2[] = + {0, 0, 1, 1, 1, 0}; +const static char* t29_in[] = + {t29_in_0, t29_in_1, t29_in_2}; + +const static size_t t29_n_input_items = sizeof (t29_in_0); +const static size_t t29_n_code_inputs = sizeof (t29_in) / sizeof (char*); + +const static char t29_res_0[] = + {0, 1, 1, 1, 1, 1, 1, 0}; +const static char t29_res_1[] = + {0, 1, 0, 1, 0, 0, 1, 0}; +const static char* t29_res[] = + {t29_res_0, t29_res_1}; + +const static size_t t29_n_output_items = sizeof (t29_res_0); +const static size_t t29_n_code_outputs = sizeof (t29_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t29 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t29_in, (const char**) t29_res, + 1, (const size_t*) &t29_n_input_items, + (const size_t*) &t29_n_output_items, 5, t29_n_code_inputs, + t29_n_code_outputs, (const int*) t29_code_generator); +} + +// TEST 30 +// +// checking for: +// start state is 0, same feedback, termination to 0 state +// # of termination bits = 2 + +const static int t30_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t30_code_feedback[] = {0, 0, 7, 0, 0, 7}; + +const static char t30_in_0[] = + {0, 1, 1, 0, 0, 0, 0}; +const static char t30_in_1[] = + {0, 1, 0, 1, 0, 0, 0}; +const static char t30_in_2[] = + {0, 0, 0, 0, 1, 0, 1}; +const static char* t30_in[] = + {t30_in_0, t30_in_1, t30_in_2}; + +const static size_t t30_n_input_items = sizeof (t30_in_0); +const static size_t t30_n_code_inputs = sizeof (t30_in) / sizeof (char*); + +const static char t30_res_0[] = + {0, 1, 1, 0, 1, 0, 1, 0, 1}; +const static char t30_res_1[] = + {0, 1, 0, 1, 0, 1, 1, 0, 0}; +const static char* t30_res[] = + {t30_res_0, t30_res_1}; + +const static size_t t30_n_output_items = sizeof (t30_res_0); +const static size_t t30_n_code_outputs = sizeof (t30_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t30 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t30_in, (const char**) t30_res, + 1, (const size_t*) &t30_n_input_items, + (const size_t*) &t30_n_output_items, 5, t30_n_code_inputs, + t30_n_code_outputs, (const int*) t30_code_generator, + (const int*) t30_code_feedback); +} + +// TEST 31 +// +// checking for: +// state state is 0, different feedbacks, termination to 0 state +// # of term bits will be 4 + +const static int t31_code_generator[] = {1, 4, 0, 3, 1, 6}; +const static int t31_code_feedback[] = {0, 5, 0, 7, 0, 7}; + +const static char t31_in_0[] = + {0, 1, 0, 0, 0, 1, 0, 1, 1}; +const static char t31_in_1[] = + {0, 0, 0, 1, 1, 1, 0, 1, 0}; +const static char* t31_in[] = + {t31_in_0, t31_in_1}; + +const static size_t t31_n_input_items = sizeof (t31_in_0); +const static size_t t31_n_code_inputs = sizeof (t31_in) / sizeof (char*); + +const static char t31_res_0[] = + {0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1}; +const static char t31_res_1[] = + {0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0}; +const static char t31_res_2[] = + {0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; +const static char* t31_res[] = + {t31_res_0, t31_res_1, t31_res_2}; + +const static size_t t31_n_output_items = sizeof (t31_res_0); +const static size_t t31_n_code_outputs = sizeof (t31_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t31 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t31_in, (const char**) t31_res, + 1, (const size_t*) &t31_n_input_items, + (const size_t*) &t31_n_output_items, 6, t31_n_code_inputs, + t31_n_code_outputs, (const int*) t31_code_generator, + (const int*) t31_code_feedback); +} + +// TEST 32 +// +// checking for: +// start state is 0, different feedbacks, termination to non-0 state +// # of term bits will be 2 + +const static int t32_code_generator[] = {1, 0, 1, 4, 3, 6}; +const static int t32_code_feedback[] = {0, 0, 0, 5, 7, 7}; +const static size_t t32_term_state = 4; + +const static char t32_in_0[] = + {0, 1, 0, 0, 0, 0, 1}; +const static char t32_in_1[] = + {0, 0, 1, 0, 1, 0, 1}; +const static char t32_in_2[] = + {0, 0, 0, 1, 0, 0, 1}; +const static char* t32_in[] = + {t32_in_0, t32_in_1, t32_in_2}; + +const static size_t t32_n_input_items = sizeof (t32_in_0); +const static size_t t32_n_code_inputs = sizeof (t32_in) / sizeof (char*); + +const static char t32_res_0[] = + {0, 1, 0, 1, 0, 1, 1, 0, 0}; +const static char t32_res_1[] = + {0, 0, 1, 1, 1, 1, 1, 0, 1}; +const static char* t32_res[] = + {t32_res_0, t32_res_1}; + +const static size_t t32_n_output_items = sizeof (t32_res_0); +const static size_t t32_n_code_outputs = sizeof (t32_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t32 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t32_in, (const char**) t32_res, + 1, (const size_t*) &t32_n_input_items, + (const size_t*) &t32_n_output_items, 5, t32_n_code_inputs, + t32_n_code_outputs, (const int*) t32_code_generator, + (const int*) t32_code_feedback, true, 0, t32_term_state); +} + +// TEST 33 +// +// checking for termination to non-0 state, no feedback + +const static int t33_code_generator[] = {1, 0, 3, 0, 1, 6}; +const static size_t t33_term_state = 2; + +const static char t33_in_0[] = + {0, 1, 0, 1, 0, 0, 1, 1}; +const static char t33_in_1[] = + {0, 1, 0, 0, 1, 0, 1, 1}; +const static char t33_in_2[] = + {0, 1, 0, 1, 1, 0, 0, 1}; +const static char* t33_in[] = + {t33_in_0, t33_in_1, t33_in_2}; + +const static size_t t33_n_input_items = sizeof (t33_in_0); +const static size_t t33_n_code_inputs = sizeof (t33_in) / sizeof (char*); + +const static char t33_res_0[] = + {0, 0, 1, 0, 0, 0, 1, 0, 1, 0}; +const static char t33_res_1[] = + {0, 1, 1, 1, 0, 0, 0, 0, 1, 1}; +const static char* t33_res[] = + {t33_res_0, t33_res_1}; + +const static size_t t33_n_output_items = sizeof (t33_res_0); +const static size_t t33_n_code_outputs = sizeof (t33_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t33 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t33_in, (const char**) t33_res, + 1, (const size_t*) &t33_n_input_items, + (const size_t*) &t33_n_output_items, 5, + t33_n_code_inputs, t33_n_code_outputs, + (const int*) t33_code_generator, + 0, true, 0, t33_term_state); +} + +// TEST 34 +// +// checking for: +// start state is not 0, no feedback, terminating to 0 state + +const static int t34_code_generator[] = {1, 0, 3, 0, 1, 6}; +const static size_t t34_start_state = 1; + +const static char t34_in_0[] = + {0, 1, 0, 0, 0, 1, 0}; +const static char t34_in_1[] = + {0, 0, 1, 0, 0, 1, 0}; +const static char t34_in_2[] = + {0, 1, 1, 1, 0, 1, 1}; +const static char* t34_in[] = + {t34_in_0, t34_in_1, t34_in_2}; + +const static size_t t34_n_input_items = sizeof (t34_in_0); +const static size_t t34_n_code_inputs = sizeof (t34_in) / sizeof (char*); + +const static char t34_res_0[] = + {1, 0, 0, 0, 1, 0, 0, 1, 0}; +const static char t34_res_1[] = + {1, 1, 0, 0, 0, 1, 0, 0, 0}; +const static char* t34_res[] = + {t34_res_0, t34_res_1}; + +const static size_t t34_n_output_items = sizeof (t34_res_0); +const static size_t t34_n_code_outputs = sizeof (t34_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t34 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t34_in, (const char**) t34_res, + 1, (const size_t*) &t34_n_input_items, + (const size_t*) &t34_n_output_items, 5, + t34_n_code_inputs, t34_n_code_outputs, + (const int*) t34_code_generator, + 0, true, t34_start_state); +} + +// TEST 35 +// +// checking for: +// start state is not 0, no feedback, terminating to non-0 state + +const static int t35_code_generator[] = {1, 0, 3, 0, 1, 6}; +const static size_t t35_start_state = 2; +const static size_t t35_term_state = 2; + +const static char t35_in_0[] = + {0, 1, 1, 1, 0, 1, 0}; +const static char t35_in_1[] = + {0, 1, 0, 0, 0, 0, 1}; +const static char t35_in_2[] = + {0, 1, 1, 0, 1, 0, 1}; +const static char* t35_in[] = + {t35_in_0, t35_in_1, t35_in_2}; + +const static size_t t35_n_input_items = sizeof (t35_in_0); +const static size_t t35_n_code_inputs = sizeof (t35_in) / sizeof (char*); + +const static char t35_res_0[] = + {0, 0, 1, 0, 1, 0, 1, 1, 1}; +const static char t35_res_1[] = + {1, 1, 1, 0, 1, 1, 0, 1, 1}; +const static char* t35_res[] = + {t35_res_0, t35_res_1}; + +const static size_t t35_n_output_items = sizeof (t35_res_0); +const static size_t t35_n_code_outputs = sizeof (t35_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t35 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t35_in, (const char**) t35_res, + 1, (const size_t*) &t35_n_input_items, + (const size_t*) &t35_n_output_items, 5, t35_n_code_inputs, + t35_n_code_outputs, (const int*) t35_code_generator, + 0, true, t35_start_state, t35_term_state); +} + +// TEST 36 +// +// checking for: +// start state is not 0, any feedback, termination to 0 state + +const static int t36_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t36_code_feedback[] = {0, 0, 7, 0, 0, 7}; +const static size_t t36_start_state = 2; +const static size_t t36_term_state = 0; + +const static char t36_in_0[] = + {0, 1, 0, 0, 0, 1, 0}; +const static char t36_in_1[] = + {0, 0, 1, 1, 0, 1, 0}; +const static char t36_in_2[] = + {0, 0, 0, 0, 1, 0, 0}; +const static char* t36_in[] = + {t36_in_0, t36_in_1, t36_in_2}; + +const static size_t t36_n_input_items = sizeof (t36_in_0); +const static size_t t36_n_code_inputs = sizeof (t36_in) / sizeof (char*); + +const static char t36_res_0[] = + {0, 0, 1, 0, 0, 1, 0, 1, 1}; +const static char t36_res_1[] = + {1, 1, 1, 0, 1, 1, 0, 0, 1}; +const static char* t36_res[] = + {t36_res_0, t36_res_1}; + +const static size_t t36_n_output_items = sizeof (t36_res_0); +const static size_t t36_n_code_outputs = sizeof (t36_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t36 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t36_in, (const char**) t36_res, + 1, (const size_t*) &t36_n_input_items, + (const size_t*) &t36_n_output_items, 5, + t36_n_code_inputs, t36_n_code_outputs, + (const int*) t36_code_generator, + (const int*) t36_code_feedback, + true, t36_start_state, t36_term_state); +} + +// TEST 37 +// +// checking for: +// start state is not 0, any feedback, termination to non-zero state + +const static int t37_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t37_code_feedback[] = {0, 0, 7, 0, 0, 7}; +const static size_t t37_start_state = 1; +const static size_t t37_term_state = 2; + +const static char t37_in_0[] = + {0, 1, 0, 1, 0, 1, 0}; +const static char t37_in_1[] = + {0, 0, 0, 0, 1, 1, 0}; +const static char t37_in_2[] = + {0, 1, 0, 0, 0, 1, 1}; +const static char* t37_in[] = + {t37_in_0, t37_in_1, t37_in_2}; + +const static size_t t37_n_input_items = sizeof (t37_in_0); +const static size_t t37_n_code_inputs = sizeof (t37_in) / sizeof (char*); + +const static char t37_res_0[] = + {1, 1, 1, 1, 1, 0, 1, 1, 1}; +const static char t37_res_1[] = + {1, 0, 0, 1, 0, 0, 0, 0, 1}; +const static char* t37_res[] = + {t37_res_0, t37_res_1}; + +const static size_t t37_n_output_items = sizeof (t37_res_0); +const static size_t t37_n_code_outputs = sizeof (t37_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t37 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t37_in, (const char**) t37_res, + 1, (const size_t*) &t37_n_input_items, + (const size_t*) &t37_n_output_items, 5, + t37_n_code_inputs, t37_n_code_outputs, + (const int*) t37_code_generator, + (const int*) t37_code_feedback, + true, t37_start_state, t37_term_state); +} + +// TEST 38 +// +// checking for: +// no feedback, block coding but no termination + +const static int t38_code_generator[] = {1, 0, 3, 0, 1, 6}; + +const static char t38_in_0[] = + {0, 1, 0, 1, 0, 0, 1, 1}; +const static char t38_in_1[] = + {0, 1, 0, 0, 1, 0, 1, 1}; +const static char t38_in_2[] = + {0, 1, 0, 1, 1, 0, 0, 1}; +const static char* t38_in[] = + {t38_in_0, t38_in_1, t38_in_2}; + +const static size_t t38_n_input_items = sizeof (t38_in_0); +const static size_t t38_n_code_inputs = sizeof (t38_in) / sizeof (char*); + +const static char t38_res_0[] = + {0, 0, 1, 0, 0, 0, 1, 0}; +const static char t38_res_1[] = + {0, 1, 1, 1, 0, 0, 1, 1}; +const static char* t38_res[] = + {t38_res_0, t38_res_1}; + +const static size_t t38_n_output_items = sizeof (t38_res_0); +const static size_t t38_n_code_outputs = sizeof (t38_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t38 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t38_in, (const char**) t38_res, + 1, (const size_t*) &t38_n_input_items, + (const size_t*) &t38_n_output_items, 5, + t38_n_code_inputs, t38_n_code_outputs, + (const int*) t38_code_generator, 0, false); +} + +// TEST 39 +// +// checking for: +// start state is 0, same feedback, block but no termination + +const static int t39_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t39_code_feedback[] = {0, 0, 7, 0, 0, 7}; + +const static char t39_in_0[] = + {0, 1, 1, 0, 0, 0, 0}; +const static char t39_in_1[] = + {0, 1, 0, 1, 0, 0, 0}; +const static char t39_in_2[] = + {0, 0, 0, 0, 1, 0, 1}; +const static char* t39_in[] = + {t39_in_0, t39_in_1, t39_in_2}; + +const static size_t t39_n_input_items = sizeof (t39_in_0); +const static size_t t39_n_code_inputs = sizeof (t39_in) / sizeof (char*); + +const static char t39_res_0[] = + {0, 1, 1, 0, 1, 0, 1}; +const static char t39_res_1[] = + {0, 1, 0, 1, 0, 0, 0}; +const static char* t39_res[] = + {t39_res_0, t39_res_1}; + +const static size_t t39_n_output_items = sizeof (t39_res_0); +const static size_t t39_n_code_outputs = sizeof (t39_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t39 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t39_in, (const char**) t39_res, + 1, (const size_t*) &t39_n_input_items, + (const size_t*) &t39_n_output_items, 5, t39_n_code_inputs, + t39_n_code_outputs, (const int*) t39_code_generator, + (const int*) t39_code_feedback, false); +} + +// TEST 40 +// +// checking for: +// state state is 0, different feedbacks, block but no termination + +const static int t40_code_generator[] = {1, 4, 0, 3, 1, 6}; +const static int t40_code_feedback[] = {0, 5, 0, 7, 0, 7}; + +const static char t40_in_0[] = + {0, 1, 0, 0, 0, 1, 0, 1, 1}; +const static char t40_in_1[] = + {0, 0, 0, 1, 1, 1, 0, 1, 0}; +const static char* t40_in[] = + {t40_in_0, t40_in_1}; + +const static size_t t40_n_input_items = sizeof (t40_in_0); +const static size_t t40_n_code_inputs = sizeof (t40_in) / sizeof (char*); + +const static char t40_res_0[] = + {0, 1, 0, 0, 0, 0, 0, 1, 1}; +const static char t40_res_1[] = + {0, 0, 0, 1, 1, 0, 0, 1, 0}; +const static char t40_res_2[] = + {0, 1, 0, 0, 1, 0, 0, 1, 0}; +const static char* t40_res[] = + {t40_res_0, t40_res_1, t40_res_2}; + +const static size_t t40_n_output_items = sizeof (t40_res_0); +const static size_t t40_n_code_outputs = sizeof (t40_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t40 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t40_in, (const char**) t40_res, + 1, (const size_t*) &t40_n_input_items, + (const size_t*) &t40_n_output_items, 6, t40_n_code_inputs, + t40_n_code_outputs, (const int*) t40_code_generator, + (const int*) t40_code_feedback, false); +} + +// TEST 41 +// +// checking for: +// start state is not 0, no feedback, terminating to non-0 state +// multi-encode, forced to retrieve all term outputs + +const static int t41_code_generator[] = {1, 0, 3, 0, 1, 6}; +const static size_t t41_start_state = 2; +const static size_t t41_term_state = 2; + +const static char t41_in_0[] = + {0, 1, 1, 1, 0, 1, 0}; +const static char t41_in_1[] = + {0, 1, 0, 0, 0, 0, 1}; +const static char t41_in_2[] = + {0, 1, 1, 0, 1, 0, 1}; +const static char* t41_in[] = + {t41_in_0, t41_in_1, t41_in_2}; + +const static size_t t41_n_input_items[] = {3, 2, 2}; +const static size_t t41_n_io_items = (sizeof (t41_n_input_items) / + sizeof (size_t)); +const static size_t t41_n_code_inputs = sizeof (t41_in) / sizeof (char*); + +const static char t41_res_0[] = + {0, 0, 1, 0, 1, 0, 1, 1, 1}; +const static char t41_res_1[] = + {1, 1, 1, 0, 1, 1, 0, 1, 1}; +const static char* t41_res[] = + {t41_res_0, t41_res_1}; + +const static size_t t41_n_output_items[] = {3, 4, 2}; +const static size_t t41_n_code_outputs = sizeof (t41_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t41 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t41_in, (const char**) t41_res, + t41_n_io_items, (const size_t*) t41_n_input_items, + (const size_t*) t41_n_output_items, 5, t41_n_code_inputs, + t41_n_code_outputs, (const int*) t41_code_generator, + 0, true, t41_start_state, t41_term_state); +} + +// TEST 42 +// +// checking for: +// start state is not 0, any feedback, termination to non-zero state +// multi-encode + +const static int t42_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t42_code_feedback[] = {0, 0, 7, 0, 0, 7}; +const static size_t t42_start_state = 1; +const static size_t t42_term_state = 2; + +const static char t42_in_0[] = + {0, 1, 0, 1, 0, 1, 0}; +const static char t42_in_1[] = + {0, 0, 0, 0, 1, 1, 0}; +const static char t42_in_2[] = + {0, 1, 0, 0, 0, 1, 1}; +const static char* t42_in[] = + {t42_in_0, t42_in_1, t42_in_2}; + +const static size_t t42_n_input_items[] = {2, 2, 1, 1, 1}; +const static size_t t42_n_io_items = (sizeof (t42_n_input_items) / + sizeof (size_t)); +const static size_t t42_n_code_inputs = sizeof (t42_in) / sizeof (char*); + +const static char t42_res_0[] = + {1, 1, 1, 1, 1, 0, 1, 1, 1}; +const static char t42_res_1[] = + {1, 0, 0, 1, 0, 0, 0, 0, 1}; +const static char* t42_res[] = + {t42_res_0, t42_res_1}; + +const static size_t t42_n_output_items[] = {2, 2, 3, 1, 1}; +const static size_t t42_n_code_outputs = sizeof (t42_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t42 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t42_in, (const char**) t42_res, + 1, (const size_t*) &t42_n_input_items, + (const size_t*) &t42_n_output_items, 5, + t42_n_code_inputs, t42_n_code_outputs, + (const int*) t42_code_generator, + (const int*) t42_code_feedback, + true, t42_start_state, t42_term_state); +} + +// TEST 43 +// +// checking for: +// no feedback, block coding but no termination +// multi-encode + +const static int t43_code_generator[] = {1, 0, 3, 0, 1, 6}; + +const static char t43_in_0[] = + {0, 1, 0, 1, 0, 0, 1, 1}; +const static char t43_in_1[] = + {0, 1, 0, 0, 1, 0, 1, 1}; +const static char t43_in_2[] = + {0, 1, 0, 1, 1, 0, 0, 1}; +const static char* t43_in[] = + {t43_in_0, t43_in_1, t43_in_2}; + +const static size_t t43_n_input_items[] = {2, 2, 2, 2}; +const static size_t t43_n_n_input_items = (sizeof (t43_n_input_items) / + sizeof (size_t)); +const static size_t t43_n_code_inputs = sizeof (t43_in) / sizeof (char*); + +const static char t43_res_0[] = + {0, 0, 1, 0, 0, 0, 1, 0}; +const static char t43_res_1[] = + {0, 1, 1, 1, 0, 0, 1, 1}; +const static char* t43_res[] = + {t43_res_0, t43_res_1}; + +const static size_t t43_n_output_items[] = {2, 2, 2, 2}; +const static size_t t43_n_code_outputs = sizeof (t43_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t43 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t43_in, (const char**) t43_res, + t43_n_n_input_items, (const size_t*) t43_n_input_items, + (const size_t*) t43_n_output_items, 5, + t43_n_code_inputs, t43_n_code_outputs, + (const int*) t43_code_generator, 0, false); +} + +// TEST 44 +// +// checking for: +// start state is 0, same feedback, block but no termination +// multi-encode + +const static int t44_code_generator[] = {1, 0, 5, 0, 1, 6}; +const static int t44_code_feedback[] = {0, 0, 7, 0, 0, 7}; + +const static char t44_in_0[] = + {0, 1, 1, 0, 0, 0, 0}; +const static char t44_in_1[] = + {0, 1, 0, 1, 0, 0, 0}; +const static char t44_in_2[] = + {0, 0, 0, 0, 1, 0, 1}; +const static char* t44_in[] = + {t44_in_0, t44_in_1, t44_in_2}; + +const static size_t t44_n_input_items[] = {5, 1, 1}; +const static size_t t44_n_n_input_items = (sizeof (t44_n_input_items) / + sizeof (size_t)); +const static size_t t44_n_code_inputs = sizeof (t44_in) / sizeof (char*); + +const static char t44_res_0[] = + {0, 1, 1, 0, 1, 0, 1}; +const static char t44_res_1[] = + {0, 1, 0, 1, 0, 0, 0}; +const static char* t44_res[] = + {t44_res_0, t44_res_1}; + +const static size_t t44_n_output_items[] = {5, 1, 1}; +const static size_t t44_n_code_outputs = sizeof (t44_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t44 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t44_in, (const char**) t44_res, + t44_n_n_input_items, (const size_t*) t44_n_input_items, + (const size_t*) t44_n_output_items, 5, t44_n_code_inputs, + t44_n_code_outputs, (const int*) t44_code_generator, + (const int*) t44_code_feedback, false); +} + +// TEST 45 +// +// checking for: +// state state is 0, different feedbacks, block but no termination +// multi-encode + +const static int t45_code_generator[] = {1, 4, 0, 3, 1, 6}; +const static int t45_code_feedback[] = {0, 5, 0, 7, 0, 7}; + +const static char t45_in_0[] = + {0, 1, 0, 0, 0, 1, 0, 1, 1}; +const static char t45_in_1[] = + {0, 0, 0, 1, 1, 1, 0, 1, 0}; +const static char* t45_in[] = + {t45_in_0, t45_in_1}; + +const static size_t t45_n_input_items[] = {5, 4}; +const static size_t t45_n_n_input_items = (sizeof (t45_n_input_items) / + sizeof (size_t)); +const static size_t t45_n_code_inputs = sizeof (t45_in) / sizeof (char*); + +const static char t45_res_0[] = + {0, 1, 0, 0, 0, 0, 0, 1, 1}; +const static char t45_res_1[] = + {0, 0, 0, 1, 1, 0, 0, 1, 0}; +const static char t45_res_2[] = + {0, 1, 0, 0, 1, 0, 0, 1, 0}; +const static char* t45_res[] = + {t45_res_0, t45_res_1, t45_res_2}; + +const static size_t t45_n_output_items[] = {5, 4}; +const static size_t t45_n_code_outputs = sizeof (t45_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t45 +() +{ + do_encoder_check (g_do_encode_in_or_out_23_45, + (const char**) t45_in, (const char**) t45_res, + t45_n_n_input_items, (const size_t*) t45_n_input_items, + (const size_t*) t45_n_output_items, 6, t45_n_code_inputs, + t45_n_code_outputs, (const int*) t45_code_generator, + (const int*) t45_code_feedback, false); +} + +// TEST 46 +// +// checking for: +// start state is not 0, no feedback, terminating to non-0 state +// multi-encode, input dictates encoding: forced to retrieve all term +// outputs; multiple encoding blocks + +const static int t46_code_generator[] = {1, 0, 3, 0, 1, 6}; +const static size_t t46_start_state = 2; +const static size_t t46_term_state = 2; + +const static char t46_in_0[] = + {0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0}; +const static char t46_in_1[] = + {0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0}; +const static char t46_in_2[] = + {0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0}; +const static char* t46_in[] = + {t46_in_0, t46_in_1, t46_in_2}; + +const static size_t t46_n_input_items[] = {5, 0, 4, 1, 1}; +const static size_t t46_n_io_items = (sizeof (t46_n_input_items) / + sizeof (size_t)); +const static size_t t46_n_code_inputs = sizeof (t46_in) / sizeof (char*); + +const static char t46_res_0[] = + {0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0}; +const static char t46_res_1[] = + {1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1}; +const static char* t46_res[] = + {t46_res_0, t46_res_1}; + +const static size_t t46_n_output_items[] = {7, 0, 4, 3, 1}; +const static size_t t46_n_code_outputs = sizeof (t46_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t46 +() +{ + do_encoder_check (true, + (const char**) t46_in, (const char**) t46_res, + t46_n_io_items, (const size_t*) t46_n_input_items, + (const size_t*) t46_n_output_items, 5, t46_n_code_inputs, + t46_n_code_outputs, (const int*) t46_code_generator, + 0, true, t46_start_state, t46_term_state); +} + +// TEST 47 +// +// checking for: +// start state is not 0, no feedback, terminating to non-0 state +// multi-encode, output dictates encoding; multiple encoding blocks + +const static int t47_code_generator[] = {1, 0, 3, 0, 1, 6}; +const static size_t t47_start_state = 2; +const static size_t t47_term_state = 2; + +const static char t47_in_0[] = + {0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0}; +const static char t47_in_1[] = + {0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0}; +const static char t47_in_2[] = + {0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0}; +const static char* t47_in[] = + {t47_in_0, t47_in_1, t47_in_2}; + +const static size_t t47_n_input_items[] = {5, 0, 0, 4, 1, 0, 0, 1}; +const static size_t t47_n_io_items = (sizeof (t47_n_input_items) / + sizeof (size_t)); +const static size_t t47_n_code_inputs = sizeof (t47_in) / sizeof (char*); + +const static char t47_res_0[] = + {0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0}; +const static char t47_res_1[] = + {1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1}; +const static char* t47_res[] = + {t47_res_0, t47_res_1}; + +const static size_t t47_n_output_items[] = {6, 0, 1, 4, 1, 1, 1, 1}; +const static size_t t47_n_code_outputs = sizeof (t47_res) / sizeof (char*); + +void +qa_encoder_convolutional_ic1_ic1::t47 +() +{ + do_encoder_check (false, + (const char**) t47_in, (const char**) t47_res, + t47_n_io_items, (const size_t*) t47_n_input_items, + (const size_t*) t47_n_output_items, 5, t47_n_code_inputs, + t47_n_code_outputs, (const int*) t47_code_generator, + 0, true, t47_start_state, t47_term_state); +} + diff --git a/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.h b/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.h index 64ab3ab5f..5890bb9ef 100644 --- a/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.h +++ b/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.h @@ -39,19 +39,63 @@ class qa_encoder_convolutional_ic1_ic1 : public CppUnit::TestCase { CPPUNIT_TEST (t6); CPPUNIT_TEST (t7); CPPUNIT_TEST (t8); + CPPUNIT_TEST (t9); + CPPUNIT_TEST (t10); + CPPUNIT_TEST (t11); + CPPUNIT_TEST (t12); + CPPUNIT_TEST (t13); + CPPUNIT_TEST (t14); + CPPUNIT_TEST (t15); + CPPUNIT_TEST (t16); + CPPUNIT_TEST (t17); + CPPUNIT_TEST (t18); + CPPUNIT_TEST (t19); + CPPUNIT_TEST (t20); + CPPUNIT_TEST (t21); + CPPUNIT_TEST (t22); + CPPUNIT_TEST (t23); + CPPUNIT_TEST (t24); + CPPUNIT_TEST (t25); + CPPUNIT_TEST (t26); + CPPUNIT_TEST (t27); + CPPUNIT_TEST (t28); + CPPUNIT_TEST (t29); + CPPUNIT_TEST (t30); + CPPUNIT_TEST (t31); + CPPUNIT_TEST (t32); + CPPUNIT_TEST (t33); + CPPUNIT_TEST (t34); + CPPUNIT_TEST (t35); + CPPUNIT_TEST (t36); + CPPUNIT_TEST (t37); + CPPUNIT_TEST (t38); + CPPUNIT_TEST (t39); + CPPUNIT_TEST (t40); + CPPUNIT_TEST (t41); + CPPUNIT_TEST (t42); + CPPUNIT_TEST (t43); + CPPUNIT_TEST (t44); + CPPUNIT_TEST (t45); + CPPUNIT_TEST (t46); + CPPUNIT_TEST (t47); CPPUNIT_TEST_SUITE_END (); private: - void do_encoder_check (int test_n, + void do_encoder_check (bool use_encode_in_or_out, const char** c_t1_in, const char** c_t1_res, - int n_input_items, - int n_output_items, - int block_size_bits, - int n_code_inputs, - int n_code_outputs, + const size_t n_io_items, + const size_t* n_input_items, + const size_t* n_output_items, + const size_t block_size_bits, + const size_t n_code_inputs, + const size_t n_code_outputs, const int* code_generators, - const int* code_feedback = 0); + const int* code_feedback = 0, + const bool do_termination = true, + const size_t start_state = 0, + const size_t term_state = 0, + const int encode_soai = -1); void t0 (); void t1 (); @@ -62,6 +106,45 @@ class qa_encoder_convolutional_ic1_ic1 : public CppUnit::TestCase { void t6 (); void t7 (); void t8 (); + void t9 (); + void t10 (); + void t11 (); + void t12 (); + void t13 (); + void t14 (); + void t15 (); + void t16 (); + void t17 (); + void t18 (); + void t19 (); + void t20 (); + void t21 (); + void t22 (); + void t23 (); + void t24 (); + void t25 (); + void t26 (); + void t27 (); + void t28 (); + void t29 (); + void t30 (); + void t31 (); + void t32 (); + void t33 (); + void t34 (); + void t35 (); + void t36 (); + void t37 (); + void t38 (); + void t39 (); + void t40 (); + void t41 (); + void t42 (); + void t43 (); + void t44 (); + void t45 (); + void t46 (); + void t47 (); }; #endif /* INCLUDED_QA_ENCODER_CONVOLUTIONAL_IC1_IC1_H */ |