#170 Demodulation problem with the class Modulator

release_4.0.x
closed
5
2014-04-08
2008-03-06
Yann Cocheril
No

When you use QAM or PSK classes, there is no problem. On the contrary, if you use the class "Modulator", there is a bug with the demodulation function named "demodulate_bits". This bug appears with the following modulations : 64-QAM or higher and with 8-PSK or higher. The following code highlights this bug comparing QAM and PSK results with those obtained from the class "Modulator_2D". The procedure is to modulate and demodulate a bit vector named "tx" with the QAM or PSK classes, and to initialize the class "Modulator_2D" with the symbols and bits2symbols obtained from them. Then we modulate and demodulate the same bit vector "tx" and show a BER different from 0.

int main (int argc, char *argv[])
{
ivec k = "2 4 6 8 10 12" ;
for (int i = 0; i < k.size (); i++) {
RNG_randomize () ;
int M = pow2i (k[i]) ;
QAM mod ;
mod.set_M (M) ;

cvec si = mod.get_symbols () ;
ivec bi = mod.get_bits2symbols () ;

Modulator_2D MOD2 (si, bi) ;

bvec tx = randb (1000*k[i]) ;
cvec sx = mod.modulate_bits (tx) ;
bvec rx = mod.demodulate_bits (sx) ;

cvec SX2 = MOD2.modulate_bits (tx) ;
bvec RX2 = MOD2.demodulate_bits (SX2) ;

BERC berc, BERC2 ;
berc.count (tx, rx) ;
BERC2.count (tx, RX2) ;
cout << M << "-QAM ::" << endl
 << " - BER1 = " << berc.get_errorrate () << endl
 << " - BER2 = " << BERC2.get_errorrate () << endl << endl ;

}

k = "1 2 3" ;
for (int i = 0; i < k.size (); i++) {
RNG_randomize () ;
int M = pow2i (k[i]) ;
PSK mod ;
mod.set_M (M) ;

cvec si = mod.get_symbols () ;
ivec bi = mod.get_bits2symbols () ;

Modulator_2D MOD2 (si, bi) ;

bvec tx = randb (1000*k[i]) ;
cvec sx = mod.modulate_bits (tx) ;
bvec rx = mod.demodulate_bits (sx) ;

cvec SX2 = MOD2.modulate_bits (tx) ;
bvec RX2 = MOD2.demodulate_bits (SX2) ;

BERC berc, BERC2 ;
berc.count (tx, rx) ;
BERC2.count (tx, RX2) ;
cout << M << "-PSK ::" << endl
 << " - BER1 = " << berc.get_errorrate () << endl
 << " - BER2 = " << BERC2.get_errorrate () << endl << endl ;

}

The result is :

./cocheril@ubuntu:~/Desktop/devel$ ./test
4-QAM ::
- BER1 = 0
- BER2 = 0

16-QAM ::
- BER1 = 0
- BER2 = 0

64-QAM ::
- BER1 = 0
- BER2 = 0.1605

256-QAM ::
- BER1 = 0
- BER2 = 0.24525

1024-QAM ::
- BER1 = 0
- BER2 = 0.3026

4096-QAM ::
- BER1 = 0
- BER2 = 0.3365

2-PSK ::
- BER1 = 0
- BER2 = 0

4-PSK ::
- BER1 = 0
- BER2 = 0

8-PSK ::
- BER1 = 0
- BER2 = 0.165333

Discussion

  • Logged In: YES
    user_id=1004597
    Originator: NO

    Hi Yann,

    Thanks for reporting this issue and especially for providing the testing code, even though you have ignored our policy to report problems first on the Help forum.
    The following fix should solve this bug:

    diff --git a/itpp/comm/modulator.h b/itpp/comm/modulator.h
    index 6e8d300..99186ad 100644
    --- a/itpp/comm/modulator.h
    +++ b/itpp/comm/modulator.h
    @@ -291,7 +291,7 @@ namespace itpp {
    k = levels2bits(M);
    bitmap.set_size(M, k);
    for (int m = 0; m < M; m++) {
    - bitmap.set_row(m, dec2bin(k, bits2symbols(m)));
    + bitmap.set_row(bits2symbols(m), dec2bin(k, m));
    }
    calculate_softbit_matrices(bits2symbols);
    setup_done = true;

    I will commit this change to our SVN repository and update the test program to catch such errors in future.

    Thanks!
    /Adam