247 lines
8.1 KiB
Matlab
247 lines
8.1 KiB
Matlab
|
|
%clear;
|
|
col = linspecer(6);
|
|
|
|
% GENERATE SIR CURVE
|
|
if ismac
|
|
foldername = '/Users/silasoettinghaus/Documents/MATLAB/Labor_Datensatz_PAM4_MPI/pam4_10km_1km';
|
|
else
|
|
foldername = 'C:\Users\Silas\Documents\MATLAB\Datensätze\Labor_Datensatz_PAM4_MPI_OFC2023\pam4_10km_1km';
|
|
end
|
|
|
|
allfiles = dir(foldername);
|
|
|
|
eq_updatelatency = 2;
|
|
eq_avg_blocklength =0;
|
|
eq_parallelization_blocklength = 92;
|
|
mudc = 0.01;
|
|
|
|
|
|
eq_ofc = EQ_silas_ofc("Ne",[25,0,0],"Nb",[2,0,0],"trainlength",4096,...
|
|
"sps",2,...
|
|
"mu_dc_dd",mudc,...
|
|
"mu_dc_train",mudc,...
|
|
"mu_ffe_train",0,...
|
|
"mu_dfe_train",0.005,...
|
|
"mu_ffe_dd",[0.0004 0.0004 0.0004],...
|
|
"mu_dfe_dd",0.005,...
|
|
"ddloops",3,...
|
|
"trainloops",4,...
|
|
"eq_parallelization_blocklength",eq_parallelization_blocklength, ...
|
|
"eq_updatelatency",eq_updatelatency,...
|
|
"eq_avg_blocklength",eq_avg_blocklength);
|
|
|
|
eq_normal = EQ_silas_ofc("Ne",[25,0,0],"Nb",[2,0,0],"trainlength",4096,...
|
|
"sps",2,...
|
|
"mu_dc_dd",0,...
|
|
"mu_dc_train",0,...
|
|
"mu_ffe_train",0,...
|
|
"mu_dfe_train",0.005,...
|
|
"mu_ffe_dd",[0.0004 0.0004 0.0004],...
|
|
"mu_dfe_dd",0.005,...
|
|
"ddloops",3,...
|
|
"trainloops",4,...
|
|
"eq_parallelization_blocklength",eq_parallelization_blocklength, ...
|
|
"eq_updatelatency",eq_updatelatency,...
|
|
"eq_avg_blocklength",eq_avg_blocklength);
|
|
|
|
mudc = 0.01;
|
|
eq_ff = EQ_silas("Ne",[25,0,0],"Nb",[2,0,0],"trainlength",4096,...
|
|
"sps",2,...
|
|
"mu_dc_dd",mudc,...
|
|
"mu_dc_train",mudc,...
|
|
"mu_ffe_train",0,...
|
|
"mu_dfe_train",0.005,...
|
|
"mu_ffe_dd",[0.0004 0.0004 0.0004],...
|
|
"mu_dfe_dd",0.005,...
|
|
"ddloops",3,...
|
|
"trainloops",4,...
|
|
"eq_parallelization_blocklength",eq_parallelization_blocklength, ...
|
|
"eq_updatelatency",eq_updatelatency,...
|
|
"eq_avg_blocklength",0);
|
|
|
|
% [ber_nml,sir_nml,fsym_nml] = sweepSIR(allfiles,eq_normal);
|
|
% [ber_ofc,sir_ofc,fsym_ofc] = sweepSIR(allfiles,eq_ofc);
|
|
% [ber_ff,sir_ff,fsym_ff] = sweepSIR(allfiles,eq_ff);
|
|
|
|
% plotBerCurve(ber_nml,sir_nml,fsym_nml);
|
|
% plotBerCurve(ber_ofc,sir_ofc,fsym_ofc);
|
|
% plotBerCurve(ber_ff,sir_ff,fsym_ff);
|
|
|
|
measurementpath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\Labor_Datensatz_PAM4_MPI_OFC2023\pam4_10km_1km\pam4__loop_10_92Gbd_19092023_1508.mat';
|
|
% measurementpath = findSirAndFsym(allfiles,-30,92e9);
|
|
measurementpath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\Labor_Datensatz_PAM4_MPI_OFC2023\pam4_10km_1km\pam4__loop_30_92Gbd_19092023_1547.mat';
|
|
|
|
% comparePSD(measurementpath)
|
|
|
|
% [totalbits,errors,ber_,loc,sir,fsym] = singleBerRun(measurementpath, eq_normal);
|
|
% [totalbits,errors,ber_,loc,sir,fsym] = singleBerRun(measurementpath, eq_ofc);
|
|
|
|
|
|
[~,~,ber_,~,sir,fsym] = singleBerRun(measurementpath, eq_ff);
|
|
|
|
|
|
mudc_loop = [0, 0.0001,0.0005, 0.001,0.005, 0.01:0.01:0.1, 0.2:0.1:1];
|
|
|
|
blocklength = [20:20:200];
|
|
|
|
parfor m = 1:length(mudc_loop)
|
|
eq_ff = EQ_silas("Ne",[25,0,0],"Nb",[2,0,0],"trainlength",4096,...
|
|
"sps",2,...
|
|
"mu_dc_dd",mudc_loop(m),...
|
|
"mu_dc_train",mudc_loop(m),...
|
|
"mu_ffe_train",0,...
|
|
"mu_dfe_train",0.005,...
|
|
"mu_ffe_dd",[0.0004 0.0004 0.0004],...
|
|
"mu_dfe_dd",0.005,...
|
|
"ddloops",3,...
|
|
"trainloops",4,...
|
|
"eq_parallelization_blocklength",eq_parallelization_blocklength, ...
|
|
"eq_updatelatency",eq_updatelatency,...
|
|
"eq_avg_blocklength",100);%blocklength(m));
|
|
|
|
[~,~,ber_(m),~,sir(m),fsym(m)] = singleBerRun(measurementpath, eq_ff);
|
|
end
|
|
|
|
figure(2)
|
|
hold on
|
|
plot(mudc_loop,ber_,'Marker','o')
|
|
ylim([1e-4, 1e-2])
|
|
yline(3.8e-3);
|
|
set(gca, 'YScale', 'log');
|
|
set(gca, 'XScale', 'log');
|
|
|
|
|
|
|
|
function cur_path = findSirAndFsym(allfiles,sir_desired,fsym_desired)
|
|
for i = 1:length(allfiles)
|
|
|
|
if allfiles(i).bytes ~= 0
|
|
cur_path = [allfiles(i).folder,filesep, allfiles(i).name];
|
|
recorded_data = load(cur_path);
|
|
delete(findobj('Type','figure','Name','prms_compare'));
|
|
else
|
|
continue
|
|
end
|
|
|
|
sir = recorded_data.saveStructTemp.awg2scope_keysight_state.eigenlight_mpi - 3.3 + 7.2;
|
|
fsym = recorded_data.saveStructTemp.common.f_sym;
|
|
|
|
if abs(sir-sir_desired)<1 && abs(fsym-fsym_desired)<1e9
|
|
return
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
function comparePSD(filepath)
|
|
recorded_data = load(filepath);
|
|
delete(findobj('Type','figure','Name','prms_compare'));
|
|
sir = recorded_data.saveStructTemp.awg2scope_keysight_state.eigenlight_mpi - 3.3 + 7.2;
|
|
fsym = recorded_data.saveStructTemp.common.f_sym;
|
|
|
|
spectrum_plot(recorded_data.saveStructTemp.dp_tsynch_out',2*fsym);
|
|
|
|
x = recorded_data.saveStructTemp.dp_tsynch_out';
|
|
|
|
pwelch(x,hamming(length(x)),[],length(x),2*fsym,"centered","power");
|
|
|
|
periodogram(x,hamming(length(x)),length(x),"centered","psd");
|
|
|
|
end
|
|
|
|
function [totalbits,errors,ber_,loc,sir,fsym] = singleBerRun(filepath, eq_object)
|
|
|
|
recorded_data = load(filepath);
|
|
delete(findobj('Type','figure','Name','prms_compare'));
|
|
sir = recorded_data.saveStructTemp.awg2scope_keysight_state.eigenlight_mpi - 3.3 + 7.2;
|
|
fsym = recorded_data.saveStructTemp.common.f_sym;
|
|
|
|
% 0) build RX Signal
|
|
y_rx = Electricalsignal(recorded_data.saveStructTemp.dp_tsynch_out');
|
|
y_rx.fs = 2.*fsym;
|
|
|
|
% 0) build tx reference Signal for eq training
|
|
y_digimod = Informationsignal(recorded_data.saveStructTemp.digi_mod_out');
|
|
y_digimod.fs = fsym;
|
|
|
|
bits_ref = recorded_data.saveStructTemp.prms_out;
|
|
|
|
[totalbits,errors,ber_,loc] = runPostProc(eq_object,y_rx,y_digimod,bits_ref);
|
|
|
|
disp([class(eq_object),': fsym: ',num2str(fsym*1e-9),'GBd, SIR: ',num2str(sir),' ->> BER: ',sprintf('%2E',ber_)]);
|
|
|
|
end
|
|
|
|
function plotBerCurve(ber_,sir,fsym)
|
|
|
|
rate = [92e9, 56e9];
|
|
figure(95)
|
|
|
|
for r = 1:length(rate)
|
|
|
|
sorted = sortrows([sir(fsym == rate(r)); ber_(fsym == rate(r))]',1)';
|
|
hold on
|
|
plot(abs(sorted(1,:)),sorted(2,:),'DisplayName',[num2str(rate(r).*1e-9),' GBd; PAM4;'],'LineWidth',1,'Marker','o','MarkerSize',5,'LineStyle','-','HandleVisibility','on');
|
|
|
|
|
|
end
|
|
set(gca, 'YScale', 'log');
|
|
yline(3.8e-3,'LineWidth',1, 'LineStyle','--','HandleVisibility','off');
|
|
xlim([15,35]);
|
|
xlabel('SIR in dB');
|
|
ylabel('BER');
|
|
end
|
|
|
|
function [ber_,sir,fsym] = sweepSIR(allfiles,eq_object)
|
|
|
|
parfor i = 1:length(allfiles)
|
|
|
|
if allfiles(i).bytes ~= 0
|
|
recorded_data = load([allfiles(i).folder,filesep, allfiles(i).name]);
|
|
delete(findobj('Type','figure','Name','prms_compare'));
|
|
else
|
|
continue
|
|
end
|
|
|
|
sir(i) = recorded_data.saveStructTemp.awg2scope_keysight_state.eigenlight_mpi - 3.3 + 7.2;
|
|
fsym(i) = recorded_data.saveStructTemp.common.f_sym;
|
|
|
|
fdac(i) = recorded_data.saveStructTemp.common.f_DAC;
|
|
fadc(i) = recorded_data.saveStructTemp.common.f_ADC;
|
|
|
|
% 0) build RX Signal
|
|
y_rx = Electricalsignal(recorded_data.saveStructTemp.dp_tsynch_out');
|
|
y_rx.fs = 2.*fsym(i);
|
|
|
|
% 0) build tx reference Signal for eq training
|
|
y_digimod = Informationsignal(recorded_data.saveStructTemp.digi_mod_out');
|
|
y_digimod.fs = fsym(i);
|
|
|
|
bits_ref = recorded_data.saveStructTemp.prms_out;
|
|
|
|
[totalbits,errors,ber_(i),loc] = runPostProc(eq_object,y_rx,y_digimod,bits_ref);
|
|
|
|
disp(['fsym: ',num2str(fsym(i)*1e-9),'GBd, SIR: ',num2str(sir(i)),' ->> BER: ',sprintf('%2E',ber_(i))]);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function [totalbits,errors,ber_,loc] = runPostProc(eq_object,y_rx,y_ref,bits_ref)
|
|
|
|
% 1) normlaize
|
|
y_rx = y_rx.normalize("mode","rms");
|
|
|
|
[Eq_out] = eq_object.process(y_rx,y_ref);
|
|
|
|
% 3) digital demodulation object
|
|
digimod = PAMmapper(4,0);
|
|
|
|
%estimated/ equalized symbol sequence
|
|
d_estimated = digimod.demap(Eq_out);
|
|
|
|
% 4) BER calculation
|
|
[totalbits,errors,ber_,loc] = calc_ber(d_estimated.signal(1:end,:),bits_ref(1:end,:)',"skip_front",100,"skip_end",150,"returnErrorLocation",1);
|
|
|
|
end |