Update April
This commit is contained in:
70
projects/IMDD_base_system/filter_debug.m
Normal file
70
projects/IMDD_base_system/filter_debug.m
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
clear
|
||||
%% Set Simulation Variables
|
||||
|
||||
O = 18; %order of prbs
|
||||
N = 2^(O-1); %length of prbs
|
||||
[~,seed] = prbs(O,1); %initialize first seed of prbs
|
||||
|
||||
% Modulation
|
||||
M = 4; %PAM-M
|
||||
bitpattern = zeros(N,log2(M));
|
||||
|
||||
% Symbol Rate
|
||||
fsym = 112e9;
|
||||
|
||||
% DAC Rate
|
||||
fdac = 120e9;
|
||||
|
||||
% Simulation oversampling rate "k";
|
||||
kover = 16;
|
||||
|
||||
% ADC Rate
|
||||
fadc = 256e9;
|
||||
|
||||
% Simulation frequency in "analog domain"
|
||||
fsimu = kover * fdac ;
|
||||
|
||||
|
||||
|
||||
%% CONSTRUCT ALL CLASSES
|
||||
|
||||
digimod = PAMmapper(M,0);
|
||||
|
||||
pulsef = Pulseformer("pulseform","rrc","fdac",fdac,"fsym",fsym,"pulselength",32,"rrcalpha",0.05);
|
||||
|
||||
awg = AWG('preset','M8199B','fdac',fdac,'kover',kover,'lpf_active',1,'f_cutoff',56e9,'lpf_type',filtertypes.gaussian,'bit_resolution',5.5);
|
||||
|
||||
lp_laser = Filter('filtdegree',1,"f_cutoff",30e9,"fsamp",fdac,"filterType",filtertypes.bessel_inp);
|
||||
|
||||
|
||||
|
||||
%% PROCESS
|
||||
|
||||
% PRBS Generation
|
||||
for i = 1:log2(M)
|
||||
[bitpattern(:,i),seed] = prbs(O,N,seed);
|
||||
end
|
||||
|
||||
% Build Inf. signal class
|
||||
bits = Informationsignal(bitpattern);
|
||||
|
||||
% Digi Mod
|
||||
mod_out = digimod.map(bits);
|
||||
% merken für EQ training
|
||||
reference = mod_out;
|
||||
|
||||
% shape shape
|
||||
mod_out = pulsef.process(mod_out);
|
||||
test = applyPulseShaping(reference.signal,fsym,fdac);
|
||||
|
||||
% AWG -> ELECTRICAL DOMAIN
|
||||
X = lp_laser.process(mod_out);
|
||||
%X.spectrum(fsimu,"displayname",'AWG out','figurename','after AWG');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
227
projects/IMDD_base_system/imddmodel.m
Normal file
227
projects/IMDD_base_system/imddmodel.m
Normal file
@@ -0,0 +1,227 @@
|
||||
function output = imddmodel(sir,dcmode)
|
||||
|
||||
for realiz = 1:3
|
||||
|
||||
rng(realiz);
|
||||
|
||||
%% Set Simulation Variables
|
||||
delay = 0;10+(10*realiz); %mpi delay in meter
|
||||
|
||||
fiblen = 0; %main link in km
|
||||
|
||||
laser_linewidth =0e6;
|
||||
|
||||
O = 18; %order of prbs
|
||||
N = 2^(O-1); %length of prbs
|
||||
[~,seed] = prbs(O,1); %initialize first seed of prbs
|
||||
|
||||
% Modulation
|
||||
M = 4; %PAM-M
|
||||
bitpattern = zeros(N,log2(M));
|
||||
|
||||
% Symbol Rate
|
||||
fsym = 112e9;
|
||||
|
||||
% DAC Rate
|
||||
fdac = 120e9;
|
||||
|
||||
% Simulation oversampling rate "k";
|
||||
kover = 16;
|
||||
|
||||
% ADC Rate
|
||||
fadc = 256e9;
|
||||
|
||||
% Simulation frequency in "analog domain"
|
||||
fsimu = kover * fdac ;
|
||||
|
||||
|
||||
|
||||
%% B) CONSTRUCT ALL CLASSES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
digimod = PAMmapper(M,0);
|
||||
|
||||
pulseform = Pulseformer("pulseform","rrc","fdac",fdac,"fsym",fsym,"pulselength",32,"rrcalpha",0.027);
|
||||
|
||||
awg = AWG('fdac',fdac,'kover',kover,'lpf_active',1,'f_cutoff',56e9,'lpf_type',filtertypes.gaussian,'bit_resolution',5.5);
|
||||
|
||||
lp_laser = Filter('filtdegree',1,"f_cutoff",50e9,"fsamp",fdac*kover,"filterType",filtertypes.bessel_inp);
|
||||
|
||||
u_pi = 3.5;
|
||||
vbias = (0.5*u_pi)-u_pi;
|
||||
extmodlaser = EML("mode",eml_mode.im_cosinus,"power",5,"fsimu",fsimu,"lambda",1550,"bias",vbias,"u_pi",u_pi,"linewidth",laser_linewidth);
|
||||
|
||||
fib = Fiber("fsimu",fdac*kover,"fiber_length",fiblen,"alpha",0.2,"D",16,"lambda0",thz2nm(193.1),"gamma",0);
|
||||
|
||||
reflectionpoint = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",sir);
|
||||
reflectionprop = Fiber("fsimu",fdac*kover,"fiber_length",delay/1000,"alpha",0.2,"D",16,"lambda0",1550,"gamma",0);
|
||||
|
||||
opticatten = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",-8);
|
||||
|
||||
phdiode = Photodiode("fsimu",fdac*kover,"dark_current",2e-08,"responsivity",1,"temperature",20);
|
||||
|
||||
lp_diode = Filter('filtdegree',1,"f_cutoff",50e9,"fsamp",fdac*kover,"filterType",filtertypes.bessel_inp);
|
||||
|
||||
scp = Scope("fsimu",fdac*kover,"fadc",fadc,...
|
||||
"delay",0,"fixed_delay",0,"lpf_bw",113e9,"filtertype",filtertypes.butterworth,...
|
||||
"samplingdelay",0,"rand_samplingdelay",0,"freq_offset",0,"samp_jitter",0,...
|
||||
"adcresolution",6,"quantbuffer",0.1,'block_dc',1);
|
||||
|
||||
eq = EQ("K",2,"plottrain",0,"plotfinal",0,...
|
||||
"training_length",4096,"training_loops",2,...
|
||||
"Ne",[50,5,3],"Nb",[3,2,2],...
|
||||
"DCmu",0.05,"DDmu",[0.0004 0.0005 0.0006 0.0007 ],"DFEmu",0.005,"FFEmu",0.005,...
|
||||
"dd_loops",2,"epsilon",[10 100 1000 ],"M",2,...
|
||||
"thres",[0.005 0.004 0.0005 ],"l1act",0,"delay",0,"rho",0.0005,"ideal_dfe",0,"DB_aim",0);
|
||||
|
||||
eq2 = EQ_silas("Ne",[20,0,0],"Nb",[3,0,0],"trainlength",4096,"mu_dc_dd",0.005,"mu_dc_train",0.05,...
|
||||
"mu_ffe_train",0.005,"mu_combined_dd",[0.0004 0.0006 0.0003 0.005],"ddloops",3,"dcmode",dcmode);
|
||||
|
||||
|
||||
%% C) PROCESS TX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% 1) PRBS Generation
|
||||
for i = 1:log2(M)
|
||||
[bitpattern(:,i),seed] = prbs(O,N,seed);
|
||||
end
|
||||
|
||||
% 2 ) Build Inf. signal class
|
||||
bits = Informationsignal(bitpattern);
|
||||
|
||||
% 3) Digi modulation -> PAM-M signal
|
||||
digimod_out = digimod.map(bits);
|
||||
|
||||
% 4) Pulse shaping -> racos
|
||||
X = pulseform.process(digimod_out);
|
||||
|
||||
% 5) AWG (lowpass, quantization, sample and hold)
|
||||
X = awg.process(X);
|
||||
|
||||
% 6) Lowpass behavior of laser and hf-cable? why twice?
|
||||
X = lp_laser.process(X);
|
||||
X = lp_laser.process(X);
|
||||
|
||||
% 7) Normalize signal
|
||||
X = X.normalize("mode","oneone");
|
||||
X.signal = X.signal .* 1.3800;
|
||||
|
||||
|
||||
|
||||
%% D) PROCESS OPTICAL CHANNEL %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% 1) Laser; Modulation -> OPTICAL DOMAIN
|
||||
[X,extmodlaser] = extmodlaser.process(X);
|
||||
|
||||
% 2) Main fiber propagation
|
||||
X = fib.process(X);
|
||||
|
||||
if delay ~= 0
|
||||
|
||||
% 3) Reflection
|
||||
% Reflection is just an attenuation
|
||||
R = reflectionpoint.process(X);
|
||||
|
||||
% Propagate back and forth (actual fiber propagation)
|
||||
R = reflectionprop.process(R);
|
||||
|
||||
% Delay the reflected signal
|
||||
[R,n] = R.delay("delay_meter",delay);
|
||||
|
||||
% Add together
|
||||
X.signal = X.signal(n:end);
|
||||
R.signal = R.signal(n:end);
|
||||
|
||||
%disp(['SIR ',num2str(10*log10(X.power/R.power))]);
|
||||
|
||||
X = X+R;
|
||||
|
||||
% 4) Equalize
|
||||
% cut reference signal to correct length (nessecary due to MPI delay)
|
||||
digimod_out.signal = digimod_out.signal(round(n * fsym/fsimu) : end,:);
|
||||
bitpattern = bitpattern(round(n * fsym/fsimu):end,:);
|
||||
end
|
||||
|
||||
% 4) Attenuation
|
||||
X = opticatten.process(X);
|
||||
% X = edfaamp.process(X);
|
||||
|
||||
% 5) Photo Diode -> ELECTRICAL DOMAIN
|
||||
X = phdiode.process(X);
|
||||
X = lp_diode.process(X);
|
||||
|
||||
|
||||
%% E) PROCESS RX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% 1) Oscilloscope (Sampling to f_adc; Quantization; Bandwidth Limitation)
|
||||
X = scp.process(X);
|
||||
|
||||
% 2) Resample to 2x symbol rate
|
||||
X = X.resample("fs_out",2*fsym,"fs_in",fadc);
|
||||
|
||||
% 3) Normalize
|
||||
Eq_in = X.normalize("mode","rms");
|
||||
|
||||
|
||||
|
||||
% MPI reduction DC removal BEFORE EQ
|
||||
wl = 3000; % symbols
|
||||
Eq_in.signal = Eq_in.signal - 1/wl .* movsum( Eq_in.signal,[wl/2,wl/2]);
|
||||
|
||||
% Equalize Signal
|
||||
[Eq_out] = eq2.process(Eq_in,digimod_out);
|
||||
|
||||
|
||||
|
||||
|
||||
%% A1: MPI reduction DC removal
|
||||
wl = 1000; % symbols
|
||||
yk_dcsm = Eq_out;
|
||||
yk_dcsm.signal = Eq_out.signal - 1/wl .* movsum( Eq_out.signal,[wl/2,wl/2]);
|
||||
|
||||
%% A2: MPI reduction Level wise error removal
|
||||
yk_lvsm = Eq_out;
|
||||
yk_lvlp = Eq_out;
|
||||
pre_decision_level_uni = digimod.decide_pamlevel(Eq_out);
|
||||
pre_decision_level_bi = ( pre_decision_level_uni*2-3 ) .* 1/sqrt(5);
|
||||
|
||||
e = Eq_out.signal - pre_decision_level_bi;
|
||||
|
||||
lp_mpi = Filter('filtdegree',1,"f_cutoff",2e6,"fsamp",fsym,"filterType",filtertypes.bessel_inp);
|
||||
|
||||
filtered = lp_mpi.process(e);
|
||||
|
||||
wl = 30; % symbols
|
||||
smoothed = ( 1/wl .* movsum(e,[wl/2,wl/2]) );
|
||||
|
||||
% remove interference
|
||||
for level = 0:3
|
||||
yk_lvsm.signal(pre_decision_level_uni==level) = yk_lvsm.signal(pre_decision_level_uni==level) - smoothed(pre_decision_level_uni==level);
|
||||
yk_lvlp.signal(pre_decision_level_uni==level) = yk_lvlp.signal(pre_decision_level_uni==level) - filtered(pre_decision_level_uni==level);
|
||||
end
|
||||
|
||||
%% PROCESS RX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% 1) Digi Demod
|
||||
d_bm = digimod.demap(Eq_out);
|
||||
d_dcsm = digimod.demap(yk_dcsm);
|
||||
d_lvsm = digimod.demap(yk_lvsm);
|
||||
d_lvlp = digimod.demap(yk_lvlp);
|
||||
|
||||
% 2) BER
|
||||
|
||||
dbit = length(d_bm.signal)-length(bitpattern);
|
||||
|
||||
[~,errors_bm,ber_bm(realiz),loc] = calc_ber(d_bm.signal(1:end-dbit,:) ,bitpattern(1:end,:),"skip",0,"returnErrorLocation",1);
|
||||
[~,errors_dcsm,ber_dcsm(realiz)] = calc_ber(d_dcsm.signal(1:end-dbit,:) ,bitpattern(1:end,:),"skip",0,"returnErrorLocation",0);
|
||||
[~,errors_lvsm,ber_lvsm(realiz)] = calc_ber(d_lvsm.signal(1:end-dbit,:) ,bitpattern(1:end,:),"skip",0,"returnErrorLocation",0);
|
||||
[~,errors_lvlp,ber_lvlp(realiz)] = calc_ber(d_lvlp.signal(1:end-dbit,:) ,bitpattern(1:end,:),"skip",0,"returnErrorLocation",0);
|
||||
|
||||
|
||||
end
|
||||
|
||||
output.ber_bm = mean(ber_bm);
|
||||
output.ber_dcsm = mean(ber_dcsm);
|
||||
output.ber_lvsm = mean(ber_lvsm);
|
||||
output.ber_lvlp = mean(ber_lvlp);
|
||||
|
||||
|
||||
end
|
||||
208
projects/IMDD_base_system/run_loop.m
Normal file
208
projects/IMDD_base_system/run_loop.m
Normal file
@@ -0,0 +1,208 @@
|
||||
|
||||
clear
|
||||
|
||||
sir_loop = [-25:2:-13];
|
||||
sir_loop = 0;
|
||||
lw_loop = [1,2,3];
|
||||
|
||||
data = cell(length(sir_loop),length(lw_loop));
|
||||
|
||||
iterations=size(data);
|
||||
|
||||
parfor ix = 1:numel(data)
|
||||
|
||||
[u1,u2] = ind2sub(iterations,ix);
|
||||
|
||||
output = imddmodel(sir_loop(u1),lw_loop(u2));
|
||||
|
||||
data{ix} = output;
|
||||
|
||||
end
|
||||
|
||||
for sir = 1:size(data,1)
|
||||
for lw = 1:size(data,2)
|
||||
ber_bm(sir,lw) = data{sir,lw}.ber_bm;
|
||||
ber_dcsm(sir,lw) = data{sir,lw}.ber_dcsm;
|
||||
ber_lvsm(sir,lw) = data{sir,lw}.ber_lvsm;
|
||||
ber_lvlp(sir,lw) = data{sir,lw}.ber_lvlp;
|
||||
end
|
||||
end
|
||||
|
||||
col = [ 0.6510 0.8078 0.8902
|
||||
0.6980 0.8745 0.5412
|
||||
0.9922 0.7490 0.4353];
|
||||
figure(22)
|
||||
for l = 1:numel(lw_loop)
|
||||
hold on
|
||||
plot(sir_loop,ber_bm(:,l),'DisplayName',['DC mode:', num2str(lw_loop(l)),', Linewidth= 50 MHz'],'Marker','o','MarkerFaceColor',col(l,:),'Color',col(l,:),'LineWidth',2,'LineStyle','--');
|
||||
end
|
||||
set(gca,'yscale','log');
|
||||
yline(3.8e-3,'LineWidth',2,'LineStyle','--','HandleVisibility','off');
|
||||
set(gca,'xdir','reverse');
|
||||
|
||||
|
||||
|
||||
%% Plot
|
||||
col = linspecer(8);
|
||||
figure(1)
|
||||
hold on
|
||||
m = ["x","o","pentagram","hexagram","*","+"];
|
||||
cnt = 1;
|
||||
for d = 1%:size(data,2)
|
||||
for dc = 1:size(data,1)
|
||||
for lw = 1:size(data,3)
|
||||
ber_bm(dc,d,lw) = (data{dc,d,lw}.ber_bm);
|
||||
ber_dcsm(dc,d,lw) = data{dc,d,lw}.ber_dcsm;
|
||||
ber_lvsm(dc,d,lw) = data{dc,d,lw}.ber_lvsm;
|
||||
ber_lvlp(dc,d,lw) = (data{dc,d,lw}.ber_lvlp);
|
||||
end
|
||||
end
|
||||
i = 1;
|
||||
comm_dn = [];% ['EQ DC Tap: ',num2str(dc_tap_loop(d)),' m'];
|
||||
title("Dependency on Laser Linewidth; B2B; Delay : 2*50m")
|
||||
plot(lw_loop*1e-6,mean(squeeze(ber_bm(1:end,d,:)),1),"LineWidth",1.2,"Marker",m(1),"MarkerSize",5,'Color',col(cnt,:),'DisplayName',[' ',comm_dn]);
|
||||
plot(lw_loop*1e-6,mean(squeeze(ber_dcsm(1:end,d,:)),1),"LineWidth",1,"Marker",m(1+4),"MarkerSize",5,'LineStyle','--','Color',col(cnt,:),'DisplayName',['DC smoothing ',comm_dn],'HandleVisibility','on');
|
||||
plot(lw_loop*1e-6,mean(squeeze(ber_lvsm(1:end,d,:)),1),"LineWidth",1.2,"Marker",m(1+1),"MarkerSize",5,'LineStyle',':','Color',col(cnt,:),'DisplayName',['Lvl Smoothing ',comm_dn],'HandleVisibility','on');
|
||||
plot(lw_loop*1e-6,mean(squeeze(ber_lvlp(1:end,d,:)),1),"LineWidth",1,"Marker",m(1+3),"MarkerSize",5,'LineStyle','-.','Color',col(cnt,:),'DisplayName',['Lvl Lowpass ',comm_dn],'HandleVisibility','on');
|
||||
set(gca,'yscale','log');
|
||||
set(gca,'xscale','log');
|
||||
%xticklabels([10 100 1000 10000]);
|
||||
grid minor
|
||||
yline(3.8e-3,'LineWidth',2,'LineStyle','--','HandleVisibility','off');
|
||||
ylim([1e-3 4e-2]);
|
||||
ylabel("BER");
|
||||
xlabel("Linewidth in MHz")
|
||||
legend
|
||||
cnt = cnt+1;
|
||||
end
|
||||
|
||||
|
||||
figure(1)
|
||||
contour(lw_loop,sir_loop,thres_a0,16:0.4:21,'LineWidth',2,'FaceAlpha',0.3,'ShowText','on',"LabelFormat","%0.1f dB");
|
||||
clim([16 21]);
|
||||
ylabel("Bandwidth in Multiples of Linewidth");
|
||||
xlabel("Linewidth in MHz");
|
||||
% set(gca,'yscale','log');
|
||||
grid minor
|
||||
title("MPI removal - Optimization of Lowpass Filter Bandwidth")
|
||||
|
||||
figure(2)
|
||||
contour(lw_loop,sir_loop([1:10,12:end]),thres_a0([1:10,12:end],:),16:0.3:21,'LineWidth',2,'FaceAlpha',0.3,'ShowText','on',"LabelFormat","%0.1f dB");
|
||||
clim([16 21]);
|
||||
ylabel("Window Length");
|
||||
xlabel("Linewidth in MHz");
|
||||
set(gca,'yscale','log');
|
||||
grid minor
|
||||
title("MPI removal - Optimization of Averaging Window Length")
|
||||
|
||||
|
||||
|
||||
%% Plot Winlen Contour
|
||||
hdfec = 3.8e-3.*ones(size(sir_loop));
|
||||
|
||||
for dc = 1:size(data,2)
|
||||
for lw = 1:size(data,3)
|
||||
for s = 1:size(data,1)
|
||||
ber_lvlp(s,dc,lw) = data{s,dc,lw}.ber_dcsm;
|
||||
% ber_dcsm(wl,lw,s) = data{wl,s,lw}.ber_dcsm;
|
||||
end
|
||||
|
||||
a_bm = InterX([sir_loop;squeeze(ber_lvlp(:,dc,lw))'],[sir_loop;hdfec]);
|
||||
% a_dcsm = InterX([sirloop;squeeze(ber_dcsm(wl,lw,:))'],[sirloop;hdfec]);
|
||||
try
|
||||
thres_a0(dc,lw) = -a_bm(1);
|
||||
%thres_a1(wl,lw) = -a_dcsm(1);
|
||||
catch
|
||||
thres_a0(dc,lw) = NaN;
|
||||
%thres_a1(wl,lw) = NaN;
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
figure(1)
|
||||
contour(lw_loop,bw_loop,thres_a0,14:0.2:21,'LineWidth',1.5,'FaceAlpha',0.3,'ShowText','on',"LabelFormat","%0.1f dB");
|
||||
a = flip(cbrewer2('seq','Spectral',32));
|
||||
a = [a(1:12,:); a(22:end,:)];
|
||||
colormap(a);
|
||||
clim([16 21]);
|
||||
ylabel("Window Length");
|
||||
xlabel("Linewidth in MHz");
|
||||
yticks(bw_loop);
|
||||
yticklabels(bw_loop);
|
||||
set(gca,'yscale','log');
|
||||
set(gca,'xscale','log');
|
||||
grid minor
|
||||
|
||||
|
||||
|
||||
|
||||
%% Plot DC Tap Contour
|
||||
hdfec = 3.8e-3.*ones(size(bw_loop));
|
||||
thres_a0 = zeros(size(ber,1),size(ber,3));
|
||||
thres_a1 = zeros(size(ber,1),size(ber,3));
|
||||
for dc = 1:size(ber,1)
|
||||
for lw = 1:size(ber,3)
|
||||
a_lvsm = InterX([bw_loop;ber(dc,:,lw)],[bw_loop;hdfec]);
|
||||
thres_a0(dc,lw) = -a_lvsm(1);
|
||||
|
||||
a1 = InterX([bw_loop;ber_a1(dc,:,lw)],[bw_loop;hdfec]);
|
||||
thres_a1(dc,lw) = -a1(1);
|
||||
end
|
||||
end
|
||||
|
||||
figure(1)
|
||||
subplot(2,1,1)
|
||||
contour(lw_loop,sir_loop,thres_a0,16:0.5:21,'LineWidth',3,'FaceAlpha',0.3,'ShowText','on',"LabelFormat","%0.1f dB");
|
||||
clim([16 21]);
|
||||
ylabel("DC Tap");
|
||||
xlabel("Linewidth in MHz");
|
||||
set(gca,'yscale','log');
|
||||
grid minor
|
||||
subplot(2,1,2)
|
||||
contour(lw_loop,sir_loop,thres_a1,16:0.5:21,'LineWidth',3,'FaceAlpha',0.3,'ShowText','on',"LabelFormat","%0.1f dB");
|
||||
clim([16 21]);
|
||||
ylabel("DC Tap");
|
||||
xlabel("Linewidth in MHz");
|
||||
set(gca,'yscale','log');
|
||||
grid minor
|
||||
|
||||
%% Plot Curves of required SIR to see the minimum a bit better
|
||||
col = flip(cbrewer2('seq','Spectral',16));
|
||||
col = col([1:4, 10:end],:);
|
||||
figure(2)
|
||||
hold on
|
||||
for lw = [size(ber,3):-2:2 2 1]
|
||||
plot(sir_loop,thres_a0(:,lw),'DisplayName',[' Linewidth: ',num2str(lw_loop(lw)*1e-6), ' MHz'],'Color',col(lw,:),'Marker','o','MarkerFaceColor',col(lw,:),'LineWidth',2);
|
||||
set(gca,'xscale','log');
|
||||
end
|
||||
xlabel("DC Tap Value");
|
||||
ylabel("Required SIR to rech FEC in dB");
|
||||
|
||||
%%
|
||||
col = linspecer(7);
|
||||
figure(3)
|
||||
cnt=1;
|
||||
for lw = [1,2,11]
|
||||
|
||||
for i = 1:length(sir_loop)-1
|
||||
|
||||
subplot(1,3,cnt)
|
||||
hold on
|
||||
plot(-1.*bw_loop,ber(i,:,lw),"LineWidth",2,"Marker","o","MarkerSize",5,'Color',col(i,:),'DisplayName',['DC tap ',num2str(sir_loop(i))]);
|
||||
plot(-1.*bw_loop,ber_a1(i,:,lw),"LineWidth",2,"Marker","x","MarkerSize",5,'LineStyle','--','Color',col(i,:),'DisplayName',['A1. DC tap ',num2str(sir_loop(i))]);
|
||||
yline(3.8e-3,'LineWidth',2,'LineStyle','--','HandleVisibility','off');
|
||||
set(gca,'yscale','log');
|
||||
grid minor
|
||||
|
||||
xlim([15,30]);
|
||||
ylim([1e-4,1e-2]);
|
||||
xlabel("SIR in dB");
|
||||
ylabel("BER");
|
||||
title(['BER for different SIR;',' Linewidth: ',num2str(lw_loop(lw)*1e-6), ' MHz'])
|
||||
text(25,4.2e-3,"FEC $3.8 e^{-3}$");
|
||||
end
|
||||
cnt = cnt+1;
|
||||
end
|
||||
legend
|
||||
|
||||
399
projects/IMDD_base_system/setup_simulation.m
Normal file
399
projects/IMDD_base_system/setup_simulation.m
Normal file
@@ -0,0 +1,399 @@
|
||||
|
||||
|
||||
lw = [0.1e6 1e6 10e6];
|
||||
|
||||
for lp = 1
|
||||
|
||||
rng(9);
|
||||
|
||||
%% A) Set Simulation Variables
|
||||
|
||||
sir = -18;
|
||||
delay = 50; %mpi delay in meter
|
||||
|
||||
fiblen = 0; %main link in km
|
||||
|
||||
laser_linewidth =5e6;
|
||||
|
||||
O = 19; %order of prbs
|
||||
N = 2^(O-1); %length of prbs
|
||||
[~,seed] = prbs(O,1); %initialize first seed of prbs
|
||||
|
||||
% Modulation
|
||||
M = 4; %PAM-M
|
||||
bitpattern = zeros(N,log2(M));
|
||||
|
||||
% Symbol Rate
|
||||
fsym = 112e9;
|
||||
|
||||
% DAC Rate
|
||||
fdac = 120e9;
|
||||
|
||||
% Simulation oversampling rate "k";
|
||||
kover = 16;
|
||||
|
||||
% ADC Rate
|
||||
fadc = 256e9;
|
||||
|
||||
% Simulation frequency in "analog domain"
|
||||
fsimu = kover * fdac ;
|
||||
|
||||
|
||||
|
||||
%% B) CONSTRUCT ALL CLASSES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
digimod = PAMmapper(M,0);
|
||||
|
||||
pulseform = Pulseformer("pulseform","rrc","fdac",fdac,"fsym",fsym,"pulselength",32,"rrcalpha",0.027);
|
||||
|
||||
awg = AWG('fdac',fdac,'kover',kover,'lpf_active',1,'f_cutoff',56e9,'lpf_type',filtertypes.gaussian,'bit_resolution',5.5);
|
||||
|
||||
lp_laser = Filter('filtdegree',1,"f_cutoff",50e9,"fsamp",fdac*kover,"filterType",filtertypes.bessel_inp);
|
||||
|
||||
u_pi = 3.5;
|
||||
vbias = (0.5*u_pi)-u_pi;
|
||||
extmodlaser = EML("mode",eml_mode.im_cosinus,"power",5,"fsimu",fsimu,"lambda",1310,"bias",vbias,"u_pi",u_pi,"linewidth",laser_linewidth);
|
||||
|
||||
fib = Fiber("fsimu",fdac*kover,"fiber_length",fiblen,"alpha",0.2,"D",16,"lambda0",thz2nm(193.1),"gamma",0);
|
||||
|
||||
reflectionpoint = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",sir);
|
||||
reflectionprop = Fiber("fsimu",fdac*kover,"fiber_length",delay/1000,"alpha",0.2,"D",16,"lambda0",1550,"gamma",0);
|
||||
|
||||
opticatten = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",-8);
|
||||
|
||||
phdiode = Photodiode("fsimu",fdac*kover,"dark_current",2e-08,"responsivity",1,"temperature",20);
|
||||
|
||||
lp_diode = Filter('filtdegree',1,"f_cutoff",50e9,"fsamp",fdac*kover,"filterType",filtertypes.bessel_inp);
|
||||
|
||||
scp = Scope("fsimu",fdac*kover,"fadc",fadc,...
|
||||
"delay",0,"fixed_delay",0,"lpf_bw",113e9,"filtertype",filtertypes.butterworth,...
|
||||
"samplingdelay",0,"rand_samplingdelay",0,"freq_offset",0,"samp_jitter",0,...
|
||||
"adcresolution",6,"quantbuffer",0.1,'block_dc',1);
|
||||
|
||||
eq = EQ("K",2,"plottrain",0,"plotfinal",0,...
|
||||
"training_length",4096,"training_loops",2,...
|
||||
"Ne",[50,5,3],"Nb",[3,0,0],...
|
||||
"DCmu",0.05,"DDmu",[0.0004 0.0005 0.0006 0.0007 ],"DFEmu",0.005,"FFEmu",0.00,...
|
||||
"dd_loops",2,"epsilon",[10 100 1000 ],"M",2,...
|
||||
"thres",[0.005 0.004 0.0005 ],"l1act",0,"delay",0,"rho",0.0005,"ideal_dfe",0,"DB_aim",0);
|
||||
|
||||
eq = EQ_silas("Ne",[50,5,3],"Nb",[2,0,0],"trainlength",4096,...
|
||||
"sps",2,...
|
||||
"mu_dc_dd",0.05,...
|
||||
"mu_dc_train",0.05,...
|
||||
"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,...
|
||||
"dcmode",1);
|
||||
|
||||
|
||||
%% C) PROCESS TX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% 1) PRBS Generation
|
||||
for i = 1:log2(M)
|
||||
[bitpattern(:,i),seed] = prbs(O,N,seed);
|
||||
end
|
||||
|
||||
% 2 ) Build Inf. signal class
|
||||
bits = Informationsignal(bitpattern);
|
||||
|
||||
% 3) Digi modulation -> PAM-M signal
|
||||
digimod_out = digimod.map(bits);
|
||||
|
||||
% 4) Pulse shaping -> racos
|
||||
X = pulseform.process(digimod_out);
|
||||
|
||||
% 5) AWG (lowpass, quantization, sample and hold)
|
||||
X = awg.process(X);
|
||||
|
||||
% 6) Lowpass behavior of laser and hf-cable? why twice?
|
||||
X = lp_laser.process(X);
|
||||
% X = lp_laser.process(X);
|
||||
|
||||
% 7) Normalize signal
|
||||
X = X.normalize("mode","oneone");
|
||||
X.signal = X.signal .* 1.3800;
|
||||
|
||||
|
||||
%% D) PROCESS OPTICAL CHANNEL %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% 1) Laser; Modulation -> OPTICAL DOMAIN
|
||||
[X,extmodlaser] = extmodlaser.process(X);
|
||||
|
||||
% 2) Main fiber propagation
|
||||
X = fib.process(X);
|
||||
|
||||
if delay ~= 0
|
||||
% 3) Reflection
|
||||
% Reflection is just an attenuation
|
||||
R = reflectionpoint.process(X);
|
||||
|
||||
% Propagate back and forth (actual fiber propagation)
|
||||
R = reflectionprop.process(R);
|
||||
|
||||
% Delay the reflected signal
|
||||
[R,n] = R.delay("delay_meter",delay);
|
||||
|
||||
% Add together
|
||||
col = cbrewer2('qual','Paired',8);
|
||||
|
||||
xax = (1:X.length);% / fsimu * (physconst("LightSpeed")/1.4677);
|
||||
xax_sec = (1:X.length) / fsimu .* 1e6;%* (physconst("LightSpeed")/1.4677);
|
||||
xax_sec = xax_sec(n:end).';
|
||||
thresh = pi/4;
|
||||
phaseX = phase(X.signal(n:end));
|
||||
phaseR = phase(R.signal(n:end));
|
||||
phasediff = wrapToPi(phaseX-phaseR);
|
||||
[pos_high] = find(abs(phasediff)>thresh);
|
||||
[pos_low] = find(abs(phasediff)<=thresh);
|
||||
|
||||
|
||||
figure(6);hold on;histogram(phaseX-phaseR,500,'EdgeAlpha',0)
|
||||
|
||||
figure()
|
||||
subplot(3,1,1)
|
||||
scatter(xax_sec.',wrapToPi(phaseX),4,'.','MarkerEdgeColor',col(2,:),'DisplayName','Desired Signal')
|
||||
hold on
|
||||
scatter(xax_sec,wrapToPi(phaseR),4,'.','MarkerEdgeColor',col(1,:),'DisplayName','Reflected Signal')
|
||||
hold on
|
||||
lg = legend;
|
||||
lg.Location = "southwest";
|
||||
xlim([xax_sec(1) xax_sec(end)]);
|
||||
xlabel('time in $\mu$s')
|
||||
ylim([-pi pi]);
|
||||
yticks([-pi 0 pi])
|
||||
yticklabels({'$-\pi$',0, '$\pi$'})
|
||||
ylabel('$\phi$')
|
||||
|
||||
subplot(3,1,2)
|
||||
scatter(xax_sec(pos_low),phasediff(pos_low),4,'.','MarkerEdgeColor',col(5,:),'DisplayName','Phase Difference')
|
||||
hold on
|
||||
scatter(xax_sec(pos_high),phasediff(pos_high),4,'.','MarkerEdgeColor',col(2,:),'HandleVisibility','off')
|
||||
% yline(thresh,'LineWidth',2,'LineStyle','-','HandleVisibility','off')
|
||||
% yline(-thresh,'LineWidth',2,'LineStyle','-','HandleVisibility','off')
|
||||
lg = legend;
|
||||
lg.Location = "southwest";
|
||||
xlabel('time in $\mu$s')
|
||||
xlim([xax_sec(1) xax_sec(end)]);
|
||||
ylim([-pi pi]);
|
||||
yticks([-pi 0 pi])
|
||||
yticklabels({'$-\pi$',0, '$\pi$'})
|
||||
ylabel('$\Delta \phi$')
|
||||
|
||||
|
||||
X.signal = X.signal(n:end);
|
||||
R.signal = R.signal(n:end);
|
||||
X1 = X;
|
||||
X = X+R;
|
||||
|
||||
subplot(3,1,3)
|
||||
scatter(xax_sec(pos_low),abs(X.signal(pos_low).^2)*1000,4,'.','MarkerEdgeColor',col(5,:),'DisplayName','Constructive Interference');
|
||||
hold on
|
||||
scatter(xax_sec(pos_high),abs(X.signal(pos_high).^2)*1000,4,'.','MarkerEdgeColor',col(2,:),'DisplayName','Destructive Interference');
|
||||
%scatter(xax_sec(pos_high),abs(X1.signal(pos_high).^2)*1000,4,'.','MarkerEdgeColor',col(1,:),'MarkerFaceAlpha',0.3,'DisplayName','Destructive Interference');
|
||||
xlim([xax_sec(1) xax_sec(end)]);
|
||||
xlabel('time in $\mu$s')
|
||||
lg = legend;
|
||||
lg.Location = "southwest";
|
||||
ylabel('Optical power in mW');
|
||||
|
||||
|
||||
|
||||
|
||||
disp(['SIR ',num2str(10*log10(X.power/R.power))]);
|
||||
|
||||
% cut reference signal to correct length (nessecary due to MPI delay)
|
||||
digimod_out.signal = digimod_out.signal(round(n * fsym/fsimu) : end,:);
|
||||
|
||||
bitpattern = bitpattern(round(n * fsym/fsimu):end,:);
|
||||
|
||||
end
|
||||
|
||||
|
||||
% plot(angle(R.signal))
|
||||
|
||||
% 4) Attenuation
|
||||
X = opticatten.process(X);
|
||||
|
||||
|
||||
% 5) Photo Diode -> ELECTRICAL DOMAIN
|
||||
X = phdiode.process(X);
|
||||
X = lp_diode.process(X);
|
||||
|
||||
|
||||
%% E) PROCESS RX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% 1) Oscilloscope (Sampling to f_adc; Quantization; Bandwidth Limitation)
|
||||
X = scp.process(X);
|
||||
|
||||
% 2) Resample to 2x symbol rate
|
||||
X = X.resample("fs_out",2*fsym,"fs_in",fadc);
|
||||
|
||||
% 3) Normalize
|
||||
Eq_in = X.normalize("mode","rms");
|
||||
|
||||
% 4) Equalize
|
||||
|
||||
% MPI reduction DC removal BEFORE EQ
|
||||
wl = 3000; % symbols
|
||||
Eq_in.signal = Eq_in.signal - 1/wl .* movsum( Eq_in.signal,[wl/2,wl/2]);
|
||||
|
||||
% Equalize Signal
|
||||
[Eq_out] = eq.process(Eq_in,digimod_out);
|
||||
|
||||
|
||||
|
||||
%% A1: MPI reduction DC removal
|
||||
wl = 1000; % symbols
|
||||
yk_dcsm = Eq_out;
|
||||
yk_dcsm.signal = Eq_out.signal - 1/wl .* movsum( Eq_out.signal,[wl/2,wl/2]);
|
||||
|
||||
%% A2: MPI reduction Level wise error removal
|
||||
yk_lvsm = Eq_out;
|
||||
yk_lvlp = Eq_out;
|
||||
pre_decision_level_uni = digimod.decide_pamlevel(Eq_out);
|
||||
pre_decision_level_bi = ( pre_decision_level_uni*2-3 ) .* 1/sqrt(5);
|
||||
|
||||
e = Eq_out.signal - pre_decision_level_bi;
|
||||
|
||||
lp_mpi = Filter('filtdegree',1,"f_cutoff",2e6,"fsamp",fsym,"filterType",filtertypes.bessel_inp);
|
||||
|
||||
filtered = lp_mpi.process(e);
|
||||
|
||||
wl = 30; % symbols
|
||||
smoothed = ( 1/wl .* movsum(e,[wl/2,wl/2]) );
|
||||
|
||||
% remove interference
|
||||
for level = 0:3
|
||||
yk_lvsm.signal(pre_decision_level_uni==level) = yk_lvsm.signal(pre_decision_level_uni==level) - smoothed(pre_decision_level_uni==level);
|
||||
yk_lvlp.signal(pre_decision_level_uni==level) = yk_lvlp.signal(pre_decision_level_uni==level) - filtered(pre_decision_level_uni==level);
|
||||
end
|
||||
|
||||
% Calc EVM
|
||||
|
||||
evm_bm = calc_evm(Eq_out.signal, pre_decision_level_bi);
|
||||
evm_dcsm = calc_evm(yk_dcsm.signal, pre_decision_level_bi);
|
||||
evm_lsm = calc_evm(yk_lvsm.signal, pre_decision_level_bi);
|
||||
evm_llp = calc_evm(yk_lvlp.signal, pre_decision_level_bi);
|
||||
|
||||
% figure(1);bar([evm_bm' evm_dcsm' evm_llp' evm_lsm']);ylim([0.01 0.1]);set(gca,'yscale','log');
|
||||
|
||||
%% PROCESS RX %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% 1) Digi Demod
|
||||
d_bm = digimod.demap(Eq_out);
|
||||
d_dcsm = digimod.demap(yk_dcsm);
|
||||
d_lvsm = digimod.demap(yk_lvsm);
|
||||
d_lvlp = digimod.demap(yk_lvlp);
|
||||
|
||||
% 2) BER
|
||||
dbit = length(d_bm.signal)-length(bitpattern);
|
||||
|
||||
[~,errors_bm,ber_bm,loc] = calc_ber(d_bm.signal(1:end-dbit,:) ,bitpattern(1:end,:),"skip",0,"returnErrorLocation",1);
|
||||
[~,errors_dcsm,ber_dcsm] = calc_ber(d_dcsm.signal(1:end-dbit,:) ,bitpattern(1:end,:),"skip",0,"returnErrorLocation",0);
|
||||
[~,errors_lvsm,ber_lvsm] = calc_ber(d_lvsm.signal(1:end-dbit,:) ,bitpattern(1:end,:),"skip",0,"returnErrorLocation",0);
|
||||
[~,errors_lvlp,ber_lvlp] = calc_ber(d_lvlp.signal(1:end-dbit,:) ,bitpattern(1:end,:),"skip",0,"returnErrorLocation",0);
|
||||
|
||||
% Display BER
|
||||
disp(['BER benchmark: ', sprintf('%2E',ber_bm), ' ERRORS: ' ,num2str(sum(errors_bm))]);
|
||||
disp(['BER dc smooth (A1): ', sprintf('%2E',ber_dcsm), ' ERRORS: ' ,num2str(sum(errors_dcsm))]);
|
||||
disp(['BER lv smooth (A2): ', sprintf('%2E',ber_lvsm), ' ERRORS: ' ,num2str(sum(errors_lvsm))]);
|
||||
disp(['BER lv lowpas: ', sprintf('%2E',ber_lvlp), ' ERRORS: ' ,num2str(sum(errors_lvlp))]);
|
||||
|
||||
|
||||
%% Generate some Plots
|
||||
|
||||
if 1
|
||||
|
||||
% SCATTER
|
||||
col = cbrewer2('Paired',8);
|
||||
|
||||
xax = 1:Eq_out.length;
|
||||
|
||||
figure(3)
|
||||
sgtitle('')
|
||||
|
||||
subplot(1,3,1)
|
||||
hold on
|
||||
eq_decision = digimod.decide_pamlevel(Eq_out);
|
||||
true_symbols = digimod.decide_pamlevel(digimod_out);
|
||||
|
||||
xindices = 1:Eq_in.length;
|
||||
errorpos = find(loc~=0)*2;
|
||||
errorpos(errorpos>length(Eq_in.signal)) = length(Eq_in.signal);
|
||||
correct = find(loc==0)*2;
|
||||
correct(correct>length(Eq_in.signal)) = length(Eq_in.signal);
|
||||
scatter(xindices(correct),Eq_in.signal(correct),4,'.','MarkerEdgeColor',col(4,:),'DisplayName','After EQ');
|
||||
hold on
|
||||
scatter(xindices(errorpos),Eq_in.signal(errorpos),6,'x','MarkerEdgeColor',col(6,:),'DisplayName','Wrong Decision');
|
||||
hold off
|
||||
|
||||
xlim([1, xindices(end)]);
|
||||
ylim([-3 3]);
|
||||
xlabel('Sampling Index')
|
||||
ylabel('Amplitude')
|
||||
a = legend;
|
||||
a.Location = "best";
|
||||
|
||||
subplot(1,3,2)
|
||||
xindices = 1:Eq_out.length;
|
||||
xax_sec = (1:Eq_out.length) / fsym .* 1e6;
|
||||
scatter(xax_sec(loc==0),Eq_out.signal(loc==0),4,'.','MarkerEdgeColor',col(4,:),'DisplayName','After EQ');
|
||||
hold on
|
||||
scatter(xindices(loc~=0),Eq_out.signal(loc~=0),8,'x','MarkerEdgeColor',col(6,:),'DisplayName','Wrong Decision');
|
||||
hold off
|
||||
xlim([1, xax(end)]);
|
||||
ylim([-2 2]);
|
||||
xlabel('Sampling Index')
|
||||
ylabel('Amplitude')
|
||||
legend
|
||||
a = legend;
|
||||
a.Location = "best";
|
||||
hold off
|
||||
|
||||
subplot(1,3,3)
|
||||
xindices = 1:yk_lvsm.length;
|
||||
scatter(xindices(loc==0),yk_lvsm.signal(loc==0),4,'.','MarkerEdgeColor',col(4,:),'DisplayName','After A2');
|
||||
hold on
|
||||
scatter(xindices(loc~=0),yk_lvsm.signal(loc~=0),8,'x','MarkerEdgeColor',col(6,:),'DisplayName','Wrong Decision');
|
||||
hold off
|
||||
xlim([1, xax(end)]);
|
||||
ylim([-2 2]);
|
||||
xlabel('Sampling Index')
|
||||
ylabel('Amplitude')
|
||||
legend
|
||||
a = legend;
|
||||
a.Location = "best";
|
||||
hold off
|
||||
|
||||
|
||||
end
|
||||
|
||||
if 0
|
||||
col = cbrewer2('Paired',8);
|
||||
|
||||
figure(11)
|
||||
clf
|
||||
|
||||
subplot(2,1,1)
|
||||
hold on
|
||||
plot(digimod_out.signal(4150:4175),'DisplayName','Tx','Color',col(1,:),'LineWidth',3);
|
||||
plot(Eq_out.signal(4150:4175),'DisplayName','Rx after EQ','Color',col(6,:),'LineWidth',1);
|
||||
title('Modulated Sequence Zoom');
|
||||
legend
|
||||
hold off
|
||||
subplot(2,1,2)
|
||||
hold on
|
||||
stem(d_bm.signal(4150:4175,1),'DisplayName','Tx','Color',col(1,:),'LineStyle','-','LineWidth',5)
|
||||
stem(bitpattern(4150:4175,1)','DisplayName','Rx','Color',col(6,:),'LineStyle','--','LineWidth',2)
|
||||
title('Bitpattern Tx - Rx');
|
||||
legend
|
||||
hold off
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
198
projects/MPI_April/mpi_simulation_cspr.m
Normal file
198
projects/MPI_April/mpi_simulation_cspr.m
Normal file
@@ -0,0 +1,198 @@
|
||||
%% Settings
|
||||
clear
|
||||
|
||||
filename = '112G_2';
|
||||
load_sequence = 0;
|
||||
|
||||
M = 4;
|
||||
datarate = 112e9;
|
||||
|
||||
kover = 8;
|
||||
fsym = round(datarate*1e-9 / log2(M))*1e9;
|
||||
%fsym = 50e9;
|
||||
fdac = 256e9;
|
||||
fadc = 256e9;
|
||||
|
||||
laser_linewidth = 1e6;
|
||||
mpi_ = 50; %meter
|
||||
sir = 20; %decibel = attenuation of interference path
|
||||
|
||||
lowpass_cutoff = fsym/2 * 1;
|
||||
awg_bw = lowpass_cutoff;
|
||||
mod_bw = lowpass_cutoff;
|
||||
phd_bw = lowpass_cutoff;
|
||||
scp_bw = lowpass_cutoff;
|
||||
|
||||
mpi_path=50;
|
||||
|
||||
vp = [0.25];
|
||||
vb = [0.5:0.05:0.8];
|
||||
vb = 0.7;
|
||||
pn_key = [27];
|
||||
rop = -5;
|
||||
|
||||
LP_awg = Filter('filtdegree',2,"f_cutoff",awg_bw,"fs",fdac,"filterType","butterworth");
|
||||
LP_laser = Filter('filtdegree',4,"f_cutoff",mod_bw,"fs",fdac*kover,"filterType",filtertypes.gaussian);
|
||||
LP_opt = Filter('filtdegree',4,"f_cutoff",fsym/log2(M).*1.5,"fs",fdac*kover,"filterType",filtertypes.gaussian);
|
||||
LP_phd = Filter('filtdegree',2,"f_cutoff",phd_bw,"fs",fdac*kover,"filterType",filtertypes.butterworth);
|
||||
LP_scpe = Filter('filtdegree',2,"f_cutoff",scp_bw,"fs",fadc,"filterType","butterworth");
|
||||
|
||||
for pnk = 1:length(pn_key)
|
||||
for m = 1:length(vb)
|
||||
if load_sequence
|
||||
|
||||
load(['C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\MPI_April\',filename,'.mat'],'X');
|
||||
|
||||
spectrum_plot(X.signal',X.fs,'spectrum');
|
||||
else
|
||||
|
||||
% 1) PRBS Generation
|
||||
O = 17; %order of prbs
|
||||
N = 2^(O-1); %length of prbs
|
||||
[~,seed] = prbs(O,1); %initialize first seed of prbs
|
||||
bitpattern=[];
|
||||
for i = 1:log2(M)
|
||||
[bitpattern(:,i),seed] = prbs(O,N,seed);
|
||||
end
|
||||
|
||||
% 2 ) Build Inf. signal class
|
||||
bits = Informationsignal(bitpattern);
|
||||
|
||||
% 3) Digi modulation -> PAM-M signal
|
||||
digimod_out = PAMmapper(M,0).map(bits);
|
||||
digimod_out.fs = fsym;
|
||||
|
||||
X = Pulseformer("fsym",fsym,"fdac",fdac,"pulse","rrc","pulselength",16,"rrcalpha",0.01).process(digimod_out);
|
||||
|
||||
% 5) AWG (lowpass, quantization, sample and hold)
|
||||
%X = M8196A().process(X);
|
||||
kover = 16;
|
||||
X = AWG("fdac",fdac,"dac_min",-1,"dac_max",1,"H_lpf",LP_awg,"kover",kover).process(X);
|
||||
|
||||
% 6) Lowpass behavior before laser
|
||||
X = LP_laser.process(X);
|
||||
|
||||
% 7) Normalize signal
|
||||
X = X.normalize("mode","oneone");
|
||||
|
||||
%save(['C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\MPI_April\',char(filename)],'X');
|
||||
end
|
||||
|
||||
% 1) Laser; Modulation -> OPTICAL DOMAIN
|
||||
u_pi = 2;
|
||||
vbias = -vb(m)*u_pi;
|
||||
extmodlaser = EML("mode",eml_mode.im_cosinus,"power",3,"fsimu",X.fs,"lambda",1290,"bias",vbias,"u_pi",u_pi,"linewidth",laser_linewidth,"randomkey",pn_key(pnk));
|
||||
E = X.*vp(1);
|
||||
[Opt,extmodlaser] = extmodlaser.process(E);
|
||||
|
||||
% figure(m)
|
||||
% hold on
|
||||
% scatter(E.signal(1:100000),(abs(Opt.signal(1:100000)).^2)*1e3,0.1,'.','DisplayName','Modulator TF')
|
||||
% xlabel('Input in V')
|
||||
% ylabel('abs(Output) in mW')
|
||||
|
||||
Opt = LP_opt.process(Opt);
|
||||
|
||||
cspr(m) = Opt.cspr;
|
||||
|
||||
% 2) ping pong fiber propagation
|
||||
Interference_sig = Fiber("fsimu",Opt.fs,"fiber_length",mpi_path*2/1000,"alpha",0,"D",0,"lambda0",1310,"gamma",0).process(Opt);
|
||||
|
||||
Interference_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",-sir).process(Interference_sig);
|
||||
|
||||
% In the meantime: delay the main signal
|
||||
[Main_sig,n] = Opt.delay("delay_meter",mpi_path*2);
|
||||
|
||||
% Add
|
||||
Combined_sig = Main_sig + Interference_sig;
|
||||
|
||||
% Cut (due to the delays there is a jump in the signals)
|
||||
if n == 0;n = 1;end
|
||||
Combined_sig.signal = Combined_sig.signal(ceil(n):end);
|
||||
|
||||
% Fiber
|
||||
Combined_sig = Fiber("fsimu",Combined_sig.fs,"fiber_length",0,"alpha",0.3,"D",0,"lambda0",1310,"gamma",0,"Dslope",0.08).process(Combined_sig);
|
||||
|
||||
for i = 1:length(rop)
|
||||
|
||||
% Set ROP
|
||||
Rx_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",rop(i)).process(Combined_sig);
|
||||
rop_save(m,i) = Rx_sig.power;
|
||||
|
||||
% Square Law
|
||||
Rx_sig = Photodiode("fsimu",Rx_sig.fs,"dark_current",2e-08,"responsivity",1,"temperature",20).process(Rx_sig);
|
||||
|
||||
%Lowpass PhDiode
|
||||
Rx_sig = LP_phd.process(Rx_sig);
|
||||
|
||||
% Scope
|
||||
Rx_sig = Scope("fsimu",Rx_sig.fs,"fadc",fadc,...
|
||||
"delay",0,"fixed_delay",0,"lpf_bw",scp_bw,"filtertype",filtertypes.butterworth,...
|
||||
"samplingdelay",0,"rand_samplingdelay",0,"freq_offset",0,"samp_jitter",0,...
|
||||
"adcresolution",16,"quantbuffer",0.1,'block_dc',1,'lpf_active',1,'H_lpf',LP_scpe).process(Rx_sig);
|
||||
|
||||
% Sample to 2x fsym
|
||||
Rx_sig = Rx_sig.resample("fs_in",fadc,"fs_out",2*fsym);
|
||||
|
||||
% Sync Rx signal with reference
|
||||
[Rx_sig,D,cuts] = Rx_sig.tsynch("reference",digimod_out,"fs_ref",fsym);
|
||||
|
||||
% % simple EQ (optimum mudc: 0.05 -> 0.005)
|
||||
EQ_sig = EQ_silas_plain("Ne",[20,8,8],"Nb",[2,0,0],"trainlength",4096,"mu_dc_dd",0.005,"mu_dc_train",0.05,...
|
||||
"mu_ffe_train",0.005,"mu_combined_dd",[0.0004 0.0006 0.0003 0.005],"ddloops",3,'trainloops',3,'sps',2).process(Rx_sig,digimod_out);
|
||||
|
||||
% Demap
|
||||
Rx_Bits = PAMmapper(M,0).demap(EQ_sig);
|
||||
|
||||
Rx_symboldecision = PAMmapper(M,0).decide_pamlevel(EQ_sig,"symbol_levels",unique(digimod_out.signal));
|
||||
|
||||
levels = PAMmapper(M,0).separate_pamlevels(EQ_sig);
|
||||
level_avg(:,m,i) = mean(levels,'omitnan');
|
||||
level_std(:,m,i) = std(levels,'omitnan');
|
||||
|
||||
% BER
|
||||
[~,errors_bm,BER(m,i),errors] = calc_ber(Rx_Bits.signal,bitpattern,"skip_front",0,"skip_end",0,"returnErrorLocation",1);
|
||||
|
||||
formatted_ber = sprintf('%.1e', BER(m,i));
|
||||
disp(formatted_ber);
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
plot_analysis_window;
|
||||
save(['C:\Users\Silas\Nextcloud4\Dokumente\02_Ablage_Office\MPI\Investigation_April_2024\','PAM_',num2str(M),'_mpi_',num2str(mpi_path),'_lw_',num2str(laser_linewidth)],"BER");
|
||||
|
||||
% BER plot
|
||||
figure(340)
|
||||
cols = linspecer(7);
|
||||
for m = 1:size(BER,1)
|
||||
hold on
|
||||
plot(rop,BER(m,:),'DisplayName',['Bias: ',num2str(vb(m)), ' V'],'LineStyle','-','Color',cols(m,:),'LineWidth',1,'Marker','o','MarkerEdgeColor',[1 1 1],'MarkerFaceColor',cols(m,:));
|
||||
|
||||
end
|
||||
set(gca,'YScale','log');
|
||||
legend
|
||||
xlabel("ROP in dBm")
|
||||
yline(3.8e-3,'DisplayName','FEC');
|
||||
|
||||
|
||||
figure(21)
|
||||
hold on
|
||||
plot(rop,mean(BER),'DisplayName',['Modulation: ',num2str(2*vp/extmodlaser.u_pi*100), ' $\%$'],'LineStyle','-','Color',cols(2,:),'LineWidth',1);
|
||||
set(gca,'YScale','log');
|
||||
legend
|
||||
ylabel("ROP in dBm")
|
||||
yline(3.8e-3,'DisplayName','FEC');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%check Rx and TX symbols
|
||||
figure(101)
|
||||
scatter(1:100,Rx_symboldecision.signal(1:100),10,'o');
|
||||
hold on
|
||||
scatter(1:100,digimod_out.signal(1:100),5,'x');
|
||||
70
projects/MPI_April/plot_analysis_window.m
Normal file
70
projects/MPI_April/plot_analysis_window.m
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
%straight outta workspace, show everything I want
|
||||
|
||||
cols = linspecer(8);
|
||||
colpairs = cbrewer2('paired',8);
|
||||
|
||||
f=figure(20);
|
||||
clf(f)
|
||||
f.Name="Optspec";
|
||||
%Spectrum of Optical Signal after superposition
|
||||
subplot(3,2,1:2)
|
||||
spectrum_plot(Combined_sig.normalize("mode","rms").signal',Combined_sig.fs,'Optspec',['Papr: ',num2str(Combined_sig.papr), '; CSPR: ',num2str(Combined_sig.cspr)]);
|
||||
hold on
|
||||
ylim([-100,0]);
|
||||
|
||||
%Phase Investigation
|
||||
subplot(3,2,3)
|
||||
hold on
|
||||
phase_int = extmodlaser.phase(n:end);
|
||||
phase_main = delayseq(extmodlaser.phase,n);
|
||||
phase_main = phase_main(n:end);
|
||||
phase_diff = phase_int - phase_main;
|
||||
t = (1:length(phase_int))' ./ extmodlaser.fsimu ;
|
||||
plot(t*1e6,phase_int,'Color',colpairs(1,:),'DisplayName','Interferer Phase');
|
||||
plot(t*1e6,phase_main,'Color',colpairs(2,:),'DisplayName','Signal Phase (delayed)');
|
||||
plot(t*1e6,phase_diff,'Color',colpairs(4,:),'DisplayName','Delta Phase');
|
||||
legend
|
||||
|
||||
subplot(3,2,4)
|
||||
%Received Signal after Phdiode
|
||||
yyaxis left
|
||||
t = (1:Rx_sig.length)' ./ Rx_sig.fs;
|
||||
scatter(t*1e6,Rx_sig.normalize("mode","oneone").signal.*max(unique(digimod_out.signal)),1,'.','MarkerEdgeColor',cols(5,:));
|
||||
hold on
|
||||
errors_t = errors./Rx_Bits.fs;
|
||||
errors_sym = Rx_symboldecision.signal(errors);
|
||||
scatter(errors_t*1e6,errors_sym,2,'x','LineWidth',1);
|
||||
yline(PAMmapper(M,0).thresholds);
|
||||
|
||||
%Again: Phase Diff
|
||||
yyaxis right
|
||||
t = (1:length(phase_int))' ./ extmodlaser.fsimu ;
|
||||
plot(t*1e6,phase_diff,'Color',colpairs(4,:),'DisplayName','Delta Phase');
|
||||
|
||||
title(['Lwidth:',num2str(laser_linewidth) ,'; SIR: ', num2str(sir) ,'dB; ROP: ',num2str(rop(i)),' dBm'])
|
||||
xlabel('t in $\mu$s')
|
||||
legend
|
||||
|
||||
%Equalized Signal
|
||||
subplot(3,2,5)
|
||||
t = (1:EQ_sig.length)' ./ EQ_sig.fs;
|
||||
for h = 1:size(levels,2)
|
||||
scatter(t*1e6,levels(:,h),1,'.');
|
||||
hold on
|
||||
end
|
||||
yline(PAMmapper(M,0).thresholds);
|
||||
title(['BER: ',sprintf('%.1e', BER(m,i))]);
|
||||
|
||||
%Histogram of EQzed Signal
|
||||
subplot(3,2,6)
|
||||
for h = 1:size(levels,2)
|
||||
std_dev = std(levels(:,h),'omitnan');
|
||||
mean_val = mean(levels(:,h),'omitnan');
|
||||
hold on
|
||||
histogram(levels(:,h),1000,"EdgeColor","none","Normalization","pdf");
|
||||
text(mean_val, 0.1, ['$\sigma^2:$ ',sprintf('%.2f', std_dev)], 'HorizontalAlignment', 'center');
|
||||
end
|
||||
hold on
|
||||
xline(PAMmapper(M,0).thresholds);
|
||||
xticks(sort([unique(digimod_out.signal);PAMmapper(M,0).thresholds']));
|
||||
55
projects/MPI_April/simulate_tx_sig.m
Normal file
55
projects/MPI_April/simulate_tx_sig.m
Normal file
@@ -0,0 +1,55 @@
|
||||
function simulate_tx_sig(filename)
|
||||
|
||||
%% Params
|
||||
M=4;
|
||||
digimod = PAMmapper(M,0);
|
||||
|
||||
fdac = 120e9;
|
||||
fsym = 112e9;
|
||||
pulseform = Pulseformer("pulseform","rrc","fdac",fdac,"fsym",fsym,"pulselength",32,"rrcalpha",0.027);
|
||||
|
||||
kover = 16;
|
||||
awg = AWG('fdac',fdac,'kover',kover,'lpf_active',1,'f_cutoff',56e9,'lpf_type',filtertypes.gaussian,'bit_resolution',5.5);
|
||||
%awg = M8199B();
|
||||
|
||||
lp_laser = Filter('filtdegree',2,"f_cutoff",50e9,"fsamp",fdac*kover,"filterType",filtertypes.butterworth);
|
||||
|
||||
|
||||
|
||||
%% PROCESS TX
|
||||
|
||||
% 1) PRBS Generation
|
||||
O = 20; %order of prbs
|
||||
N = 2^(O-1); %length of prbs
|
||||
[~,seed] = prbs(O,1); %initialize first seed of prbs
|
||||
for i = 1:log2(M)
|
||||
[bitpattern(:,i),seed] = prbs(O,N,seed);
|
||||
end
|
||||
|
||||
% 2 ) Build Inf. signal class
|
||||
bits = Informationsignal(bitpattern);
|
||||
|
||||
% 3) Digi modulation -> PAM-M signal
|
||||
digimod_out = digimod.map(bits);
|
||||
|
||||
% 4) Pulse shaping -> racos
|
||||
X = pulseform.process(digimod_out);
|
||||
|
||||
% 5) AWG (lowpass, quantization, sample and hold)
|
||||
X = awg.process(X);
|
||||
|
||||
% 6) Lowpass behavior before laser
|
||||
X = lp_laser.process(X);
|
||||
|
||||
% 7) Normalize signal
|
||||
X = X.normalize("mode","oneone");
|
||||
X.signal = X.signal;
|
||||
|
||||
spectrum_plot(X.signal',X.fs,'spectrum');
|
||||
|
||||
if nargin == 1
|
||||
save(['C:\Users\Silas\Documents\MATLAB\imdd_simulation\projects\',char(filename)],'X');
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
444
projects/MPI_offline_analysis/mpi_analysis_pam4.m
Normal file
444
projects/MPI_offline_analysis/mpi_analysis_pam4.m
Normal file
@@ -0,0 +1,444 @@
|
||||
|
||||
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
|
||||
|
||||
|
||||
% SETTINGS
|
||||
|
||||
optimize_mudc = 0;
|
||||
run_sir_sweep = 0;
|
||||
run_feed_forward = 1;
|
||||
run_baseline = 0;
|
||||
run_ideal_dc_tap = 0;
|
||||
plot_timesignal = 1;
|
||||
|
||||
block_loop = [1];
|
||||
|
||||
for bl = 1:numel(block_loop)
|
||||
|
||||
eq_parallelization_blocklength = block_loop(bl);
|
||||
eq_updatelatency = 3;
|
||||
eq_avg_blocklength =0;
|
||||
|
||||
% FIND BEST MU DC
|
||||
|
||||
if optimize_mudc
|
||||
mudc_loop = [0, 0.0001,0.0005, 0.001,0.005, 0.01:0.01:0.1, 0.2:0.1:1];
|
||||
|
||||
current_filename = 'pam4__loop_14_92Gbd_19092023_1513.mat';
|
||||
current_filename = 'pam4__loop_29_56Gbd_19092023_1546.mat';
|
||||
recorded_data = load([foldername,filesep, current_filename]);
|
||||
|
||||
[best_mudc,ber]= optimizeMuDc(recorded_data,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength,mudc_loop);
|
||||
|
||||
% figure(16)
|
||||
% hold on
|
||||
% plot(mudc_loop,ber);
|
||||
% set(gca, 'YScale', 'log');
|
||||
% set(gca, 'XScale', 'log');
|
||||
% scatter(best_mudc,ber(mudc_loop==best_mudc),100,'Marker','x','LineWidth',2)
|
||||
% yline(ber(1));
|
||||
% xlim([0,1])
|
||||
end
|
||||
|
||||
if run_sir_sweep
|
||||
|
||||
mudc = best_mudc;
|
||||
[ber,sir,fsym] = runSIRsweep(eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength,mudc);
|
||||
|
||||
plotSirSweep(ber,sir,fsym,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength,mudc)
|
||||
|
||||
crossing = calculateCrossing([92e9, 56e9],ber,sir,fsym);
|
||||
|
||||
req_sir_56(bl) = crossing(2,2) ;
|
||||
req_sir_92(bl) = crossing(2,1) ;
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
if run_feed_forward
|
||||
|
||||
current_filename = 'pam4__loop_14_92Gbd_v19092023_1513.mat';
|
||||
recorded_data = load([foldername,filesep, current_filename]);
|
||||
eq_avg_blocklength = [50,100,1000,3000];
|
||||
[best_block,ber]= optimizeAvgBlocklength(recorded_data,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength,0);
|
||||
|
||||
|
||||
best_block = 400;
|
||||
|
||||
[ber_base,sir_base,fsym_base] = runSIRsweep(eq_parallelization_blocklength,eq_updatelatency,best_block,0);
|
||||
|
||||
plotSirSweep(ber_base,sir_base,fsym_base,eq_parallelization_blocklength,eq_updatelatency,best_block,0)
|
||||
|
||||
crossing = calculateCrossing([92e9, 56e9],ber_base,sir_base,fsym_base);
|
||||
|
||||
[ber_base,sir_base,fsym_base] = runSIRsweep(eq_parallelization_blocklength,eq_updatelatency,0,0);
|
||||
|
||||
plotSirSweep(ber_base,sir_base,fsym_base,eq_parallelization_blocklength,eq_updatelatency,0,0)
|
||||
|
||||
crossing = calculateCrossing([92e9, 56e9],ber_base,sir_base,fsym_base);
|
||||
|
||||
end
|
||||
|
||||
|
||||
if run_baseline
|
||||
|
||||
mudc = 0;
|
||||
[ber_base,sir_base,fsym_base] = runSIRsweep(eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength,mudc);
|
||||
|
||||
plotSirSweep(ber_base,sir_base,fsym_base,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength,mudc)
|
||||
|
||||
crossing = calculateCrossing([92e9, 56e9],ber_base,sir_base,fsym_base);
|
||||
|
||||
req_sir_56_baseline = crossing(2,2) ;
|
||||
req_sir_92_baseline = crossing(2,1) ;
|
||||
|
||||
end
|
||||
|
||||
if run_ideal_dc_tap
|
||||
|
||||
current_filename = 'pam4__loop_29_56Gbd_19092023_1546.mat';
|
||||
recorded_data = load([foldername,filesep, current_filename]);
|
||||
[mudc,~]= optimizeMuDc(recorded_data,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength,mudc_loop);
|
||||
|
||||
eq_parallelization_blocklength = 1;
|
||||
eq_updatelatency = 1;
|
||||
[ber_ideal,sir_ideal,fsym_ideal] = runSIRsweep(eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength,mudc);
|
||||
|
||||
plotSirSweep(ber_ideal,sir_ideal,fsym_ideal,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength,mudc)
|
||||
|
||||
crossing = calculateCrossing([92e9, 56e9],ber_ideal,sir_ideal,fsym_ideal);
|
||||
|
||||
req_sir_56_ideal = crossing(2,2) ;
|
||||
req_sir_92_ideal = crossing(2,1) ;
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
if plot_timesignal
|
||||
|
||||
current_filename = 'pam4__loop_26_92Gbd_19092023_1542.mat';
|
||||
recorded_data = load([foldername,filesep, current_filename]);
|
||||
|
||||
sir = recorded_data.saveStructTemp.awg2scope_keysight_state.eigenlight_mpi - 3.3 + 7.2;
|
||||
|
||||
fsym = 92e9;
|
||||
eq_parallelization_blocklength = 1;
|
||||
eq_updatelatency = 1;
|
||||
eq_avg_blocklength = 0;
|
||||
|
||||
% TRUE SYMBOLS
|
||||
correct_symbols = recorded_data.saveStructTemp.digi_mod_out';
|
||||
|
||||
%3) PLAIN RECEIVED SIGNAL
|
||||
disp('RX Signal')
|
||||
y_rx = Electricalsignal(recorded_data.saveStructTemp.dp_tsynch_out');
|
||||
y_rx.fs = 2.*fsym;
|
||||
rx_symbols = y_rx.resample("fs_in",2.*fsym,"fs_out",fsym);
|
||||
rx_symbols = rx_symbols.normalize("mode","rms").signal;
|
||||
disp(std(rx_symbols));
|
||||
scatterleveldependent(rx_symbols,correct_symbols,fsym);
|
||||
|
||||
%1) PLOT WITH WITH ALGORITHM
|
||||
if 0
|
||||
mudc_loop = [0, 0.0001,0.0005, 0.001,0.005, 0.01:0.01:0.1, 0.2:0.1:1];
|
||||
[mudc,~]= optimizeMuDc(recorded_data,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength,mudc_loop);
|
||||
end
|
||||
|
||||
disp('ALGORITHM ')
|
||||
mudc = 0.05;
|
||||
results_alg = runPostProcessing(recorded_data,mudc,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength);
|
||||
disp(results_alg.ber);
|
||||
rx_symbols = results_alg.EQ_out.signal;
|
||||
disp(std(rx_symbols));
|
||||
scatterleveldependent(rx_symbols,correct_symbols,fsym);
|
||||
|
||||
%2) JUST EQ
|
||||
disp('Just EQ')
|
||||
mudc = 0;
|
||||
results = runPostProcessing(recorded_data,mudc,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength);
|
||||
disp(results.ber)
|
||||
rx_symbols = results.EQ_out.signal;
|
||||
disp(std(rx_symbols));
|
||||
scatterleveldependent(rx_symbols,correct_symbols,fsym);
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
function plotSirSweep(ber,sir,fsym,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength,mudc)
|
||||
|
||||
|
||||
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; mudc: ',num2str(mudc)],'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 [crossing] = calculateCrossing(rate,ber,sir,fsym)
|
||||
|
||||
for r = 1:length(rate)
|
||||
sorted = sortrows([sir(fsym == rate(r)); ber(fsym == rate(r))]',1)';
|
||||
berVals = sorted(2,:);
|
||||
xAxis = sorted(1,:);
|
||||
|
||||
hdfec = 3.8e-3 .* ones(1,length(sorted));
|
||||
crossing(:,r) = InterX([hdfec(:)';xAxis],[berVals;xAxis]) ;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function [ber,sir,fsym] = runSIRsweep(eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength,mudc)
|
||||
|
||||
% GENERATE SIR CURVE
|
||||
if ismac
|
||||
foldername = '/Users/silasoettinghaus/Documents/MATLAB/Labor_Datensatz_PAM4_MPI/pam4_10km_1km';
|
||||
else
|
||||
foldername = 'C:\Users\Silas\Documents\MATLAB\Labor_Datensatz_PAM4_MPI\pam4_10km_1km';
|
||||
end
|
||||
|
||||
allfiles = dir(foldername);
|
||||
|
||||
parfor i = 1:length(allfiles)
|
||||
|
||||
if allfiles(i).bytes ~= 0
|
||||
current_filename = allfiles(i).name;
|
||||
recorded_data = load([foldername,filesep, current_filename]);
|
||||
else
|
||||
continue
|
||||
end
|
||||
|
||||
results = runPostProcessing(recorded_data,mudc,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength);
|
||||
ber(i) = results.ber;
|
||||
fsym(i) = results.fsym;
|
||||
sir(i) = results.sir
|
||||
|
||||
disp(['fsym: ',num2str(results.fsym*1e-9),'GBd, SIR: ',num2str(results.sir),' ->> BER: ',sprintf('%2E',results.ber)]);
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
function [best_blocklength,ber] = optimizeAvgBlocklength(recorded_data,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength_loop,mudc)
|
||||
|
||||
for j = 1:length(eq_avg_blocklength_loop)
|
||||
eq_avg_blocklength = eq_avg_blocklength_loop(j);
|
||||
|
||||
|
||||
results = runPostProcessing(recorded_data,mudc,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength);
|
||||
ber(j) = results.ber;
|
||||
|
||||
disp(['fsym: ',num2str(results.fsym*1e-9),'GBd, SIR: ',num2str(results.sir),' ->> BER: ',sprintf('%2E',results.ber)]);
|
||||
|
||||
end
|
||||
|
||||
[~,pos]=min(ber);
|
||||
best_blocklength = eq_avg_blocklength_loop(pos);
|
||||
|
||||
end
|
||||
|
||||
function [best_mudc,ber] = optimizeMuDc(recorded_data,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength,mudc_loop)
|
||||
|
||||
parfor j = 1:length(mudc_loop)
|
||||
mudc = mudc_loop(j);
|
||||
|
||||
|
||||
results = runPostProcessing(recorded_data,mudc,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength);
|
||||
ber(j) = results.ber;
|
||||
|
||||
disp(['fsym: ',num2str(results.fsym*1e-9),'GBd, SIR: ',num2str(results.sir),' ->> BER: ',sprintf('%2E',results.ber)]);
|
||||
|
||||
end
|
||||
|
||||
[~,pos]=min(ber);
|
||||
best_mudc = mudc_loop(pos);
|
||||
|
||||
end
|
||||
|
||||
function results = runPostProcessing(recorded_data,mudc,eq_parallelization_blocklength,eq_updatelatency,eq_avg_blocklength)
|
||||
|
||||
results.sir = recorded_data.saveStructTemp.awg2scope_keysight_state.eigenlight_mpi - 3.3 + 7.2;
|
||||
results.fsym = recorded_data.saveStructTemp.common.f_sym;
|
||||
|
||||
results.fdac = recorded_data.saveStructTemp.common.f_DAC;
|
||||
results.fadc = recorded_data.saveStructTemp.common.f_ADC;
|
||||
|
||||
|
||||
% 0) build RX Signal
|
||||
y_rx = Electricalsignal(recorded_data.saveStructTemp.dp_tsynch_out');
|
||||
y_rx.fs = 2.*results.fsym;
|
||||
|
||||
% 0) build tx reference Signal for eq training
|
||||
y_digimod = Electricalsignal(recorded_data.saveStructTemp.digi_mod_out');
|
||||
y_digimod.fs = results.fsym;
|
||||
|
||||
|
||||
% 1) normlaize
|
||||
y_rx = y_rx.normalize("mode","rms");
|
||||
|
||||
eq = 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",eq_avg_blocklength);
|
||||
|
||||
[Eq_out] = eq.process(y_rx,y_digimod);
|
||||
|
||||
results.EQ_out = Eq_out;
|
||||
|
||||
% 3) digital demodulation object
|
||||
digimod = PAMmapper(2^recorded_data.saveStructTemp.common.M,0);
|
||||
|
||||
%estimated/ equalized symbol sequence
|
||||
d_estimated = digimod.demap(Eq_out);
|
||||
|
||||
%correct data symbols
|
||||
d_correct = recorded_data.saveStructTemp.prms_out;
|
||||
|
||||
% 4) BER calculation
|
||||
[totalbits,errors,results.ber,loc] = calc_ber(d_estimated.signal(1:end,:) ,d_correct(1:end,:)',"skip",0,"returnErrorLocation",1);
|
||||
end
|
||||
|
||||
function std_per_lvl = calcleveldependentstd(rx_symbols,correct_symbols)
|
||||
error_of_rx_signal = rx_symbols - correct_symbols;
|
||||
levels = unique(correct_symbols);
|
||||
for l = 1:4
|
||||
level_amplitude = levels(l);
|
||||
std_per_lvl(l) = var(( 1/64 .* movsum(error_of_rx_signal(correct_symbols==level_amplitude),[64/2,64/2]) ));
|
||||
%std_per_lvl(l) = std(error_of_rx_signal(correct_symbols==level_amplitude));
|
||||
end
|
||||
end
|
||||
|
||||
function scatterleveldependent(rx_symbols,correct_symbols,f_sym)
|
||||
col = cbrewer2('Paired',8);
|
||||
ccnt = -1;
|
||||
figure1 = figure();
|
||||
levels = unique(correct_symbols);
|
||||
|
||||
start = 1;
|
||||
ende = length(correct_symbols);
|
||||
|
||||
start = 30000;
|
||||
ende = 40000;
|
||||
|
||||
for l = 1:4
|
||||
ccnt = ccnt+2;
|
||||
|
||||
level_amplitude = levels(l);
|
||||
|
||||
symbols_for_lvl = NaN(1,length(correct_symbols));
|
||||
symbols_for_lvl(correct_symbols==level_amplitude) = rx_symbols(correct_symbols==level_amplitude);
|
||||
std_lvl(l) = std(symbols_for_lvl,'omitnan');
|
||||
xax_in_sec = ((1:length(correct_symbols)) / f_sym) * 1e6;
|
||||
xax_in_sec = 1:length(correct_symbols);
|
||||
|
||||
scatter(xax_in_sec(start:ende),symbols_for_lvl(start:ende),10,'.','MarkerFaceAlpha',0.5,'MarkerEdgeAlpha',0.5,'MarkerEdgeColor',col(ccnt,:));
|
||||
hold on;
|
||||
end
|
||||
|
||||
std_lvl = round(std_lvl,2);
|
||||
disp(std_lvl);
|
||||
|
||||
ccnt = 0;
|
||||
|
||||
% Add the windowed/ smoothed curves
|
||||
for l = 1:4
|
||||
ccnt = ccnt+2;
|
||||
level_amplitude = levels(l);
|
||||
|
||||
symbols_for_lvl = NaN(1,length(correct_symbols));
|
||||
|
||||
movmean = 1/250 .* movsum(rx_symbols(correct_symbols==level_amplitude),[250/2,250/2]);
|
||||
|
||||
symbols_for_lvl(correct_symbols==level_amplitude) = movmean;
|
||||
|
||||
nanx = isnan(symbols_for_lvl);
|
||||
t = 1:numel(symbols_for_lvl);
|
||||
symbols_for_lvl(nanx) = interp1(t(~nanx), symbols_for_lvl(~nanx), t(nanx));
|
||||
|
||||
xax_in_sec = ((1:length(correct_symbols)) / f_sym) * 1e6;
|
||||
xax_in_sec = 1:length(correct_symbols);
|
||||
|
||||
plot(xax_in_sec(start:ende),symbols_for_lvl(start:ende),'Color',col(ccnt,:));
|
||||
hold on
|
||||
end
|
||||
|
||||
%yline(max(rx_symbols(correct_symbols==levels(2))))
|
||||
|
||||
if 0
|
||||
annotation(figure1,'textbox',...
|
||||
[0.660523809523809 0.844444444444448 0.133523809523809 0.0603174603174607],...
|
||||
'String',['\sigma = ',num2str(std_lvl(4))],...
|
||||
'LineWidth',1.8,...
|
||||
'LineStyle','none',...
|
||||
'FontSize',12,...
|
||||
'FitBoxToText','off');
|
||||
|
||||
% Create textbox
|
||||
annotation(figure1,'textbox',...
|
||||
[0.667666666666665 0.642857142857147 0.133523809523809 0.0603174603174607],...
|
||||
'String',['\sigma = ',num2str(std_lvl(3))],...
|
||||
'LineWidth',1.8,...
|
||||
'LineStyle','none',...
|
||||
'FontSize',12,...
|
||||
'FitBoxToText','off');
|
||||
|
||||
% Create textbox
|
||||
annotation(figure1,'textbox',...
|
||||
[0.671238095238093 0.442857142857148 0.133523809523809 0.0603174603174608],...
|
||||
'String',['\sigma = ',num2str(std_lvl(2))],...
|
||||
'LineWidth',1.8,...
|
||||
'LineStyle','none',...
|
||||
'FontSize',12,...
|
||||
'FitBoxToText','off');
|
||||
|
||||
% Create textbox
|
||||
annotation(figure1,'textbox',...
|
||||
[0.670047619047616 0.265079365079371 0.133523809523809 0.0603174603174608],...
|
||||
'String',['\sigma = ',num2str(std_lvl(1))],...
|
||||
'LineWidth',1.8,...
|
||||
'LineStyle','none',...
|
||||
'FontSize',12,...
|
||||
'FitBoxToText','off');
|
||||
end
|
||||
|
||||
xlim([0, 2.6])
|
||||
ylim([-2 2])
|
||||
xlabel('Time in $\mu$s');
|
||||
ylabel('Normalized Amplitude');
|
||||
|
||||
end
|
||||
|
||||
|
||||
188
projects/MPI_offline_analysis/mpi_analysis_pam4_old_notworking.m
Normal file
188
projects/MPI_offline_analysis/mpi_analysis_pam4_old_notworking.m
Normal file
@@ -0,0 +1,188 @@
|
||||
|
||||
|
||||
|
||||
% parfsym = zeros(length(mudc_loop),length(allfiles));
|
||||
% parsir = zeros(length(mudc_loop),length(allfiles));
|
||||
% ber_wo_reduction = zeros(length(mudc_loop),length(allfiles));
|
||||
% ber_w_dcremoval = zeros(length(mudc_loop),length(allfiles));
|
||||
% mudc = zeros(length(mudc_loop),length(allfiles));
|
||||
% blocklen = zeros(length(mudc_loop),length(allfiles));
|
||||
|
||||
% parameters.mudc = [0, 0.0001,0.0005, 0.001,0.005, 0.01:0.01:0.1, 0.2:0.1:1];
|
||||
% parameters.eq_parallelization_blocklength = [1];
|
||||
% parameters.eq_updatelatency = [1];
|
||||
% parameters.eq_avg_blocklength =[0];
|
||||
block_loop = [1];
|
||||
|
||||
for j = 1:length(mudc_loop)
|
||||
|
||||
mudc_current = mudc_loop(j);
|
||||
block_current = block_loop(1);
|
||||
|
||||
parfor i = 1:length(allfiles)
|
||||
|
||||
if 1
|
||||
|
||||
if allfiles(i).bytes ~= 0
|
||||
current_filename = allfiles(i).name;
|
||||
else
|
||||
continue
|
||||
end
|
||||
|
||||
else
|
||||
%
|
||||
% current_filename = 'pam4__loop_29_56Gbd_19092023_1546.mat';
|
||||
% current_filename = 'pam4__loop_30_92Gbd_19092023_1547.mat';
|
||||
%
|
||||
current_filename = 'pam4__loop_13_56Gbd_19092023_1512.mat';
|
||||
current_filename = 'pam4__loop_14_92Gbd_19092023_1513.mat';
|
||||
|
||||
end
|
||||
|
||||
% load dataset
|
||||
recorded_data = load([foldername,filesep, current_filename]);
|
||||
% get common variables of simulation loop
|
||||
|
||||
%even if redundant, save stuff to results struct
|
||||
parsir(j,i) = recorded_data.saveStructTemp.awg2scope_keysight_state.eigenlight_mpi - 3.3 + 7.2;
|
||||
parfsym(j,i) = recorded_data.saveStructTemp.common.f_sym;
|
||||
|
||||
fdac = recorded_data.saveStructTemp.common.f_DAC;
|
||||
fadc = recorded_data.saveStructTemp.common.f_ADC;
|
||||
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 = Electricalsignal(recorded_data.saveStructTemp.digi_mod_out');
|
||||
y_digimod.fs = fsym;
|
||||
|
||||
rx_symbols = y_rx.resample("fs_in",2.*fsym,"fs_out",fsym);
|
||||
rx_symbols = rx_symbols.normalize("mode","rms").signal;
|
||||
correct_symbols = recorded_data.saveStructTemp.digi_mod_out';
|
||||
|
||||
% scatterleveldependent(rx_symbols,correct_symbols,parfsym(j,i));
|
||||
% title([num2str(fsym.*1e-9),' GBd; SIR: ',num2str(parsir(j,i)),' dB']);
|
||||
|
||||
% if parfsym(j,i) == 56e9
|
||||
% deviation56(i) = var(( 1/500 .* movsum(y_rx.signal,[500/2,500/2]) ));
|
||||
% sir56(i) = simdata.saveStructTemp.awg2scope_keysight_state.eigenlight_mpi - 3.3 + 7.2;
|
||||
% std56(i,:) = calcleveldependentstd(rx_symbols,correct_symbols);
|
||||
% else
|
||||
% deviation92(i) = var(( 1/500 .* movsum(y_rx.signal,[500/2,500/2]) ));
|
||||
% sir92(i) = simdata.saveStructTemp.awg2scope_keysight_state.eigenlight_mpi - 3.3 + 7.2;
|
||||
% std92(i,:) = calcleveldependentstd(rx_symbols,correct_symbols);
|
||||
% end
|
||||
|
||||
% 1) normlaize
|
||||
y_rx = y_rx.normalize("mode","rms");
|
||||
|
||||
eq = EQ_silas("Ne",[25,0,0],"Nb",[2,0,0],"trainlength",4096,...
|
||||
"sps",2,...
|
||||
"mu_dc_dd",mudc_current,...
|
||||
"mu_dc_train",mudc_current,...
|
||||
"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",block_current, ...
|
||||
"eq_updatelatency",3,...
|
||||
"eq_avg_blocklength",10000);
|
||||
|
||||
[Eq_out] = eq.process(y_rx,y_digimod);
|
||||
|
||||
% 2.2) MPI reduction blocks
|
||||
|
||||
% 3) digital demodulation
|
||||
digimod = PAMmapper(2^recorded_data.saveStructTemp.common.M,0);
|
||||
|
||||
d_hat = digimod.demap(Eq_out);
|
||||
|
||||
d_ = digimod.demap(Electricalsignal(recorded_data.saveStructTemp.digi_mod_out'));
|
||||
d = recorded_data.saveStructTemp.prms_out;
|
||||
|
||||
% scatterleveldependent(Eq_out.signal,correct_symbols,parfsym(j,i));
|
||||
% title([num2str(fsym.*1e-9),' GBd; SIR: ',num2str(parsir(j,i)),' dB']);
|
||||
|
||||
% 4) BER calculation
|
||||
[totalbits,errors_bm,ber_dhat,loc] = calc_ber(d_hat.signal(1:end,:) ,d(1:end,:)',"skip",0,"returnErrorLocation",1);
|
||||
|
||||
ber_nodctap = mean(recorded_data.saveStructTemp.prms_compare_state.BER );
|
||||
|
||||
disp(['fsym: ',num2str(parfsym(j,i).*1e-9),'GBd, SIR: ',num2str(parsir(j,i)),' ->> BER_new: ',sprintf('%2E',ber_dhat),' BER_old: ',sprintf('%2E',ber_nodctap)]);
|
||||
|
||||
% 5) save to struct
|
||||
|
||||
ber_wo_reduction(j,i) = ber_nodctap;
|
||||
ber_w_dcremoval(j,i) = ber_dhat;
|
||||
mudc(j,i) = eq.mu_dc_dd;
|
||||
blocklen(j,i) = eq.eq_parallelization_blocklength;
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
rate = [92e9, 56e9];
|
||||
figure(95)
|
||||
col = cbrewer2('Paired',8);
|
||||
for r = 1:length(rate)
|
||||
for j = 1:length(mudc_loop)
|
||||
|
||||
|
||||
if mudc_loop(j) == 0
|
||||
lnsty = '--';
|
||||
|
||||
mark = 'square';
|
||||
|
||||
else
|
||||
lnsty = "-";
|
||||
|
||||
mark = 'v';
|
||||
end
|
||||
|
||||
if r == 1
|
||||
handlvis = 'on';
|
||||
colr = col(6,:);
|
||||
else
|
||||
handlvis = 'off';
|
||||
colr = col(8,:);
|
||||
end
|
||||
|
||||
%plot curve of standard FFE+DFE
|
||||
if j == 1
|
||||
load(['C:\Users\Silas\Nextcloud4\Dokumente\02_Ablage_Office\OFC2024\',num2str(rate(r).*1e-9),'GBd_no_dcs.mat'],'b');
|
||||
plot(abs(b(1,:)),b(2,:),'DisplayName',[num2str(rate(r).*1e-9),' GBd; PAM4; mudc: ',0],'LineWidth',1,'Marker','o','MarkerSize',5,'LineStyle',lnsty,'HandleVisibility',handlvis,'Color',colr);
|
||||
end
|
||||
|
||||
hold on
|
||||
b = [parsir(j,parfsym(j,:)==rate(r));ber_w_dcremoval(j,parfsym(j,:)==rate(r))];
|
||||
b=sort(b,2);
|
||||
plot(abs(b(1,:)),b(2,:),'DisplayName',[num2str(rate(r).*1e-9),' GBd; PAM4; mudc: ',num2str(mudc_loop(j))],'LineWidth',1,'Marker',mark,'MarkerSize',5,'LineStyle',lnsty,'HandleVisibility',handlvis,'Color',colr);
|
||||
|
||||
end
|
||||
end
|
||||
set(gca, 'YScale', 'log');
|
||||
yline(3.8e-3,'LineWidth',1, 'LineStyle','--','HandleVisibility','off');
|
||||
xlim([15,35]);
|
||||
xlabel('SIR in dB');
|
||||
ylabel('BER');
|
||||
annotation('textbox',...
|
||||
[0.328380952380952 0.477777777777781 0.197809523809524 0.106349206349207],...
|
||||
'String',{'3.8 $\cdot 10^{-3}$'},...
|
||||
'LineStyle','none',...
|
||||
'Interpreter','latex',...
|
||||
'FitBoxToText','off');
|
||||
|
||||
% legend('Standard EQ','Adaptive DC Subtraction')
|
||||
|
||||
figure(16)
|
||||
hold on
|
||||
plot(mudc_loop,ber_w_dcremoval(:,1));set(gca, 'YScale', 'log');set(gca, 'XScale', 'log');
|
||||
xlim([0,1])
|
||||
Reference in New Issue
Block a user