Skip to content

Commit

Permalink
channel::decode_mlse() : add a new unit test for MLSE time domain equ…
Browse files Browse the repository at this point in the history
…alizer
  • Loading branch information
kamarya committed Mar 13, 2021
1 parent 374ecf6 commit 25d3761
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 45 deletions.
25 changes: 12 additions & 13 deletions inc/susa/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ template <class T> class channel
*
* @param mat_arg the encoded signal vector
* @param dbl_ebn0 the signal to noise ratio Eb/N0
* @return Log Likelihood Ratio (LLR) vector
*/
matrix <T> decode_bcjr(const matrix <T> &mat_arg, T dbl_ebn0);

Expand Down Expand Up @@ -310,7 +311,6 @@ template <class T> matrix <T> channel <T>::decode_mlse(const matrix <T> &mat_arg
}



// Trace Back the Trellis (decoding)
unsigned int uint_curr_state = uint_init_state;
unsigned int uint_curr_input;
Expand Down Expand Up @@ -338,16 +338,13 @@ template <class T> matrix <T> channel <T>::decode_mlse(const matrix <T> &mat_arg
// It detects the initial and final states.

T dbl_metric = 0;
unsigned int uint_l = mat_taps.size() - 1;
unsigned int uint_num_stages = mat_arg.size() - 2 * uint_l;
unsigned int uint_num_states = uint_num_states_mem;
size_t sz_length = mat_arg.size();
size_t uint_l = mat_taps.size() - 1;
size_t uint_num_stages = sz_length - 2 * uint_l;
size_t uint_num_states = uint_num_states_mem;

matrix <T> mat_new_arg = mat_arg.mid(uint_l, mat_arg.size() - uint_l - 1);
matrix <T> mat_new_arg = mat_arg.mid(uint_l, sz_length - uint_l - 1);



////matrix <T> mat_metric(uint_num_states, uint_num_stages + 1,std::numeric_limits<T>::max());
////for (unsigned int uint_i = 0; uint_i < uint_num_states; uint_i++) mat_metric(uint_i, 0) = 0;
matrix <T> mat_metric_past(uint_num_states, 1);
matrix <T> mat_metric_next(uint_num_states, 1,std::numeric_limits<T>::max());

Expand All @@ -370,10 +367,12 @@ template <class T> matrix <T> channel <T>::decode_mlse(const matrix <T> &mat_arg
T dbl_next_output;
unsigned int uint_next_state;

for (unsigned int uint_stage = 0; uint_stage < uint_num_stages; uint_stage++) {
for (unsigned int uint_state = 0; uint_state < uint_num_states; uint_state++) {
for (unsigned int uint_pam_index = 0; uint_pam_index < uint_num_pam; uint_pam_index++) {

for (unsigned int uint_stage = 0; uint_stage < uint_num_stages; uint_stage++)
{
for (unsigned int uint_state = 0; uint_state < uint_num_states; uint_state++)
{
for (unsigned int uint_pam_index = 0; uint_pam_index < uint_num_pam; uint_pam_index++)
{
dbl_next_output = this->next_output(uint_state,uint_pam_index);
uint_next_state = this->next_state(uint_state,uint_pam_index);

Expand Down
39 changes: 7 additions & 32 deletions test/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,18 @@

int main(void)
{

// ignore the tail of the bits
const unsigned len = 15;

susa::matrix<double> mat_bits(17,1);

// the actual transmitted bits
mat_bits(0) = -1;
mat_bits(1) = -1;
mat_bits(2) = -1;
mat_bits(3) = -1;
mat_bits(4) = -1;
mat_bits(5) = 1;
mat_bits(6) = -1;
mat_bits(7) = 1;
mat_bits(8) = -1;
mat_bits(9) = 1;
mat_bits(10) = 1;
mat_bits(11) = -1;
mat_bits(12) = 1;
mat_bits(13) = -1;
mat_bits(14) = -1;
mat_bits(15) = 1;
mat_bits(16) = 1;
susa::matrix<double> mat_bits("-1 -1 -1 -1 1 1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1");
mat_bits.resize(18,1);

// pulse amplitude (pam) vector
susa::matrix<double> mat_pam(2, 1);
mat_pam(0) = -1;
mat_pam(1) = 1;
susa::matrix<double> mat_pam("-1 1");

// channel taps
susa::matrix<double> mat_taps(1, 4);
mat_taps(0) = 1;
mat_taps(1) = -0.9;
mat_taps(2) = 0.5;
mat_taps(3) = .4;
susa::matrix<double> mat_taps("1 -0.9 0.5 0.4");

susa::channel<double> ch(mat_taps, mat_pam);

Expand All @@ -74,12 +50,11 @@ int main(void)
{
mat_decoded_bits(uint_i) = mat_decoded(uint_i) > 1 ? 1 : -1;
}

//std::cout << "\ncoded : \n" << mat_coded;
//std::cout << "\nuncoded : \n" << mat_bits.left(len);
//std::cout << "\ndecoded : \n" << mat_decoded_bits.left(len);

susa::matrix <double> mat_decoded_mlse = ch.decode_mlse(mat_coded);

SUSA_TEST_EQ(mat_bits.left(len), mat_decoded_bits.left(len), "BCJR channel equalizer.");
SUSA_TEST_EQ(mat_bits.left(len), mat_decoded_mlse.left(len), "MLSE (Viterbi) channel equalizer.");
SUSA_TEST_PRINT_STATS();

return (uint_failed);
Expand Down

0 comments on commit 25d3761

Please sign in to comment.