384 lines
13 KiB
Matlab
384 lines
13 KiB
Matlab
|
|
|
|
lw = [0.1e6 1e6 10e6];
|
|
|
|
for lp = 1
|
|
|
|
rng(9);
|
|
|
|
%% A) Set Simulation Variables
|
|
|
|
sir = -18;
|
|
delay = 10; %mpi delay in meter
|
|
|
|
fiblen = 0; %main link in km
|
|
|
|
laser_linewidth =5e6;
|
|
|
|
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",[30,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',3);
|
|
|
|
|
|
%% 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_mtr = (1:X.length) / fsimu * (physconst("LightSpeed")/1.4677);
|
|
% thresh = 0.7;
|
|
% phaseX = phase(X.signal);
|
|
% phaseR = phase(R.signal);
|
|
% phasediff = wrapToPi(phaseX-phaseR);
|
|
% [pos_high] = find(abs(phasediff)>thresh);
|
|
% [pos_low] = find(abs(phasediff)<=thresh);
|
|
%
|
|
% figure()
|
|
% subplot(3,1,1)
|
|
% scatter(xax_mtr,wrapToPi(phaseX),4,'.','MarkerEdgeColor',col(4,:),'DisplayName','Phase of original Signal')
|
|
% hold on
|
|
% scatter(xax_mtr,wrapToPi(phaseR),4,'.','MarkerEdgeColor',col(7,:),'DisplayName','Phase of delayed Signal')
|
|
% hold on
|
|
% xline(delay,'LineWidth',4,'LineStyle','--','HandleVisibility','off')
|
|
% lg = legend;
|
|
% lg.Location = "southwest";
|
|
%
|
|
% subplot(3,1,2)
|
|
% scatter(xax_mtr(pos_low),phasediff(pos_low),4,'.','MarkerEdgeColor',col(6,:),'DisplayName','Phase Difference')
|
|
% hold on
|
|
% scatter(xax_mtr(pos_high),phasediff(pos_high),4,'.','MarkerEdgeColor',col(4,:),'HandleVisibility','off')
|
|
% xline(delay,'LineWidth',4,'LineStyle','--','HandleVisibility','off')
|
|
% yline(thresh,'LineWidth',2,'LineStyle','-','HandleVisibility','off')
|
|
% yline(-thresh,'LineWidth',2,'LineStyle','-','HandleVisibility','off')
|
|
% lg = legend;
|
|
% lg.Location = "southwest";
|
|
|
|
X = X+R;
|
|
|
|
% subplot(3,1,3)
|
|
% scatter(xax_mtr(pos_low),abs(X.signal(pos_low).^2),4,'.','MarkerEdgeColor',col(6,:),'DisplayName','Constructive Interference');
|
|
% hold on
|
|
% scatter(xax_mtr(pos_high),abs(X.signal(pos_high).^2),4,'.','MarkerEdgeColor',col(4,:),'DisplayName','Destructive Interference');
|
|
% xline(delay,'LineWidth',4,'LineStyle','--','HandleVisibility','off')
|
|
%
|
|
% lg = legend;
|
|
% lg.Location = "southwest";
|
|
|
|
X.signal = X.signal(n:end);
|
|
R.signal = R.signal(n:end);
|
|
|
|
|
|
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] = 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
|
|
|
|
% 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;
|
|
scatter(xindices(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
|
|
|
|
|
|
% ERROR IN EQ
|
|
figure(13)
|
|
plot((eq2.error_log(1,:)),'DisplayName','First iteration DD mode','Linewidth',0.5);
|
|
hold on;
|
|
for i = 1:size(eq2.error_log,1)
|
|
plot((eq2.error_log(i,:)),'Linewidth',0.5);
|
|
end
|
|
loc(loc==0) = NaN;
|
|
stem(loc.*mean((eq2.error_log(end,:))),'DisplayName','Error Positions')
|
|
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
|
|
|
|
|
|
|