IT++ Logo
itpp::BPSK Class Reference

BPSK modulator with real symbols. More...

#include <itpp/comm/modulator.h>

Inheritance diagram for itpp::BPSK:
itpp::Modulator< double >

Public Member Functions

 BPSK ()
 Constructor.
 
virtual ~BPSK ()
 Destructor.
 
void modulate_bits (const bvec &bits, vec &output) const
 Modulate bits into BPSK symbols in complex domain.
 
vec modulate_bits (const bvec &bits) const
 Modulate bits into BPSK symbols in complex domain.
 
void demodulate_bits (const vec &signal, bvec &output) const
 Demodulate noisy BPSK symbols in complex domain into bits.
 
bvec demodulate_bits (const vec &signal) const
 Demodulate noisy BPSK symbols in complex domain into bits.
 
virtual void demodulate_soft_bits (const vec &rx_symbols, double N0, vec &soft_bits, Soft_Method method=LOGMAP) const
 Soft demodulator for AWGN channel.
 
vec demodulate_soft_bits (const vec &rx_symbols, double N0, Soft_Method method=LOGMAP) const
 Soft demodulator for AWGN channel.
 
virtual void demodulate_soft_bits (const vec &rx_symbols, const vec &channel, double N0, vec &soft_bits, Soft_Method method=LOGMAP) const
 Soft demodulator for a known channel in AWGN.
 
vec demodulate_soft_bits (const vec &rx_symbols, const vec &channel, double N0, Soft_Method method=LOGMAP) const
 Soft demodulator for a known channel in AWGN.
 
virtual void set (const Vec< double > &symbols, const ivec &bits2symbols)
 Set the constellation to use in the modulator.
 
virtual int bits_per_symbol () const
 Returns number of bits per symbol.
 
virtual int get_k () const
 Returns number of bits per symbol.
 
virtual int get_M () const
 Returns number of modulation symbols.
 
virtual Vec< double > get_symbols () const
 Get the symbol values used in the modulator.
 
virtual ivec get_bits2symbols () const
 Get the bitmap, which maps input bits into symbols.
 
virtual void modulate (const ivec &symbolnumbers, Vec< double > &output) const
 Modulation of symbols.
 
virtual Vec< double > modulate (const ivec &symbolnumbers) const
 Modulation of symbols.
 
virtual void demodulate (const Vec< double > &signal, ivec &output) const
 Demodulation of symbols.
 
virtual ivec demodulate (const Vec< double > &signal) const
 Demodulation of symbols.
 
virtual void modulate_bits (const bvec &bits, Vec< double > &output) const
 Modulation of bits.
 
virtual void demodulate_bits (const Vec< double > &signal, bvec &bits) const
 Hard demodulation of bits.
 
virtual bvec demodulate_bits (const Vec< double > &signal) const
 Hard demodulation of bits.
 
virtual void demodulate_soft_bits (const Vec< double > &rx_symbols, double N0, vec &soft_bits, Soft_Method method=LOGMAP) const
 Soft demodulator for AWGN channels.
 
virtual vec demodulate_soft_bits (const Vec< double > &rx_symbols, double N0, Soft_Method method=LOGMAP) const
 Soft demodulator for AWGN channels.
 
virtual void demodulate_soft_bits (const Vec< double > &rx_symbols, const Vec< double > &channel, double N0, vec &soft_bits, Soft_Method method=LOGMAP) const
 Soft demodulator for fading channels.
 
virtual vec demodulate_soft_bits (const Vec< double > &rx_symbols, const Vec< double > &channel, double N0, Soft_Method method=LOGMAP) const
 Soft demodulator for fading channels.
 

Protected Member Functions

void calculate_softbit_matrices ()
 This function calculates the soft bit mapping matrices S0 and S1.
 

Protected Attributes

bool setup_done
 Setup indicator.
 
int k
 Number of bits per modulation symbol.
 
int M
 Number of modulation symbols.
 
bmat bitmap
 Bit to symbol mapping table (size: M x k)
 
ivec bits2symbols
 Bit to symbol mapping in decimal form (size: M)
 
Vec< double > symbols
 Corresponding modulation symbols (size: M)
 
imat S0
 Matrix where row k contains the constellation points with '0' in bit position k.
 
imat S1
 Matrix where row k contains the constellation points with '1' in bit position k.
 

Related Symbols

(Note that these are not member symbols.)

typedef Modulator< double > Modulator_1D
 Definition of 1D Modulator (with real symbols)
 
typedef Modulator< std::complex< double > > Modulator_2D
 Definition of 2D Modulator (with complex symbols)
 

Detailed Description

BPSK modulator with real symbols.

This is a special version of the PSK modulator with $M = 2$ constellation points. The following bit to symbol mapping is used:

  • $0 \rightarrow 1$
  • $1 \rightarrow -1$.

Beside hard demapping, this class can also perform soft demodulation, calculating the log-MAP estimate of the individual bits. To use it properly the received symbols should be equal to:

\[r_k = c_k s_k +
n_k,\]

where $c_k$ is the real or complex channel gain, $s_k$ is the transmitted constellation symbol, and $n_k$ is the AWGN of the channel (with variance $N_0$).

It is also assumed that the channel estimates are perfect when calculating the soft bits.

Note
This class uses real values for representing symbols. There is a similar class named BPSK_c, which uses complex values for symbols and therefore is compatible with other PSK and QAM based modulators.

Definition at line 876 of file modulator.h.

Constructor & Destructor Documentation

◆ BPSK()

itpp::BPSK::BPSK ( )
inline

Constructor.

Definition at line 880 of file modulator.h.

◆ ~BPSK()

virtual itpp::BPSK::~BPSK ( )
inlinevirtual

Destructor.

Definition at line 882 of file modulator.h.

Member Function Documentation

◆ modulate_bits() [1/3]

void itpp::BPSK::modulate_bits ( const bvec & bits,
vec & output ) const

Modulate bits into BPSK symbols in complex domain.

Definition at line 310 of file modulator.cpp.

Referenced by itpp::EXIT::generate_apriori_info(), and modulate_bits().

◆ modulate_bits() [2/3]

vec itpp::BPSK::modulate_bits ( const bvec & bits) const
virtual

Modulate bits into BPSK symbols in complex domain.

Reimplemented from itpp::Modulator< double >.

Definition at line 318 of file modulator.cpp.

References modulate_bits().

◆ demodulate_bits() [1/4]

void itpp::BPSK::demodulate_bits ( const vec & signal,
bvec & output ) const

Demodulate noisy BPSK symbols in complex domain into bits.

Definition at line 326 of file modulator.cpp.

Referenced by itpp::Dummy_Code::decode(), and demodulate_bits().

◆ demodulate_bits() [2/4]

bvec itpp::BPSK::demodulate_bits ( const vec & signal) const

Demodulate noisy BPSK symbols in complex domain into bits.

Definition at line 334 of file modulator.cpp.

References demodulate_bits().

◆ demodulate_soft_bits() [1/8]

void itpp::BPSK::demodulate_soft_bits ( const vec & rx_symbols,
double N0,
vec & soft_bits,
Soft_Method method = LOGMAP ) const
virtual

Soft demodulator for AWGN channel.

This function calculates the log-MAP estimate assuming equally likely bits transmitted:

\[\log \left( \frac{P(b=0|r)}{P(b=1|r)} \right) =
\frac{4 r}{N_0}\]

Parameters
rx_symbolsThe received noisy constellation symbols, $r$
N0The spectral density of the AWGN noise, $n$
soft_bitsThe soft bits calculated using the expression above
methodThe method used for demodulation (LOGMAP or APPROX)
Note
For soft demodulation it is suggested to use the N-dimensional modulator (Modulator_ND) instead, which is based on the QLLR (quantized) arithmetic and therefore is faster. Please note, however, that mixed use of Modulator_1D/Modulator_2D and Modulator_ND is not advised.

Definition at line 342 of file modulator.cpp.

Referenced by demodulate_soft_bits(), and demodulate_soft_bits().

◆ demodulate_soft_bits() [2/8]

vec itpp::BPSK::demodulate_soft_bits ( const vec & rx_symbols,
double N0,
Soft_Method method = LOGMAP ) const

Soft demodulator for AWGN channel.

Definition at line 353 of file modulator.cpp.

References demodulate_soft_bits().

◆ demodulate_soft_bits() [3/8]

void itpp::BPSK::demodulate_soft_bits ( const vec & rx_symbols,
const vec & channel,
double N0,
vec & soft_bits,
Soft_Method method = LOGMAP ) const
virtual

Soft demodulator for a known channel in AWGN.

This function calculates the log-MAP estimate assuming equally likely bits transmitted:

\[\log \left( \frac{P(b=0|r)}{P(b=1|r)} \right) =
\frac{4 \Re\{r c^{*}\}}{N_0}\]

Parameters
rx_symbolsThe received noisy constellation symbols, $r$ (complex but symbols in real part)
channelThe channel coefficients, $c$ (complex)
N0The spectral density of the AWGN noise, $n$
soft_bitsThe soft bits calculated using the expression above
methodThe method used for demodulation (LOGMAP or APPROX)
Note
For soft demodulation it is suggested to use the N-dimensional modulator (Modulator_ND) instead, which is based on the QLLR (quantized) arithmetic and therefore is faster. Please note, however, that mixed use of Modulator_1D/Modulator_2D and Modulator_ND is not advised.

Definition at line 362 of file modulator.cpp.

◆ demodulate_soft_bits() [4/8]

vec itpp::BPSK::demodulate_soft_bits ( const vec & rx_symbols,
const vec & channel,
double N0,
Soft_Method method = LOGMAP ) const

Soft demodulator for a known channel in AWGN.

Definition at line 374 of file modulator.cpp.

References demodulate_soft_bits().

◆ set()

void itpp::Modulator< double >::set ( const Vec< double > & symbols,
const ivec & bits2symbols )
virtualinherited

Set the constellation to use in the modulator.

Definition at line 86 of file modulator.h.

◆ bits_per_symbol()

virtual int itpp::Modulator< double >::bits_per_symbol ( ) const
inlinevirtualinherited

Returns number of bits per symbol.

Definition at line 89 of file modulator.h.

◆ get_k()

virtual int itpp::Modulator< double >::get_k ( ) const
inlinevirtualinherited

Returns number of bits per symbol.

Definition at line 92 of file modulator.h.

◆ get_M()

virtual int itpp::Modulator< double >::get_M ( ) const
inlinevirtualinherited

Returns number of modulation symbols.

Definition at line 95 of file modulator.h.

◆ get_symbols()

virtual Vec< double > itpp::Modulator< double >::get_symbols ( ) const
inlinevirtualinherited

Get the symbol values used in the modulator.

Definition at line 98 of file modulator.h.

◆ get_bits2symbols()

virtual ivec itpp::Modulator< double >::get_bits2symbols ( ) const
inlinevirtualinherited

Get the bitmap, which maps input bits into symbols.

The mapping is done as follows. An input bit sequence in decimal notation is used for indexing the bits2symbols table. The indexing result denotes the symbol to be used from the symbols table, e.g.:

PSK mod(8); // assume 8-PSK modulator
cvec sym = mod.get_symbols();
ivec bits2sym = mod.get_bits2symbols();
bvec in_bits = "100" // input bits
int d = bin2dec(in_bits); // decimal representation of in_bits = 4
// mapping of d into PSK symbol using bits2sym and sym tables
std::complex<double> out_symbol = sym(bits2sym(d));
M-ary PSK modulator.
Definition modulator.h:636
int mod(int k, int n)
Calculates the modulus, i.e. the signed reminder after division.
Definition elem_math.h:166
ITPP_EXPORT int bin2dec(const bvec &inbvec, bool msb_first=true)
Convert a bvec to decimal int with the first bit as MSB if msb_first == true.

Definition at line 117 of file modulator.h.

◆ modulate() [1/2]

void itpp::Modulator< double >::modulate ( const ivec & symbolnumbers,
Vec< double > & output ) const
virtualinherited

Modulation of symbols.

Definition at line 120 of file modulator.h.

◆ modulate() [2/2]

Vec< double > itpp::Modulator< double >::modulate ( const ivec & symbolnumbers) const
virtualinherited

Modulation of symbols.

Definition at line 122 of file modulator.h.

◆ demodulate() [1/2]

void itpp::Modulator< double >::demodulate ( const Vec< double > & signal,
ivec & output ) const
virtualinherited

Demodulation of symbols.

Definition at line 125 of file modulator.h.

◆ demodulate() [2/2]

ivec itpp::Modulator< double >::demodulate ( const Vec< double > & signal) const
virtualinherited

Demodulation of symbols.

Definition at line 127 of file modulator.h.

◆ modulate_bits() [3/3]

void itpp::Modulator< double >::modulate_bits ( const bvec & bits,
Vec< double > & output ) const
virtualinherited

Modulation of bits.

Definition at line 130 of file modulator.h.

◆ demodulate_bits() [3/4]

void itpp::Modulator< double >::demodulate_bits ( const Vec< double > & signal,
bvec & bits ) const
virtualinherited

Hard demodulation of bits.

Definition at line 135 of file modulator.h.

◆ demodulate_bits() [4/4]

bvec itpp::Modulator< double >::demodulate_bits ( const Vec< double > & signal) const
virtualinherited

Hard demodulation of bits.

Definition at line 137 of file modulator.h.

◆ demodulate_soft_bits() [5/8]

void itpp::Modulator< double >::demodulate_soft_bits ( const Vec< double > & rx_symbols,
double N0,
vec & soft_bits,
Soft_Method method = LOGMAP ) const
virtualinherited

Soft demodulator for AWGN channels.

This function calculates the log-likelihood ratio (LLR) of the received signal from AWGN channels. Depending on the soft demodulation method chosen, either full log-MAP calculation is performed (default method), according to the following equation:

\[\log \left(
\frac{P(b_i=0|r)}{P(b_i=1|r)} \right) = \log \left( \frac{\sum_{s_i
\in S_0} \exp \left( -\frac{|r_k - s_i|^2}{N_0} \right)} {\sum_{s_i
\in S_1} \exp \left( -\frac{|r_k - s_i|^2}{N_0} \right)} \right) \]

or approximate, but faster calculation is performed.

The approximate method finds for each bit the closest constellation points that have zero and one in the corresponding position. Let $d_0 = |r_k - s_0|$ denote the distance to the closest zero point and $d_1 = |r_k - s_1|$ denote the distance to the closest one point for the corresponding bit respectively. The approximate algorithm then computes

\[\frac{d_1^2 - d_0^2}{N_0}\]

This function can be used on channels where the channel gain $c_k = 1$.

When this function is to be used together with MAP-based turbo decoding algorithms then the channel reliability factor $L_c$ of the turbo decoder shall be set to 1. The output from this function can also be used by a Viterbi decoder using an AWGN based metric calculation function.

Parameters
rx_symbolsThe received noisy constellation symbols
N0The spectral density of the AWGN noise
soft_bitsThe soft bits calculated using the expression above
methodThe method used for demodulation (LOGMAP or APPROX)
Note
For soft demodulation it is suggested to use the N-dimensional modulator (Modulator_ND) instead, which is based on the QLLR (quantized) arithmetic and therefore is faster. Please note, however, that mixed use of Modulator_1D/Modulator_2D and Modulator_ND is not advised.

Definition at line 178 of file modulator.h.

◆ demodulate_soft_bits() [6/8]

vec itpp::Modulator< double >::demodulate_soft_bits ( const Vec< double > & rx_symbols,
double N0,
Soft_Method method = LOGMAP ) const
virtualinherited

Soft demodulator for AWGN channels.

Definition at line 182 of file modulator.h.

◆ demodulate_soft_bits() [7/8]

void itpp::Modulator< double >::demodulate_soft_bits ( const Vec< double > & rx_symbols,
const Vec< double > & channel,
double N0,
vec & soft_bits,
Soft_Method method = LOGMAP ) const
virtualinherited

Soft demodulator for fading channels.

This function calculates the log-likelihood ratio (LLR) of the received signal from fading channels. Depending on the soft demodulation method chosen, either full log-MAP calculation is performed (default method), according to the following equation:

\[\log \left( \frac{P(b_i=0|r)}{P(b_i=1|r)} \right) = \log \left(
\frac{\sum_{s_i \in S_0} \exp \left( -\frac{|r_k - c_k s_i|^2}{N_0}
\right)} {\sum_{s_i \in S_1} \exp \left( -\frac{|r_k - c_k
s_i|^2}{N_0} \right)} \right) \]

or approximate, but faster calculation is performed.

The approximate method finds for each bit the closest constellation points that have zero and one in the corresponding position. Let $d_0 = |r_k - c_k s_0|$ denote the distance to the closest zero point and $d_1 = |r_k - c_k s_1|$ denote the distance to the closest one point for the corresponding bit respectively. The approximate algorithm then computes

\[\frac{d_1^2 - d_0^2}{N_0}\]

When this function is to be used together with MAP-based turbo decoding algorithms then the channel reliability factor $L_c$ of the turbo decoder shall be set to 1. The output from this function can also be used by a Viterbi decoder using an AWGN based metric calculation function.

Parameters
rx_symbolsThe received noisy constellation symbols $r_k$
channelThe channel values $c_k$
N0The spectral density of the AWGN noise
soft_bitsThe soft bits calculated using the expression above
methodThe method used for demodulation (LOGMAP or APPROX)
Note
For soft demodulation it is suggested to use the N-dimensional modulator (Modulator_ND) instead, which is based on the QLLR (quantized) arithmetic and therefore is faster. Please note, however, that mixed use of Modulator_1D/Modulator_2D and Modulator_ND is not advised.

Definition at line 223 of file modulator.h.

◆ demodulate_soft_bits() [8/8]

vec itpp::Modulator< double >::demodulate_soft_bits ( const Vec< double > & rx_symbols,
const Vec< double > & channel,
double N0,
Soft_Method method = LOGMAP ) const
virtualinherited

Soft demodulator for fading channels.

Definition at line 228 of file modulator.h.

◆ calculate_softbit_matrices()

void itpp::Modulator< double >::calculate_softbit_matrices ( )
protectedinherited

This function calculates the soft bit mapping matrices S0 and S1.

Definition at line 254 of file modulator.h.

Referenced by itpp::PAM::set_M().

Friends And Related Symbol Documentation

◆ Modulator_1D

typedef Modulator<double> Modulator_1D
related

Definition of 1D Modulator (with real symbols)

Definition at line 266 of file modulator.h.

◆ Modulator_2D

typedef Modulator<std::complex<double> > Modulator_2D
related

Definition of 2D Modulator (with complex symbols)

Definition at line 272 of file modulator.h.

Member Data Documentation

◆ setup_done

bool itpp::Modulator< double >::setup_done
protectedinherited

Setup indicator.

Definition at line 235 of file modulator.h.

Referenced by itpp::PAM::demodulate_bits(), and itpp::PAM::set_M().

◆ k

int itpp::Modulator< double >::k
protectedinherited

Number of bits per modulation symbol.

Definition at line 237 of file modulator.h.

Referenced by itpp::PAM::demodulate_bits(), and itpp::PAM::set_M().

◆ M

int itpp::Modulator< double >::M
protectedinherited

Number of modulation symbols.

Definition at line 239 of file modulator.h.

Referenced by itpp::PAM::demodulate_bits(), and itpp::PAM::set_M().

◆ bitmap

bmat itpp::Modulator< double >::bitmap
protectedinherited

Bit to symbol mapping table (size: M x k)

Definition at line 241 of file modulator.h.

Referenced by itpp::PAM::demodulate_bits(), and itpp::PAM::set_M().

◆ bits2symbols

ivec itpp::Modulator< double >::bits2symbols
protectedinherited

Bit to symbol mapping in decimal form (size: M)

Definition at line 243 of file modulator.h.

Referenced by itpp::PAM::set_M().

◆ symbols

Vec<double> itpp::Modulator< double >::symbols
protectedinherited

Corresponding modulation symbols (size: M)

Definition at line 245 of file modulator.h.

Referenced by itpp::PAM::set_M().

◆ S0

imat itpp::Modulator< double >::S0
protectedinherited

Matrix where row k contains the constellation points with '0' in bit position k.

Definition at line 248 of file modulator.h.

◆ S1

imat itpp::Modulator< double >::S1
protectedinherited

Matrix where row k contains the constellation points with '1' in bit position k.

Definition at line 251 of file modulator.h.


The documentation for this class was generated from the following files:
SourceForge Logo

Generated on Mon Apr 7 2025 07:53:18 for IT++ by Doxygen 1.11.0