[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] gr-error-correcting-codes/src/lib/libecc encode...
From: |
Michael Dickens |
Subject: |
[Commit-gnuradio] gr-error-correcting-codes/src/lib/libecc encode... |
Date: |
Sat, 15 Jul 2006 23:48:15 +0000 |
CVSROOT: /sources/gnuradio
Module name: gr-error-correcting-codes
Changes by: Michael Dickens <michaelld> 06/07/15 23:48:15
Modified files:
src/lib/libecc : encoder_convolutional.cc
encoder_convolutional.h
encoder_convolutional_ic1_ic1.cc
encoder_convolutional_ic1_ic1.h
encoder_convolutional_ic8_ic8.h
src/lib/libecc/tests: qa_encoder_convolutional_ic1_ic1.cc
Log message:
Corrections to allow for non-feedback encoders to work.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.cc?cvsroot=gnuradio&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.h?cvsroot=gnuradio&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional_ic1_ic1.cc?cvsroot=gnuradio&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional_ic1_ic1.h?cvsroot=gnuradio&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional_ic8_ic8.h?cvsroot=gnuradio&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.cc?cvsroot=gnuradio&r1=1.1&r2=1.2
Patches:
Index: encoder_convolutional.cc
===================================================================
RCS file:
/sources/gnuradio/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.cc,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- encoder_convolutional.cc 14 Jul 2006 17:29:25 -0000 1.8
+++ encoder_convolutional.cc 15 Jul 2006 23:48:15 -0000 1.9
@@ -240,13 +240,6 @@
d_current_inputs.assign (d_n_code_inputs, 0);
d_current_outputs.assign (d_n_code_outputs, 0);
-
-
- // still need to fill in:
- // d_max_delay, d_n_memories, d_total_n_delays,
- // d_code_feedback (if FB), d_io_num, d_max_mem_masks (if SIAO),
- // d_states_ndx, d_do_encode_soai
-
// check and compute memory requirements in order to determine which
// realization uses the least memory; create and save findings to
// not have to re-do these computations later.
@@ -265,14 +258,22 @@
size_t t_max_mem = 0;
size_t t_n_unique_fb_prev_start = d_n_memories;
- for (size_t m = 0; m < d_n_code_inputs; m++)
+ for (size_t m = 0; m < d_n_code_inputs; m++) {
get_memory_requirements (m, n, t_max_mem,
t_n_unique_fb_prev_start, code_feedback);
-
+ if (d_do_feedback == false) {
+ d_states_ndx[maio(m,n)] = n;
+ }
+ }
if (d_do_feedback == false) {
// not feedback; just store memory requirements for this output
d_total_n_delays += t_max_mem;
+ d_n_delays[n] = t_max_mem;
+ d_io_num[n] = n;
+ }
}
+ if (d_do_feedback == false) {
+ d_n_memories = d_n_code_outputs;
}
// store the parameters for SOAI
@@ -281,11 +282,15 @@
std::vector<size_t> t_states_ndx_soai;
size_t t_max_delay_soai, t_total_n_delays_soai, t_n_memories_soai;
- for (size_t m = 0; m < d_code_feedback.size (); m++)
- t_fb_generators_soai[m] = d_code_feedback[m];
+ t_fb_generators_soai.assign (d_code_feedback.size (), 0);
+ t_fb_generators_soai = d_code_feedback;
+ t_n_delays_soai.assign (d_n_delays.size (), 0);
t_n_delays_soai = d_n_delays;
+ t_io_num_soai.assign (d_io_num.size (), 0);
t_io_num_soai = d_io_num;
+ t_states_ndx_soai.assign (d_states_ndx.size (), 0);
t_states_ndx_soai = d_states_ndx;
+
t_n_memories_soai = d_n_memories;
t_total_n_delays_soai = d_total_n_delays;
t_max_delay_soai = d_max_delay;
@@ -304,15 +309,23 @@
size_t t_max_mem = 0;
size_t t_n_unique_fb_prev_start = d_n_memories;
- for (size_t n = 0; n < d_n_code_outputs; n++)
+ for (size_t n = 0; n < d_n_code_outputs; n++) {
get_memory_requirements (m, n, t_max_mem,
t_n_unique_fb_prev_start, code_feedback);
-
+ if (d_do_feedback == false) {
+ d_states_ndx[maio(m,n)] = m;
+ }
+ }
if (d_do_feedback == false) {
// not feedback; just store memory requirements for this output
d_total_n_delays += t_max_mem;
+ d_n_delays[m] = t_max_mem;
+ d_io_num[m] = m;
}
}
+ if (d_do_feedback == false) {
+ d_n_memories = d_n_code_inputs;
+ }
if (DO_PRINT_DEBUG) {
std::cout <<
@@ -331,10 +344,7 @@
} else {
// use soai
d_do_encode_soai = true;
-
- for (size_t m = 0; m < d_code_feedback.size (); m++)
- d_code_feedback[m] = t_fb_generators_soai[m];
-
+ d_code_feedback = t_fb_generators_soai;
d_n_delays = t_n_delays_soai;
d_io_num = t_io_num_soai;
d_states_ndx = t_states_ndx_soai;
@@ -343,14 +353,6 @@
d_max_delay = t_max_delay_soai;
}
- if (DO_PRINT_DEBUG) {
- std::cout <<
- " d_total_n_delays = " << d_total_n_delays << "\n"
- " d_max_delay = " << d_max_delay << "\n"
- " d_do_encode_soai = " <<
- ((d_do_encode_soai == true) ? "true" : "false") << "\n";
- }
-
// make sure the block length makes sense, #2
if ((d_do_streaming == false) & (d_block_size_bits < d_max_delay)) {
@@ -376,7 +378,19 @@
}
}
+ if (DO_PRINT_DEBUG) {
+ std::cout <<
+ " d_n_memories = " << d_n_memories << "\n"
+ " d_total_n_delays = " << d_total_n_delays << "\n"
+ " d_max_delay = " << d_max_delay << "\n"
+ " d_do_encode_soai = " <<
+ ((d_do_encode_soai == true) ? "true" : "false") << "\n";
+ }
+
// FIXME: STILL NEED TO parse START AND END MEMORY STATES;
+
+ d_init_states.assign (d_n_memories, 0);
+ d_term_states.assign (d_n_memories, 0);
}
void
@@ -417,7 +431,6 @@
// get the FB code; AND off the LSB for correct functionality
// during internal computations.
-
t_in_code = ((memory_t)((*code_feedback)[maio(m,n)]));
t_in_code &= ((memory_t)(-2));
@@ -644,20 +657,58 @@
// masking required.
for (size_t p = 0; p < d_n_memories; p++) {
+ if (DO_PRINT_DEBUG) {
+ std::cout << "m_i[" << p << "] = " <<
+ n2bs(d_memory[p], 1+d_n_delays[p]);
+ }
+
d_memory[p] >>= 1;
+
+ if (DO_PRINT_DEBUG) {
+ std::cout << " >>= 1 -> " <<
+ n2bs(d_memory[p], 1+d_n_delays[p]) << "\n";
+ }
}
// for each input bit, if that bit's a '1', then XOR the code
// generators into the correct state's memory.
for (size_t m = 0; m < d_n_code_inputs; m++) {
+ if (DO_PRINT_DEBUG) {
+ std::cout << "c_i[" << m << "] = " <<
+ n2bs(d_current_inputs[m],1);
+ }
if (d_current_inputs[m] == 1) {
+ if (DO_PRINT_DEBUG) {
+ std::cout << "\n";
+ }
for (size_t n = 0; n < d_n_code_outputs; n++) {
+ if (DO_PRINT_DEBUG) {
+ std::cout << "m_i[s_ndx[" << m << "][" << n << "] == " <<
+ d_states_ndx[maio(m,n)] << "] = " <<
+ n2bs(d_memory[d_states_ndx[maio(m,n)]],
+ 1+d_n_delays[d_states_ndx[maio(m,n)]]);
+ }
+
d_memory[d_states_ndx[maio(m,n)]] ^= d_code_generators[maio(m,n)];
+
+ if (DO_PRINT_DEBUG) {
+ std::cout << " ^= c_g[][] == " <<
+ n2bs(d_code_generators[maio(m,n)],
+ 1+d_n_delays[d_states_ndx[maio(m,n)]]) <<
+ " -> " << n2bs(d_memory[d_states_ndx[maio(m,n)]],
+ 1+d_n_delays[d_states_ndx[maio(m,n)]]) << "\n";
+ }
}
+ } else if (DO_PRINT_DEBUG) {
+ std::cout << " ... nothing to do\n";
}
}
+ for (size_t p = 0; p < d_n_code_outputs; p++) {
+ d_current_outputs[p] = 0;
+ }
+
// create the output bits, by XOR'ing the individual unique
// memory(ies) into the correct output bit
@@ -710,7 +761,15 @@
// masking required.
for (size_t p = 0; p < d_n_memories; p++) {
+ if (DO_PRINT_DEBUG) {
+ std::cout << "m_i[" << p << "] = " << d_memory[p];
+ }
+
d_memory[p] >>= 1;
+
+ if (DO_PRINT_DEBUG) {
+ std::cout << "-> " << d_memory[p] << "\n";
+ }
}
// for each input bit, if that bit's a '1', then XOR the code
@@ -789,8 +848,23 @@
// off the extra high bits; then XOR in the input bit.
for (size_t p = 0; p < d_n_memories; p++) {
+ if (DO_PRINT_DEBUG) {
+ std::cout << "t_m[" << p << "] = (" <<
+ n2bs(d_memory[p],d_n_delays[p]+1) <<
+ " << 1) & mask = " <<
+ n2bs(d_max_mem_masks[p],d_n_delays[p]+1);
+ }
+
memory_t t_mem = (d_memory[p] << 1) & d_max_mem_masks[p];
d_memory[p] = t_mem ^ ((memory_t)(d_current_inputs[d_io_num[p]]));
+
+ if (DO_PRINT_DEBUG) {
+ std::cout << ", -> t_m = " << n2bs(t_mem,d_n_delays[p]+1) <<
+ ", t_i[" << d_io_num[p] << "] = " <<
+ n2bs(d_current_inputs[d_io_num[p]],2) <<
+ " -> d_m_o = " <<
+ n2bs(d_memory[p],d_n_delays[p]+1) << "\n";
+ }
}
// create the output bits: for each output, loop over all inputs,
@@ -914,6 +988,9 @@
// FIXME: how to figure out which term bit to get?
// loop to set each entry of "d_current_inputs"
+ // need to do feedback separately, since it involves determining the
+ // FB bit value & using that as the input value to cancel it out
+
d_current_inputs.assign (d_n_code_inputs, 0);
// return (d_term_states[code_input_n] & 1);
}
Index: encoder_convolutional.h
===================================================================
RCS file:
/sources/gnuradio/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- encoder_convolutional.h 12 Jul 2006 23:43:38 -0000 1.5
+++ encoder_convolutional.h 15 Jul 2006 23:48:15 -0000 1.6
@@ -74,7 +74,7 @@
*/
public:
- inline encoder_convolutional
+ encoder_convolutional
(int block_size_bits,
int n_code_inputs,
int n_code_outputs,
@@ -106,7 +106,7 @@
* the code_generator.
*/
- inline encoder_convolutional
+ encoder_convolutional
(int block_size_bits,
int n_code_inputs,
int n_code_outputs,
Index: encoder_convolutional_ic1_ic1.cc
===================================================================
RCS file:
/sources/gnuradio/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional_ic1_ic1.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- encoder_convolutional_ic1_ic1.cc 12 Jul 2006 23:43:38 -0000 1.4
+++ encoder_convolutional_ic1_ic1.cc 15 Jul 2006 23:48:15 -0000 1.5
@@ -126,7 +126,7 @@
std::cout << "Starting output_bit:\n"
" O_i[" << n << "][" << d_out_buf_ndx << "] = " <<
n2bs (out_buf[n][d_out_buf_ndx], g_num_bits_per_byte) <<
- ", b_out = " << n2bs (d_current_outputs[n], 2) << ", ";
+ ", b_out = " << n2bs (d_current_outputs[n], 1) << ", ";
}
out_buf[n][d_out_buf_ndx] = d_current_outputs[n];
@@ -166,16 +166,26 @@
if (DO_PRINT_DEBUG) {
std::cout << "I[" << m << "][" << d_in_buf_ndx << "] = " <<
- n2bs (d_current_inputs[m], 2) << "\n";
+ n2bs (d_current_inputs[m], 1) << "\n";
}
}
// decrement the number of bits left on all streams
+ if (DO_PRINT_DEBUG) {
+ std::cout << "# in bits left: " << d_n_input_bits_left <<
+ " -> " << (d_n_input_bits_left-1) << "\n";
+ }
+
d_n_input_bits_left--;
// increment the input index (not the bit shift index) for the next
// read
+ if (DO_PRINT_DEBUG) {
+ std::cout << "# in buf ndx: " << d_in_buf_ndx <<
+ " -> " << (d_in_buf_ndx+1) << "\n";
+ }
+
d_in_buf_ndx++;
}
Index: encoder_convolutional_ic1_ic1.h
===================================================================
RCS file:
/sources/gnuradio/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional_ic1_ic1.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- encoder_convolutional_ic1_ic1.h 14 Jul 2006 19:49:25 -0000 1.5
+++ encoder_convolutional_ic1_ic1.h 15 Jul 2006 23:48:15 -0000 1.6
@@ -44,7 +44,7 @@
* the single output bit per output item.
*/
- inline encoder_convolutional_ic1_ic1
+ encoder_convolutional_ic1_ic1
(int frame_size_bits,
int n_code_inputs,
int n_code_outputs,
@@ -52,18 +52,15 @@
bool do_termination = true,
int start_memory_state = 0,
int end_memory_state = 0)
-#if 1
: encoder_convolutional (frame_size_bits,
n_code_inputs,
n_code_outputs,
code_generators,
do_termination,
start_memory_state,
- end_memory_state)
-#endif
- {};
+ end_memory_state) {};
- inline encoder_convolutional_ic1_ic1
+ encoder_convolutional_ic1_ic1
(int frame_size_bits,
int n_code_inputs,
int n_code_outputs,
@@ -72,7 +69,6 @@
bool do_termination = true,
int start_memory_state = 0,
int end_memory_state = 0)
-#if 1
: encoder_convolutional (frame_size_bits,
n_code_inputs,
n_code_outputs,
@@ -80,9 +76,7 @@
code_feedback,
do_termination,
start_memory_state,
- end_memory_state)
-#endif
-{};
+ end_memory_state) {};
virtual ~encoder_convolutional_ic1_ic1 () {};
Index: encoder_convolutional_ic8_ic8.h
===================================================================
RCS file:
/sources/gnuradio/gr-error-correcting-codes/src/lib/libecc/encoder_convolutional_ic8_ic8.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- encoder_convolutional_ic8_ic8.h 9 Jul 2006 16:15:17 -0000 1.2
+++ encoder_convolutional_ic8_ic8.h 15 Jul 2006 23:48:15 -0000 1.3
@@ -44,7 +44,7 @@
class encoder_convolutional_ic8_ic8 : public encoder_convolutional
{
public:
- inline encoder_convolutional_ic8_ic8
+ encoder_convolutional_ic8_ic8
(int frame_size_bits,
int n_code_inputs,
int n_code_outputs,
@@ -60,7 +60,7 @@
start_memory_state,
end_memory_state) {};
- inline encoder_convolutional_ic8_ic8
+ encoder_convolutional_ic8_ic8
(int frame_size_bits,
int n_code_inputs,
int n_code_outputs,
Index: tests/qa_encoder_convolutional_ic1_ic1.cc
===================================================================
RCS file:
/sources/gnuradio/gr-error-correcting-codes/src/lib/libecc/tests/qa_encoder_convolutional_ic1_ic1.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- tests/qa_encoder_convolutional_ic1_ic1.cc 14 Jul 2006 19:49:25 -0000
1.1
+++ tests/qa_encoder_convolutional_ic1_ic1.cc 15 Jul 2006 23:48:15 -0000
1.2
@@ -44,9 +44,9 @@
{t0_in_0, t0_in_1, t0_in_2};
const static char t0_res_0[t0_n_output_items] =
- {0, 0, 1, 1, 1, 1, 1, 0, 0, 0};
+ {0, 1, 1, 1, 1, 0, 1, 1, 1, 0};
const static char t0_res_1[t0_n_output_items] =
- {0, 0, 0, 1, 1, 1, 1, 1, 0, 0};
+ {0, 1, 0, 1, 0, 1, 1, 0, 1, 0};
const static char* t0_res[t0_n_code_outputs] =
{t0_res_0, t0_res_1};