93 lines
3.2 KiB
Matlab
93 lines
3.2 KiB
Matlab
function [eq_package] = vnle(eq_,M,rx_signal,tx_symbols,tx_bits,options)
|
|
%VNLE Apply an equalization algorithm to the received signal and calculate BER
|
|
% This function takes an equalizer object, a received signal, and the
|
|
% transmitted symbols to apply equalization, map the received signal back to bits,
|
|
% and compute the bit error rate (BER).
|
|
%
|
|
% Inputs:
|
|
% EQ - Equalizer object that provides the equalization method
|
|
% rx_signal - Received signal that needs to be equalized
|
|
% tx_symbols - Transmitted symbols used as a reference for BER calculation
|
|
%
|
|
% Outputs:
|
|
% eq_signal - Equalized version of the received signal
|
|
% ber - Bit error rate after equalization
|
|
% numErrors - Number of bit errors detected
|
|
|
|
arguments
|
|
eq_
|
|
M
|
|
rx_signal
|
|
tx_symbols
|
|
tx_bits
|
|
options.precode_mode db_mode
|
|
options.showAnalysis = 0
|
|
end
|
|
|
|
%FFE or VNLE
|
|
if length(rx_signal)/2 == length(tx_symbols)+0.5
|
|
rx_signal.signal = rx_signal.signal(1:end-1);
|
|
elseif length(rx_signal)/2 == length(tx_symbols)-1
|
|
end
|
|
[eq_signal_sd,eq_noise] = eq_.process(rx_signal,tx_symbols);
|
|
|
|
eq_signal_hd = PAMmapper(M,0).quantize(eq_signal_sd);
|
|
|
|
% precoding to mitigate error propagation, most prominently used in
|
|
% combination with duobinary signaling to avoid catastrophic error
|
|
% behavior (see J.W.M. Bergmans, Digital Baseband Transmission and Recording -> partial response signaling)
|
|
|
|
% takes:
|
|
% -> eq_signal_hd: hard decision signal after eq
|
|
% -> tx_symbols: that where used as reference for eq
|
|
|
|
switch options.precode_mode
|
|
case db_mode.db_emulate
|
|
% re
|
|
eq_signal_hd = Duobinary().encode(eq_signal_hd,"M",M);
|
|
eq_signal_hd = Duobinary().decode(eq_signal_hd,"M",M);
|
|
|
|
tx_symbols_precoded = Duobinary().encode(tx_symbols);
|
|
tx_symbols_precoded = Duobinary().decode(tx_symbols_precoded);
|
|
|
|
tx_bits = PAMmapper(M,0).demap(tx_symbols_precoded);
|
|
|
|
case db_mode.db_discard
|
|
|
|
% normal dsp for precoded sequence == discard/omit/ignore precode
|
|
tx_bits = PAMmapper(M,0).demap(tx_symbols);
|
|
|
|
case db_mode.db_encoded
|
|
|
|
% normal DB encoded data (only for 10KM)
|
|
|
|
case db_mode.db_precoded
|
|
|
|
eq_signal_hd = Duobinary().encode(eq_signal_hd,"M",M);
|
|
eq_signal_hd = Duobinary().decode(eq_signal_hd,"M",M);
|
|
|
|
end
|
|
|
|
rx_bits = PAMmapper(M,0).demap(eq_signal_hd);
|
|
|
|
[~,numErrors,ber,~] = calc_ber(rx_bits.signal,tx_bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
|
|
[evm_total,evm_lvl] = calc_evm(eq_signal_sd,tx_symbols);
|
|
[inf_rate] = calc_air(eq_signal_sd,tx_symbols,"skip_front",10000,"skip_end",10000);
|
|
|
|
eq_package.ber_vnle = ber;
|
|
eq_package.evm_total = evm_total;
|
|
eq_package.evm_lvl = evm_lvl;
|
|
eq_package.inf_rate_vnle = inf_rate;
|
|
|
|
eq_package.snr = snr(eq_signal_sd.signal,eq_noise.signal);
|
|
|
|
if options.showAnalysis
|
|
|
|
snr(eq_signal_sd.signal,eq_noise.signal);
|
|
fprintf(['VNLE EVM lvl: ',repmat('%.3f ',1,numel(evm_lvl)),' \n'],evm_lvl);
|
|
|
|
fprintf('VNLE BER: %.2e \n',ber);
|
|
|
|
end
|
|
|
|
end |