Scattered stuff from Silas during Dissertation

This commit is contained in:
Silas Oettinghaus
2026-06-03 09:05:33 +02:00
parent a91da3b97c
commit 5c2e27687d
37 changed files with 1726 additions and 1338 deletions

View File

@@ -0,0 +1,257 @@
% Minimal IMDD model for investigating FFE noise enhancement.
% Parameters mirror the current IMDD_base_system/imdd_it.m,
% IMDD_base_system/imdd_model.m, and the FFE branch in dsp_scope_signal.m.
clearvars;
close all;
%% Sweep parameters from imdd_it.m
fsym_values = (152:16:200).*1e9;
precomp = 0;
laser_wavelength = 1310;
M = 4;
link_length = 2;
channel_alpha = 0.5;
duob_mode = db_mode.db_precoded;
decoding_mode = db_decoder.sequencedetection;
channel_mode = channel_model.physical;
channel_snr_dB = 20;
rop_values = -8:2:4;
%% Inner model parameters from imdd_model.m
bitrate = [];
apply_pulsef = 0;
fdac = 256e9;
fadc = 256e9;
random_key = 1;
rcalpha = 0.05;
kover = 16;
vbias_rel = 0.5;
u_pi = 3;
vbias = -vbias_rel*u_pi;
laser_linewidth = 0;
eml_alpha = 0;
len_tr = 4096*2;
pf_ncoeffs = 1;
mu_dc = 0.005;
nRates = numel(fsym_values);
nRops = numel(rop_values);
eq_names = ["FFE","VNLE"];
nEqs = numel(eq_names);
emptyResult = struct("fsym",[],"ROP",[],"equalizer",[],"BER",[],"SNR",[],"numBitErr",[], ...
"eq_noise",[],"eq_signal_sd",[],"eq",[],"Rx_sig",[],"Tx_sig",[],"Tx_symbols",[]);
results = repmat(emptyResult,nRates,nRops,nEqs);
cols = flip(cbrewer2('RdYlBu',nRates+4));
midIdx = floor(size(cols,1)/2) + (-1:2);
cols(midIdx,:) = [];
for i = 1:numel(fsym_values)
fsym = fsym_values(i);
fprintf("Running %.0f GBd (%d/%d)\n", fsym*1e-9, i, numel(fsym_values));
if isempty(bitrate)
bitrateCurrent = fsym * log2(M);
end
Pform = Pulseformer("fsym",fsym,"fdac",4*fsym,"pulse","rc","pulselength",16,"alpha",rcalpha);
[Digi_sig, Symbols, ~] = PAMsource( ...
"fsym",fsym,"M",M,"order",18,"useprbs",0, ...
"fs_out",fdac, ...
"applyclipping",0,"clipfactor",1.5, ...
"applypulseform",apply_pulsef,"pulseformer",Pform, ...
"randkey",random_key, ...
"duobinary_mode",duob_mode, ...
"mrds_code",0,"mrds_blocklength",512).process();
rateResults = repmat(emptyResult,nRops,nEqs);
Tx_sig = Digi_sig;
El_sig = M8199B("kover",kover).process(Digi_sig);
tx_bwl = 85e9;
El_sig = Filter("filtdegree",4,"f_cutoff",tx_bwl,"fs",fdac*kover, ...
"filterType",filtertypes.bessel_inp,"active",true).process(El_sig);
El_sig = El_sig.normalize("mode","oneone");
scaling = 0.7*(u_pi/2-abs(vbias-u_pi/2));
El_sig = El_sig .* scaling;
Opt_sig = EML("mode",eml_mode.im_cosinus,"power",3,"fsimu",El_sig.fs, ...
"lambda",laser_wavelength,"bias",vbias,"u_pi",u_pi, ...
"linewidth",laser_linewidth,"randomkey",random_key+1, ...
"alpha",eml_alpha).process(El_sig);
Opt_sig = Fiber("fsimu",Opt_sig.fs,"fiber_length",link_length, ...
"alpha",0.3,"D",0,"lambda0",1310,"gamma",0,"Dslope",0.07).process(Opt_sig);
parfor j = 1:nRops
rop = rop_values(j);
fprintf(" ROP %.1f dBm (%d/%d)\n", rop, j, nRops);
Rx_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power", ...
"amplification_db",rop).process(Opt_sig);
Rx_sig = Photodiode("fsimu",fdac*kover,"dark_current",2e-08, ...
"responsivity",0.6,"temperature",20,"nep",1.8e-11).process(Rx_sig);
rx_bwl = 90e9;
Rx_sig = Filter("filtdegree",4,"f_cutoff",rx_bwl,"fs",fdac*kover, ...
"filterType",filtertypes.butterworth,"active",true).process(Rx_sig);
Lp_scpe = Filter("filtdegree",4,"f_cutoff",110e9,"fs",fadc, ...
"filterType",filtertypes.butterworth,"active",true);
Rx_sig = Scope("fsimu",fdac*kover,"fadc",fadc, ...
"delay",0,"fixed_delay",0,"filtertype",filtertypes.butterworth, ...
"samplingdelay",0,"rand_samplingdelay",0,"freq_offset",0, ...
"samp_jitter",0,"adcresolution",8,"quantbuffer",0.1, ...
"block_dc",1,"lpf_active",1,"H_lpf",Lp_scpe).process(Rx_sig);
txPulseformer = [];
if apply_pulsef
txPulseformer = Pform;
end
Scpe_sig = preprocessSignal(Rx_sig, Symbols, fsym, ...
"mode","auto", ...
"tx_pulseformer",txPulseformer, ...
"debug_plots",0);
Scpe_sig.signal = Scpe_sig.signal(1:2*Symbols.length);
Scpe_sig.signal = real(Scpe_sig.signal);
for k = 1:nEqs
switch eq_names(k)
case "FFE"
eq_ = FFE("epochs_tr",5,"epochs_dd",5,"len_tr",len_tr, ...
"mu_dd",1e-1,"mu_tr",0.4,"order",50, ...
"sps",2,"decide",0,"optmize_mus",1,"dd_mode",1, ...
"adaption_technique","nlms","mu_dc",1.021e-05);
case "VNLE"
eq_ = VNLE("epochs_tr",5,"epochs_dd",5,"len_tr",len_tr, ...
"mu_dd",[0.0004 0.0005 0.0006],"mu_tr",0, ...
"order",[25,2,2],"sps",2,"decide",0, ...
"optmize_mus",1,"mu_dc",0.1);
end
[eq_signal_sd, eq_noise] = eq_.process(Scpe_sig, Symbols);
eq_signal_hd = PAMmapper(M,0).quantize(eq_signal_sd);
rx_bits = PAMmapper(M,0).demap(eq_signal_hd);
tx_bits_demapped = PAMmapper(M,0).demap(Symbols);
[~, errors, ber] = calc_ber(rx_bits.signal, tx_bits_demapped.signal, ...
"skip_front",10,"skip_end",10);
localResult = emptyResult;
localResult.fsym = fsym;
localResult.ROP = rop;
localResult.equalizer = eq_names(k);
localResult.BER = ber;
localResult.SNR = snr(eq_signal_sd.signal, eq_noise.signal);
localResult.numBitErr = errors;
localResult.eq_noise = eq_noise;
localResult.eq_signal_sd = eq_signal_sd;
localResult.eq = eq_;
localResult.Rx_sig = Rx_sig;
localResult.Tx_sig = Tx_sig;
localResult.Tx_symbols = Symbols;
rateResults(j,k) = localResult;
end
end
results(i,:,:) = reshape(rateResults,1,nRops,nEqs);
end
%% Plot section
close all
berGrid = reshape([results.BER],nRates,nRops,nEqs);
figure(400);
clf;
for k = 1:nEqs
subplot(1,nEqs,k);
plot(fsym_values.*1e-9, berGrid(:,:,k), "LineWidth",0.8, ...
"LineStyle","-","Marker",".","MarkerSize",15);
set(gca,"YScale","log");
grid on;
grid minor;
xlabel("Symbol rate (GBd)");
ylabel("BER");
title(eq_names(k) + " BER vs. Symbol Rate");
legend(compose("ROP %.1f dBm",rop_values),"Location","best");
end
%%
figure(500);
clf;
for k = 1:nEqs
subplot(1,nEqs,k);
plot(rop_values, berGrid(:,:,k).', "LineWidth",0.8, ...
"LineStyle","-","Marker",".","MarkerSize",15);
set(gca,"YScale","log");
grid on;
grid minor;
xlabel("ROP");
ylabel("BER");
title(eq_names(k) + " BER vs. ROP");
legend(compose("%.0f GBd",fsym_values.*1e-9),"Location","best");
end
%%
plotResults = reshape(results(:,end,:),nRates,nEqs);
for k = 1:nEqs
for i = 1:nRates
fsym = plotResults(i,k).fsym;
eq_noise = plotResults(i,k).eq_noise;
eq_signal_sd = plotResults(i,k).eq_signal_sd;
Rx_sig = plotResults(i,k).Rx_sig;
Tx_sig = plotResults(i,k).Tx_sig;
Tx_symbols = plotResults(i,k).Tx_symbols;
displayName = sprintf('%s, %d GBd, ROP %.1f dBm',plotResults(i,k).equalizer,fsym.*1e-9,plotResults(i,k).ROP);
showEQNoisePSD(eq_noise, "fignum", 1, "displayname", displayName,"color",cols(i,:));
xlim([0, 120])
% mat2tikz_improved("C:/Users/Silas/Documents/6971e0b65b380ca6d71c837f/03_DSP_Techniques/tikz/ffe_noise_enhancement/noise_psd.tex")
Tx_sig.normalize("mode","rms").spectrum("displayname",displayName,'fignum',2,'normalizeTo0dB',0,"color",cols(i,:),"linestyle",'-','HandleVisibility','on');
xlim([0, 120])
% mat2tikz_improved("C:/Users/Silas/Documents/6971e0b65b380ca6d71c837f/03_DSP_Techniques/tikz/ffe_noise_enhancement/tx_signals.tex")
Rx_sig.normalize("mode","rms").spectrum("displayname",displayName,'fignum',3,'normalizeTo0dB',0,"color",cols(i,:));
xlim([0, 120])
% mat2tikz_improved("C:/Users/Silas/Documents/6971e0b65b380ca6d71c837f/03_DSP_Techniques/tikz/ffe_noise_enhancement/rx_signals.tex")
showEQNoiseSNR(eq_signal_sd, eq_noise,"displayname",displayName,"color",cols(i,:),"fignum",4);
xlim([0, 120])
% mat2tikz_improved("C:/Users/Silas/Documents/6971e0b65b380ca6d71c837f/03_DSP_Techniques/tikz/ffe_noise_enhancement/snr_after_ffe.tex")
% showEQfilter(plotResults(i,k).eq.e, eq_signal_sd.fs.*2,"displayname",displayName,'fignum',5,"color",cols(i,:));
% xlim([0, 120]);
fprintf('%s BER %.2e \n',plotResults(i,k).equalizer,plotResults(i,k).BER)
if i == 1 || i == nRates-1 || i == nRates
show2Dconstellation(PAMmapper(M,0).get_scaling.*eq_signal_sd.signal(1:end), PAMmapper(M,0).get_scaling.*Tx_symbols.signal(1:end), ...
"displayname",displayName, ...
"fignum",5+(k-1)*nRates+i, ...
"clear",i == 1 && k == 1,"rasterize", false);
mat2tikz_improved(sprintf("C:/Users/Silas/Documents/6971e0b65b380ca6d71c837f/03_DSP_Techniques/tikz/ffe_noise_enhancement/noise_correlation_%s.tex",displayName),"cleanfigure",true);
eq_signal_sd.eye(fsym,M,"fignum",8+(k-1)*nRates+i,"mode",1);
end
end
end
%%

View File

@@ -0,0 +1,66 @@
% Build convolution matrix and solve c such that conv(x,c) approx delta
x = [0.05; -0.12; 0.3; 1; 0.25; -0.1; 0.04]; % channel pulse response
Ntaps = 7;
mu = 0.002;
Nit = 500;
[c, hhist] = peakDistEqualizer(x, Ntaps, mu, Nit);
h_eff = conv(x,c);
stem(h_eff)
grid on
xlabel('Sample index')
ylabel('Combined impulse response')
function [c, h_hist] = peakDistEqualizer(x, Ntaps, mu, Nit)
% Peak-distortion / Lucky sign-gradient equalizer
%
% x : sampled channel pulse response, main cursor should be near center
% Ntaps : odd number of equalizer taps
% mu : step size
% Nit : number of training iterations
%
% c : equalizer coefficients
% h : combined impulse response h = conv(x,c)
x = x(:);
assert(mod(Ntaps,2)==1, 'Ntaps must be odd');
midTap = (Ntaps+1)/2;
c = zeros(Ntaps,1);
c(midTap) = 1; % start with through connection
h_hist = cell(Nit,1);
for it = 1:Nit
h = conv(x,c);
h_hist{it} = h;
% locate main cursor
[~, mainIdx] = max(abs(h));
% normalize main cursor conceptually
h = h / h(mainIdx);
% update non-center equalizer taps
for j = 1:Ntaps
if j == midTap
continue
end
% map equalizer tap j to corresponding ISI sample
isiIdx = mainIdx + (j - midTap);
if isiIdx >= 1 && isiIdx <= length(h)
c(j) = c(j) - mu * sign(h(isiIdx));
end
end
% optional: normalize center/main gain
h = conv(x,c);
[~, mainIdx] = max(abs(h));
c = c / h(mainIdx);
end
end