129 lines
4.2 KiB
Matlab
129 lines
4.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
|
|
options.eth_style = 0;
|
|
options.postFFE = [];
|
|
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);
|
|
|
|
if ~isempty(options.postFFE)
|
|
[eq_signal_sd,eq_noise] = options.postFFE.process(eq_signal_sd,tx_symbols);
|
|
end
|
|
|
|
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,"eth_style",options.eth_style).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,"eth_style",options.eth_style).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);
|
|
|
|
eq_package.signal = eq_signal_sd;
|
|
|
|
|
|
if options.showAnalysis
|
|
|
|
fprintf('SNR: %d dB \n',snr(eq_signal_sd.signal,eq_noise.signal));
|
|
|
|
if M == 6
|
|
logm = 2.5;
|
|
else
|
|
logm = log2(M);
|
|
end
|
|
|
|
fprintf('NGMI: %.4f \n', inf_rate/logm);
|
|
|
|
fprintf(['VNLE EVM lvl: ',repmat('%.3f ',1,numel(evm_lvl)),' \n'],evm_lvl);
|
|
|
|
fprintf('VNLE BER: %.2e \n',ber);
|
|
|
|
disp("%%%%%%%%%%%%%%%%%%%%%")
|
|
|
|
% showEQcoefficients('n1',eq_.e,'n2',eq_.e2,'n3',eq_.e3,"displayname",'Coefficients');
|
|
%
|
|
% if ~isempty(options.postFFE)
|
|
% showEQcoefficients('n1',options.postFFE.e,"displayname",'Coefficients');
|
|
% end
|
|
%
|
|
% showEQNoisePSD(eq_noise);
|
|
%
|
|
% showEQfilter(eq_.e,eq_signal_sd.fs.*2)
|
|
|
|
% noiselessness(tx_symbols,eq_noise,"displayname",'SNR after VNLE','fignum',301);
|
|
|
|
% showLevelHistogram(eq_signal_sd,tx_symbols,"fignum",302);
|
|
|
|
|
|
|
|
end
|
|
|
|
end |