RENEWLab  1.1.0
RENEW project
berr_perfect.m File Reference

Functions

1/sqrt(2 modvec_bpsk ()
 
mod_fcn_16qam, tx_data arrayfun ()
 
otherwise fprintf ('Invalid MOD_ORDER(%d)! Must be in[2, 4, 16, 64]\n', MOD_ORDER)
 
 CN (0, nvar)
 
 switch (MOD_ORDER) case 2 % BPSK rx_data
 

Variables

function berr_th
 
 tx_data = randi(MOD_ORDER, N_DATA_SYMS, 1) - 1
 
 modvec_16qam = (1/sqrt(10)) .* [-3 -1 +3 +1]
 
 modvec_64qam = (1/sqrt(42)) .* [-7 -5 -1 -3 +7 +5 +1 +3]
 
 mod_fcn_bpsk = @(x) complex(modvec_bpsk(1+x),0)
 
 mod_fcn_qpsk = @(x) complex(modvec_bpsk(1+bitshift(x, -1)), modvec_bpsk(1+mod(x, 2)))
 
 mod_fcn_16qam = @(x) complex(modvec_16qam(1+bitshift(x, -2)), modvec_16qam(1+mod(x,4)))
 
 mod_fcn_64qam = @(x) complex(modvec_64qam(1+bitshift(x, -3)), modvec_64qam(1+mod(x,8)))
 
Map the data values on to complex symbols switch MOD_ORDER case BPSK tx_syms = arrayfun(mod_fcn_bpsk, tx_data)
 
 return
 
end Create channel if awgn
 
 h = sqrt(hvar/2).*(randn(N_DATA_SYMS, N_ANT) + 1i*randn(N_DATA_SYMS, N_ANT))
 
end Add noise nvar = 1/ 10^(0.1*snr)
 
 w = sqrt(nvar/2).*(randn(N_DATA_SYMS,1) + 1i*randn(N_DATA_SYMS,1))
 
 rx_syms = h.*tx_syms + w
 
Equalize with *known * channel
 
Demodulate demod_fcn_bpsk = @(x) double(real(x)>0)
 
 demod_fcn_qpsk = @(x) double(2*(real(x)>0) + 1*(imag(x)>0))
 
 demod_fcn_16qam = @(x) (8*(real(x)>0)) + (4*(abs(real(x))<0.6325)) + (2*(imag(x)>0)) + (1*(abs(imag(x))<0.6325))
 
 demod_fcn_64qam
 
case QPSK rx_data = arrayfun(demod_fcn_qpsk, syms_eq)
 
end Error rates nbits = N_DATA_SYMS * log2(MOD_ORDER)
 
 bit_errs = length(find(dec2bin(bitxor(tx_data, rx_data),8) == '1'))
 

Function Documentation

◆ arrayfun()

demod_fcn_64qam syms_eq arrayfun ( )
virtual

◆ CN()

CN ( ,
nvar   
)

◆ fprintf()

otherwise fprintf ( 'Invalid MOD_ORDER(%d)! Must be in\n'  [2, 4, 16, 64],
MOD_ORDER   
)
Here is the caller graph for this function:

◆ modvec_bpsk()

1/sqrt(2 modvec_bpsk ( )
virtual

◆ switch()

switch ( MOD_ORDER  )

Variable Documentation

◆ awgn

end Create channel if awgn
Initial value:
== 0
hvar = 1

◆ berr_th

berr_th
Initial value:
= berr_perfect(snr, N_ANT,MOD_ORDER, awgn)
% Theoretical BER with no chan. est error.
N_DATA_SYMS = 1e5

◆ bit_errs

bit_errs = length(find(dec2bin(bitxor(tx_data, rx_data),8) == '1'))

◆ channel

Equalize with* known* channel

◆ demod_fcn_16qam

demod_fcn_16qam = @(x) (8*(real(x)>0)) + (4*(abs(real(x))<0.6325)) + (2*(imag(x)>0)) + (1*(abs(imag(x))<0.6325))

◆ demod_fcn_64qam

demod_fcn_64qam
Initial value:
= @(x) (32*(real(x)>0)) + (16*(abs(real(x))<0.6172)) + ...
(8*((abs(real(x))<(0.9258))&&((abs(real(x))>(0.3086))))) + ...
(4*(imag(x)>0)) + (2*(abs(imag(x))<0.6172)) + ...
(1*((abs(imag(x))<(0.9258))&&((abs(imag(x))>(0.3086)))))

◆ demod_fcn_bpsk

Demodulate demod_fcn_bpsk = @(x) double(real(x)>0)

◆ demod_fcn_qpsk

demod_fcn_qpsk = @(x) double(2*(real(x)>0) + 1*(imag(x)>0))

◆ h

else h = sqrt(hvar/2).*(randn(N_DATA_SYMS, N_ANT) + 1i*randn(N_DATA_SYMS, N_ANT))

◆ mod_fcn_16qam

mod_fcn_16qam = @(x) complex(modvec_16qam(1+bitshift(x, -2)), modvec_16qam(1+mod(x,4)))

◆ mod_fcn_64qam

mod_fcn_64qam = @(x) complex(modvec_64qam(1+bitshift(x, -3)), modvec_64qam(1+mod(x,8)))

◆ mod_fcn_bpsk

mod_fcn_bpsk = @(x) complex(modvec_bpsk(1+x),0)

◆ mod_fcn_qpsk

mod_fcn_qpsk = @(x) complex(modvec_bpsk(1+bitshift(x, -1)), modvec_bpsk(1+mod(x, 2)))

◆ modvec_16qam

modvec_16qam = (1/sqrt(10)) .* [-3 -1 +3 +1]

◆ modvec_64qam

modvec_64qam = (1/sqrt(42)) .* [-7 -5 -1 -3 +7 +5 +1 +3]

◆ nbits

end Error rates nbits = N_DATA_SYMS * log2(MOD_ORDER)

◆ nvar

end Add noise nvar = 1/ 10^(0.1*snr)

◆ return

return

◆ rx_data

case QPSK rx_data = arrayfun(demod_fcn_qpsk, syms_eq)

◆ rx_syms

rx_syms = h.*tx_syms + w

◆ tx_data

tx_data = randi(MOD_ORDER, N_DATA_SYMS, 1) - 1

◆ tx_syms

case QPSK tx_syms = arrayfun(mod_fcn_bpsk, tx_data)

◆ w

w = sqrt(nvar/2).*(randn(N_DATA_SYMS,1) + 1i*randn(N_DATA_SYMS,1))
real
data real()
snr
number of bits snr
Definition: mod_demod.m:16
hvar
hvar
Definition: getRxVec.m:28
MOD_ORDER
if MOD_ORDER
Definition: bits2syms.m:62
awgn
end Create channel if awgn
Definition: berr_perfect.m:34
x
sample frequency in MHz x
Definition: getRxVec.m:86
error
otherwise error('Invalid MOD_ORDER(%d)! Must be in[2, 4, 16, 64]\n', MOD_ORDER)