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
|
||||
|
||||
Reference in New Issue
Block a user