Many changes for 400G DSP
Minimal Example ...
This commit is contained in:
175
projects/A_minimal_example/imdd_simulation_minimal.m
Normal file
175
projects/A_minimal_example/imdd_simulation_minimal.m
Normal file
@@ -0,0 +1,175 @@
|
||||
function [ber] = imdd_simulation_minimal(varargin)
|
||||
% BASIC IMDD Model...
|
||||
|
||||
% varargin is either empty or a struct, i.e.:
|
||||
% optionalvars = struct('bitrate',300e9,'M',6);
|
||||
% then:
|
||||
% imdd_simulation_minimal(optionalvars)
|
||||
% replaces the respective variables -> nice for looping parameter sets
|
||||
|
||||
curFolder = pwd;
|
||||
funcFolder=fileparts(mfilename('fullpath'));
|
||||
if ~isempty(funcFolder)
|
||||
cd(funcFolder);
|
||||
end
|
||||
|
||||
% TX
|
||||
M = 4;
|
||||
fsym = 112e9;
|
||||
apply_pulsef = 1;
|
||||
fdac = 256e9;
|
||||
fadc = 256e9;
|
||||
random_key = 1;
|
||||
db_precode = 0;
|
||||
db_encode = 0;
|
||||
rcalpha = 0.05;
|
||||
kover = 16;
|
||||
vbias_rel = 0.5;
|
||||
u_pi = 2.9;
|
||||
vbias = -vbias_rel*u_pi;
|
||||
|
||||
laser_wavelength = 1310;
|
||||
laser_linewidth = 0;
|
||||
tx_bw_nyquist = 0.95;
|
||||
|
||||
% Channel
|
||||
link_length = 1; %km
|
||||
|
||||
% RX
|
||||
rop = -7;
|
||||
rx_bw_nyquist = 0.9;
|
||||
|
||||
% EQ
|
||||
vnle_order=[50,7,7];
|
||||
dfe_order = [2 0 0];
|
||||
|
||||
len_tr = 4096*2;
|
||||
mu_ffe = [0.0004 0.0004 0.0004];
|
||||
mu_dfe = 0.0004;
|
||||
mu_dc = 0.00;
|
||||
|
||||
% Replace optional input arguments if there are any
|
||||
if ~isempty(varargin)
|
||||
var_s = varargin{1};
|
||||
if isstruct(var_s)
|
||||
fields = fieldnames(var_s);
|
||||
for i = 1:numel(fields)
|
||||
eval([fields{i}, ' = ', num2str( var_s.(fields{i}) ), ';']);
|
||||
fprintf("%s <-- %.2f \n", fields{i}, var_s.(fields{i}));
|
||||
end
|
||||
else
|
||||
error('Optional variables should be passed as a struct.');
|
||||
end
|
||||
end
|
||||
|
||||
fsym_ = floor( bitrate*1e-9./log2(M) ).*1e9;
|
||||
if fsym_ ~= fsym
|
||||
fsym = fsym_;
|
||||
fprintf('Adapted symbolrate to %d GBd, to match provided bitrate of %d GBit/s using PAM %d \n',fsym.*1e-9,bitrate.*1e-9, M);
|
||||
end
|
||||
f_nyquist = fsym/2;
|
||||
|
||||
%%%% TX Signal
|
||||
Pform = Pulseformer("fsym",fsym,"fdac",4*fsym,"pulse","rrc","pulselength",16,"rrcalpha",rcalpha);
|
||||
|
||||
[Digi_sig,Tx_symbols,Tx_bits] = PAMsource(...
|
||||
"fsym",fsym,"M",M,"order",18,"useprbs",1,...
|
||||
"fs_out",fdac,...
|
||||
"applyclipping",0,"clipfactor",1.5,...
|
||||
"applypulseform",apply_pulsef,"pulseformer",Pform,...
|
||||
"randkey",random_key,...
|
||||
"db_precode",db_precode,"db_encode",db_encode,...
|
||||
"mrds_code",0,"mrds_blocklength",512).process();
|
||||
|
||||
Digi_sig.spectrum("displayname",'Digital Spectrum at TX','fignum',10,'normalizeTo0dB',1);
|
||||
|
||||
%%%%% AWG
|
||||
% El_sig = M8199A("kover",kover).process(Digi_sig);
|
||||
El_sig = AWG("fdac",fdac,"f_cutoff",fsym,"lpf_active",1,"kover",kover,"bit_resolution",12).process(Digi_sig);
|
||||
% El_sig.spectrum("displayname",'Digi Spectrum','fignum',100,'normalizeTo0dB',0);
|
||||
El_sig = El_sig.setPower(0,"dBm");
|
||||
|
||||
El_sig.eye(fsym,M,"fignum",11,'displayname','Rx Eye');
|
||||
|
||||
%%%%% Low-pass el. components %%%%%%
|
||||
El_sig = Filter('filtdegree',4,"f_cutoff",75e9,"fs",fdac*kover,"filterType",filtertypes.butterworth,"active",true).process(El_sig);
|
||||
|
||||
%%%%% Electrical Driver Amplifier %%%%%%
|
||||
El_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",3).process(El_sig);
|
||||
|
||||
%%%%% MODULATE E/O CONVERSION %%%%%%
|
||||
[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).process(El_sig);
|
||||
|
||||
%%%%%% Fiber %%%%%%
|
||||
Opt_sig = Fiber("fsimu",Opt_sig.fs,"fiber_length",link_length/1000,"alpha",0.3,"D",0,"lambda0",1310,"gamma",0,"Dslope",0.07).process(Opt_sig);
|
||||
|
||||
%%%%%% ROP %%%%%%
|
||||
Rx_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",rop).process(Opt_sig);
|
||||
|
||||
%%%%%% PD Square Law %%%%%%
|
||||
Rx_sig = Photodiode("fsimu",fdac*kover,"dark_current",2e-08,"responsivity",1,"temperature",20,"nep",1.8e-11).process(Rx_sig);
|
||||
|
||||
Rx_sig.eye(fsym,M,"fignum",30,'displayname','Rx Eye');
|
||||
|
||||
%%%%%% Low-pass RX (PD, El. Connectors and Scope %%%%%%
|
||||
Rx_sig = Filter('filtdegree',4,"f_cutoff",75e9,"fs",fdac*kover,"filterType",filtertypes.butterworth,"active",true).process(Rx_sig);
|
||||
|
||||
%%%%%% Low-pass inside Scope %%%%%%
|
||||
Lp_scpe = Filter('filtdegree',4,"f_cutoff",110e9,"fs",fadc,"filterType",filtertypes.butterworth,"active",true);
|
||||
|
||||
%%%%%% Scope %%%%%%
|
||||
Scpe_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);
|
||||
|
||||
Scpe_sig.spectrum("displayname",'Digital (256 GSa/s) Rx Spectrum','fignum',10,'normalizeTo0dB',1);
|
||||
|
||||
Scpe_sig.normalize("mode","rms").plot("displayname",'Digital (256 GSa/s) Rx Spectrum','fignum',21,'clear',1);
|
||||
|
||||
%%%%%% Sample to 2x fsym %%%%%%
|
||||
Scpe_sig = Scpe_sig.resample("fs_in",fadc,"fs_out",2*fsym);
|
||||
|
||||
%%%%%% Sync Rx signal with reference %%%%%%
|
||||
[Scpe_sig,S] = Scpe_sig.tsynch("reference",Tx_symbols,"fs_ref",fsym);
|
||||
|
||||
|
||||
%%% EQUALIZING
|
||||
|
||||
%FFE or VNLE
|
||||
[Eq_signal,Eq_noise] = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1).process(Scpe_sig,Tx_symbols);
|
||||
|
||||
Rx_bits = PAMmapper(M,0).demap(Eq_signal);
|
||||
|
||||
[~,numErrors,ber,~] = calc_ber(Rx_bits.signal,Tx_bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
|
||||
|
||||
Eq_signal.normalize("mode","rms").plot("displayname",'Digital (256 GSa/s) Rx Spectrum','fignum',21,'clear',0);
|
||||
|
||||
%%% Visualize EQ Stuff
|
||||
|
||||
figure(40);
|
||||
clf
|
||||
title(sprintf('PAM %d after EQ ; BER: %1.2e',M, ber ));
|
||||
constellation = unique(Tx_symbols.signal);
|
||||
received = NaN(numel(constellation),length(Tx_symbols));
|
||||
for lvl = 1:numel(constellation)
|
||||
%Separate the equalized signal into the
|
||||
%respective levels based on the actually
|
||||
%transmitted level!
|
||||
received(lvl,Tx_symbols.signal==constellation(lvl)) = Eq_signal.signal(Tx_symbols.signal==constellation(lvl));
|
||||
intermediate = received(lvl,:);
|
||||
cnt(lvl) = numel(intermediate(~isnan(intermediate)));
|
||||
hold on
|
||||
histogram(received(lvl,:),1000,"EdgeAlpha",0,'DisplayName',['Lvl ',num2str(lvl),' | ',num2str(cnt(lvl)),' entries']);
|
||||
end
|
||||
legend
|
||||
|
||||
fprintf('BER: %.2e \n',ber);
|
||||
|
||||
autoArrangeFigures;
|
||||
|
||||
if ~isempty(curFolder)
|
||||
cd(curFolder);
|
||||
end
|
||||
|
||||
end
|
||||
23
projects/A_minimal_example/run_loops.m
Normal file
23
projects/A_minimal_example/run_loops.m
Normal file
@@ -0,0 +1,23 @@
|
||||
uloops = struct;
|
||||
uloops.bitrate = [300,330,360,390,420,450,480].*1e9;
|
||||
uloops.M = [4,6,8];
|
||||
|
||||
wh = DataStorage(uloops);
|
||||
wh.addStorage("ber");
|
||||
|
||||
fprintf("Let's simulate %d configuratiuons! \n",wh.getLastLinIndice);
|
||||
|
||||
wh = submit_simulations(wh,"parallel",1);
|
||||
|
||||
for m_ = uloops.M
|
||||
ber_row = wh.getStoValue('ber', uloops.bitrate,m_);
|
||||
|
||||
figure(2024)
|
||||
hold on
|
||||
plot(uloops.bitrate.*1e-9,ber_row,'DisplayName',sprintf('PAM %d',m_));
|
||||
end
|
||||
|
||||
yline(3.8e-3,'LineWidth',2,'DisplayName','3.8e-3');
|
||||
yline(2e-2,'LineWidth',2,'LineStyle','--','DisplayName','2e-2');
|
||||
beautifyBERplot()
|
||||
legend
|
||||
72
projects/A_minimal_example/submit_simulations.m
Normal file
72
projects/A_minimal_example/submit_simulations.m
Normal file
@@ -0,0 +1,72 @@
|
||||
function wh = submit_simulations(wh,options)
|
||||
|
||||
arguments
|
||||
wh
|
||||
options.parallel = 1;
|
||||
end
|
||||
|
||||
%%% 2) SUBMIT SIMULATION
|
||||
% Initialize job results
|
||||
if options.parallel
|
||||
if isempty(gcp('nocreate'))
|
||||
parpool;
|
||||
end
|
||||
results = parallel.FevalFuture.empty();
|
||||
else
|
||||
results = [];
|
||||
end
|
||||
|
||||
|
||||
lin_idx = 1;
|
||||
for lin_idx = 1:wh.getLastLinIndice
|
||||
optionalVars = struct();
|
||||
if ~isempty(wh.getDimension)
|
||||
% Build the optionalVars struct
|
||||
[parametervalues,parameternames]=wh.getPhysIndicesByLinIndex(lin_idx);
|
||||
for pidx = 1:numel(parameternames)
|
||||
optionalVars.(parameternames{pidx}) = parametervalues{pidx};
|
||||
end
|
||||
end
|
||||
|
||||
%%% SIMULATION HERE
|
||||
if options.parallel
|
||||
|
||||
numOutputs = 1;
|
||||
results(lin_idx) = parfeval(@imdd_simulation_minimal, numOutputs, optionalVars);
|
||||
|
||||
else
|
||||
|
||||
finalresults{lin_idx} = imdd_simulation_minimal(optionalVars);
|
||||
wh.addValueToStorageByLinIdx(finalresults{lin_idx}, 'ber', lin_idx);
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
if options.parallel
|
||||
|
||||
%%% 4) Setup waitbar
|
||||
h = waitbar(0, 'Processing Simulations...');
|
||||
% Helper function to compute progress
|
||||
updateWaitbar = @(~) waitbar(mean(arrayfun(@(f) strcmp(f.State, 'finished'), results)), h);
|
||||
|
||||
fprintf('Fetching results... \n');
|
||||
|
||||
% Update the waitbar after each simulation
|
||||
updateWaitbarFutures = afterEach(results, updateWaitbar, 0);
|
||||
|
||||
% Close the waitbar after all simulations complete
|
||||
afterAll(updateWaitbarFutures, @(~) delete(h), 0);
|
||||
|
||||
%%% 7) Fetch final results after all computations
|
||||
fetchOutputs(results);
|
||||
|
||||
for ridx = 1:length(results)
|
||||
wh.addValueToStorageByLinIdx(results(ridx).OutputArguments{1}, 'ber', ridx);
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -0,0 +1,150 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 1365 313" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;">
|
||||
<g transform="matrix(1,0,0,1,-350.052,-234.682)">
|
||||
<g id="g40994" transform="matrix(3.14734,0,0,3.14734,-400.995,-235.585)">
|
||||
<path id="rect40684" d="M277.516,207.069C277.516,206.587 277.125,206.197 276.643,206.197L240.002,206.197C239.52,206.197 239.129,206.587 239.129,207.069L239.129,243.711C239.129,244.192 239.52,244.583 240.002,244.583L276.643,244.583C277.125,244.583 277.516,244.192 277.516,243.711L277.516,207.069Z" style="fill:none;stroke:black;stroke-width:1px;"/>
|
||||
<g id="g40700" transform="matrix(1,0,0,1,53.6992,6.29287)">
|
||||
<path id="path40686" d="M211.915,223.139L198.35,223.139L201.742,217.266L205.133,211.392L208.524,217.266L211.915,223.139Z" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:1px;"/>
|
||||
<path id="path40688" d="M205.133,223.139L205.133,230.555" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:1px;"/>
|
||||
<path id="path40690" d="M205.133,211.392L205.133,205.096" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:1px;"/>
|
||||
<path id="path40694" d="M198.143,211.392L212.123,211.392" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:1px;"/>
|
||||
</g>
|
||||
<g id="path40702" transform="matrix(0.317729,-0,-0,0.317729,238.629,149.417)">
|
||||
<path d="M82.941,200.888L86.409,190.917L76.351,194.125C79.689,194.169 82.984,197.55 82.941,200.888Z" style="fill:rgb(255,0,0);fill-rule:nonzero;"/>
|
||||
<path d="M80.998,196.189C77.477,199.62 73.535,203.461 73.535,203.461" style="fill:none;fill-rule:nonzero;stroke:rgb(255,0,0);stroke-width:3.15px;"/>
|
||||
</g>
|
||||
<g id="path40702-1" transform="matrix(0.317729,-0,-0,0.317729,238.629,149.417)">
|
||||
<path d="M102.022,200.888L105.49,190.917L95.433,194.125C98.771,194.169 102.066,197.55 102.022,200.888Z" style="fill:rgb(255,0,0);fill-rule:nonzero;"/>
|
||||
<path d="M100.08,196.189C96.559,199.62 92.617,203.461 92.617,203.461" style="fill:none;fill-rule:nonzero;stroke:rgb(255,0,0);stroke-width:3.15px;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g id="g40994-4" transform="matrix(3.07687,0,0,3.07687,-308.034,-474.106)">
|
||||
<g id="g41806">
|
||||
<path id="path41709" d="M272.852,307.633L280.529,307.633L288.207,302.14L295.884,302.141L303.561,307.633L311.239,307.633" style="fill:none;fill-rule:nonzero;stroke:rgb(2,0,0);stroke-width:1px;"/>
|
||||
<path id="path41709-4" d="M272.852,307.633L280.529,307.633L288.207,313.126L295.884,313.126L303.561,307.633L311.239,307.633" style="fill:none;fill-rule:nonzero;stroke:rgb(2,0,0);stroke-width:1px;"/>
|
||||
</g>
|
||||
<path id="rect40684-3" d="M311.239,289.332C311.239,288.84 310.839,288.44 310.346,288.44L273.745,288.44C273.252,288.44 272.852,288.84 272.852,289.332L272.852,325.934C272.852,326.427 273.252,326.827 273.745,326.827L310.346,326.827C310.839,326.827 311.239,326.427 311.239,325.934L311.239,289.332Z" style="fill:none;stroke:rgb(2,0,0);stroke-width:1px;"/>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,462.763,-27.6418)">
|
||||
<g id="g42228" transform="matrix(3.07687,0,0,3.07687,-770.796,-623.629)">
|
||||
<path id="rect40684-3-5" d="M311.239,289.332C311.239,288.84 310.839,288.44 310.346,288.44L273.745,288.44C273.252,288.44 272.852,288.84 272.852,289.332L272.852,325.934C272.852,326.427 273.252,326.827 273.745,326.827L310.346,326.827C310.839,326.827 311.239,326.427 311.239,325.934L311.239,289.332Z" style="fill:none;stroke:rgb(2,0,0);stroke-width:1px;"/>
|
||||
</g>
|
||||
<g transform="matrix(0.916758,0,0,0.916758,-209.942,-134.558)">
|
||||
<g transform="matrix(36.36,0,0,36.36,410.943,511.232)">
|
||||
</g>
|
||||
<text x="325.44px" y="511.232px" style="font-family:'ArialMT', 'Arial';font-size:36.36px;">A<tspan x="348.342px 382.661px " y="511.232px 511.232px ">WG</tspan></text>
|
||||
</g>
|
||||
</g>
|
||||
<g id="use14586" transform="matrix(4.16667,0,0,4.16667,538.992,319.037)">
|
||||
<g id="path38721" transform="matrix(1.27892,-0.000404508,-0.000404508,1,-27.2331,0.0394952)">
|
||||
<path d="M71.975,37.134L122.852,37.061" style="fill:none;fill-rule:nonzero;stroke:rgb(255,0,0);stroke-width:0.73px;"/>
|
||||
</g>
|
||||
<circle id="circle38723" cx="90.574" cy="26.615" r="10.503" style="fill:none;stroke:rgb(255,0,0);stroke-width:0.73px;"/>
|
||||
<circle id="circle38725" cx="96.619" cy="26.638" r="10.503" style="fill:none;stroke:rgb(255,0,0);stroke-width:0.73px;"/>
|
||||
<circle id="circle38727" cx="102.664" cy="26.594" r="10.503" style="fill:none;stroke:rgb(255,0,0);stroke-width:0.73px;"/>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,-180.978,231.592)">
|
||||
<g transform="matrix(1.12196,0,0,1.12196,-146.494,-56.6939)">
|
||||
<circle cx="974.409" cy="265.748" r="29.528" style="fill:white;stroke:rgb(255,0,0);stroke-width:2.67px;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g transform="matrix(1.16567,-0.0445706,-0.0445706,1.1674,-141.533,6.43198)">
|
||||
<g transform="matrix(0.859131,0.032801,0.032801,0.857855,577.71,19.194)">
|
||||
<path d="M441.614,202.956L452.737,201.256L451.254,212.411L441.614,202.956Z" style="fill:rgb(255,0,0);"/>
|
||||
<path d="M382.592,272.779C382.592,272.779 431.613,222.795 447.694,206.398" style="fill:none;stroke:rgb(255,0,0);stroke-width:3px;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,-20.5026,130.73)">
|
||||
<text x="933.238px" y="184.877px" style="font-family:'ArialMT', 'Arial';font-size:33.333px;">P</text>
|
||||
<g transform="matrix(20.8333,0,0,20.8333,1016.86,184.877)">
|
||||
</g>
|
||||
<text x="955.471px" y="184.877px" style="font-family:'ArialMT', 'Arial';font-size:20.833px;">launch</text>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,350.518,231.592)">
|
||||
<g transform="matrix(1.12196,0,0,1.12196,-146.494,-56.6939)">
|
||||
<circle cx="974.409" cy="265.748" r="29.528" style="fill:white;stroke:rgb(255,0,0);stroke-width:2.67px;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g transform="matrix(1.16567,-0.0445706,-0.0445706,1.1674,-141.533,6.43198)">
|
||||
<g transform="matrix(0.859131,0.032801,0.032801,0.857855,121.085,1.76038)">
|
||||
<path d="M973.11,202.956L984.233,201.256L982.75,212.411L973.11,202.956Z" style="fill:rgb(255,0,0);"/>
|
||||
<path d="M914.089,272.779C914.089,272.779 963.109,222.795 979.19,206.398" style="fill:none;stroke:rgb(255,0,0);stroke-width:3px;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,-20.5026,130.73)">
|
||||
<text x="937.937px" y="184.877px" style="font-family:'ArialMT', 'Arial';font-size:33.333px;">PD</text>
|
||||
<g transform="matrix(20.8333,0,0,20.8333,1000.46,184.877)">
|
||||
</g>
|
||||
<text x="984.242px" y="184.877px" style="font-family:'ArialMT', 'Arial';font-size:20.833px;">in</text>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(1.04523e-16,1.70851,-1.55299,9.48961e-17,2134.48,-837.195)">
|
||||
<path d="M767.327,630.707L794.304,673.144L740.349,673.144L767.327,630.707Z" style="fill:none;stroke:rgb(255,20,3);stroke-width:1.84px;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
<g id="g409941" serif:id="g40994" transform="matrix(3.07687,0,0,3.07687,681.554,-221.053)">
|
||||
<path id="rect406841" serif:id="rect40684" d="M277.516,207.089C277.516,206.596 277.116,206.197 276.623,206.197L240.022,206.197C239.529,206.197 239.129,206.596 239.129,207.089L239.129,243.691C239.129,244.183 239.529,244.583 240.022,244.583L276.623,244.583C277.116,244.583 277.516,244.183 277.516,243.691L277.516,207.089Z" style="fill:none;stroke:black;stroke-width:1px;"/>
|
||||
<g id="g407001" serif:id="g40700" transform="matrix(1,0,0,1,53.6992,6.29287)">
|
||||
<path id="path406861" serif:id="path40686" d="M211.915,223.139L198.35,223.139L201.742,217.266L205.133,211.392L208.524,217.266L211.915,223.139Z" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:1px;"/>
|
||||
<path id="path406881" serif:id="path40688" d="M205.133,223.139L205.133,230.555" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:1px;"/>
|
||||
<path id="path406901" serif:id="path40690" d="M205.133,211.392L205.133,205.096" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:1px;"/>
|
||||
<path id="path406941" serif:id="path40694" d="M198.143,211.392L212.123,211.392" style="fill:none;fill-rule:nonzero;stroke:black;stroke-width:1px;"/>
|
||||
</g>
|
||||
<g id="path407021" serif:id="path40702" transform="matrix(0.325006,-0,-0,0.325006,-107.74,148.117)">
|
||||
<path d="M1147.45,199.771L1137.62,202.907L1141.01,193.159C1140.97,196.423 1144.19,199.728 1147.45,199.771Z" style="fill:rgb(255,0,0);fill-rule:nonzero;"/>
|
||||
<path d="M1150.21,190.644C1150.21,190.644 1146.35,194.399 1142.91,197.753" style="fill:none;fill-rule:nonzero;stroke:rgb(255,0,0);stroke-width:3.08px;"/>
|
||||
</g>
|
||||
<g id="path40702-11" serif:id="path40702-1" transform="matrix(0.325006,-0,-0,0.325006,-107.74,148.117)">
|
||||
<path d="M1166.11,199.771L1156.28,202.907L1159.67,193.159C1159.62,196.423 1162.84,199.728 1166.11,199.771Z" style="fill:rgb(255,0,0);fill-rule:nonzero;"/>
|
||||
<path d="M1168.86,190.644C1168.86,190.644 1165.01,194.399 1161.56,197.753" style="fill:none;fill-rule:nonzero;stroke:rgb(255,0,0);stroke-width:3.08px;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(1,0,0,1,1525.75,150.876)">
|
||||
<g id="g422281" serif:id="g42228" transform="matrix(3.07687,0,0,3.07687,-770.796,-623.629)">
|
||||
<path id="rect40684-3-51" serif:id="rect40684-3-5" d="M311.239,289.332C311.239,288.84 310.839,288.44 310.346,288.44L273.745,288.44C273.252,288.44 272.852,288.84 272.852,289.332L272.852,325.934C272.852,326.427 273.252,326.827 273.745,326.827L310.346,326.827C310.839,326.827 311.239,326.427 311.239,325.934L311.239,289.332Z" style="fill:none;stroke:rgb(2,0,0);stroke-width:1px;"/>
|
||||
</g>
|
||||
<g transform="matrix(0.916758,0,0,0.916758,-209.942,-134.558)">
|
||||
<g transform="matrix(36.36,0,0,36.36,405.909,511.232)">
|
||||
</g>
|
||||
<text x="330.473px" y="511.232px" style="font-family:'ArialMT', 'Arial';font-size:36.36px;">R<tspan x="356.074px " y="511.232px ">T</tspan>O</text>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(1.26861,0.00113446,0.00113446,1,277.224,235.237)">
|
||||
<g transform="matrix(0.788264,-0.000894252,-0.000894252,0.999996,57.4082,-0.620229)">
|
||||
<path d="M368.303,230.541L376.948,237.082L368.248,243.55L368.303,230.541Z" style="fill:rgb(255,0,0);"/>
|
||||
<path d="M304.499,236.776C304.499,236.776 351.883,236.976 370.01,237.053" style="fill:none;stroke:rgb(255,0,0);stroke-width:2.89px;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(0.934186,-0.000277962,-0.000277962,0.999999,198.405,236.65)">
|
||||
<g transform="matrix(1.07045,0.000297545,0.000297545,1,162.33,-1.92253)">
|
||||
<path d="M170.653,231.452L179.298,237.993L170.598,244.461L170.653,231.452Z" style="fill:rgb(255,0,0);"/>
|
||||
<path d="M125.948,237.768C125.948,237.768 157.916,237.903 172.36,237.964" style="fill:none;stroke:rgb(255,0,0);stroke-width:2.89px;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(1.73353,0.00309801,0.00309801,1.00001,639.025,236.856)">
|
||||
<g transform="matrix(0.57686,-0.0017871,-0.0017871,0.999992,-166.693,-1.6572)">
|
||||
<path d="M895.303,232.857L903.948,239.399L895.248,245.866L895.303,232.857Z" style="fill:rgb(255,0,0);"/>
|
||||
<path d="M804.948,238.98C804.948,238.98 874.5,239.274 897.01,239.369" style="fill:none;stroke:rgb(255,0,0);stroke-width:2.89px;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(1.45403,0.00191757,0.00191757,1.00001,901.662,237.501)">
|
||||
<g transform="matrix(0.687744,-0.00131879,-0.00131879,0.999994,-379.363,-2.09148)">
|
||||
<path d="M1058.63,233.083L1067.27,239.624L1058.57,246.092L1058.63,233.083Z" style="fill:rgb(255,0,0);"/>
|
||||
<path d="M984.233,239.274C984.233,239.274 1040.38,239.511 1060.33,239.595" style="fill:none;stroke:rgb(255,0,0);stroke-width:2.89px;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(0.00422338,0.959693,-0.999991,0.00405319,825.177,70.1581)">
|
||||
<path d="M297.222,235.883L354.331,236.124" style="fill:none;"/>
|
||||
<g transform="matrix(0.00422338,-0.999991,1.04198,0.00440072,169.424,475.845)">
|
||||
<path d="M248.693,165.557L240.499,176.482L232.306,165.557L248.693,165.557Z"/>
|
||||
<path d="M240.499,121.674L240.499,167.742" style="fill:none;stroke:black;stroke-width:3.64px;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(0.959693,-0.00422338,0.00405319,0.999991,1250.8,239.181)">
|
||||
<path d="M297.222,235.883L354.331,236.124" style="fill:none;"/>
|
||||
<g transform="matrix(1.04198,0.00440072,-0.00422338,0.999991,-938.545,-8.46312)">
|
||||
<path d="M1230.83,230.931L1241.76,239.125L1230.83,247.318L1230.83,230.931Z"/>
|
||||
<path d="M1186.95,239.125L1233.02,239.125" style="fill:none;stroke:black;stroke-width:3.64px;stroke-miterlimit:1.5;"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M480-120q-151 0-255.5-46.5T120-280v-400q0-66 105.5-113T480-840q149 0 254.5 47T840-680v400q0 67-104.5 113.5T480-120Zm0-479q89 0 179-25.5T760-679q-11-29-100.5-55T480-760q-91 0-178.5 25.5T200-679q14 30 101.5 55T480-599Zm0 199q42 0 81-4t74.5-11.5q35.5-7.5 67-18.5t57.5-25v-120q-26 14-57.5 25t-67 18.5Q600-528 561-524t-81 4q-42 0-82-4t-75.5-11.5Q287-543 256-554t-56-25v120q25 14 56 25t66.5 18.5Q358-408 398-404t82 4Zm0 200q46 0 93.5-7t87.5-18.5q40-11.5 67-26t32-29.5v-98q-26 14-57.5 25t-67 18.5Q600-328 561-324t-81 4q-42 0-82-4t-75.5-11.5Q287-343 256-354t-56-25v99q5 15 31.5 29t66.5 25.5q40 11.5 88 18.5t94 7Z"/></svg>
|
||||
|
After Width: | Height: | Size: 729 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="m105-399-65-47 200-320 120 140 160-260 120 180 135-214 65 47-198 314-119-179-152 247-121-141-145 233Zm475 159q42 0 71-29t29-71q0-42-29-71t-71-29q-42 0-71 29t-29 71q0 42 29 71t71 29ZM784-80 676-188q-21 14-45.5 21t-50.5 7q-75 0-127.5-52.5T400-340q0-75 52.5-127.5T580-520q75 0 127.5 52.5T760-340q0 26-7 50.5T732-244l108 108-56 56Z"/></svg>
|
||||
|
After Width: | Height: | Size: 452 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed"><path d="M440-120v-480H120v-160q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H440Zm80-80h240v-160H520v160Zm0-240h240v-160H520v160ZM200-680h560v-80H200v80ZM120-80v-80h102q-48-23-77.5-68T115-330q0-79 55.5-134.5T305-520v80q-45 0-77.5 32T195-330q0 39 24 69t61 38v-97h80v240H120Z"/></svg>
|
||||
|
After Width: | Height: | Size: 421 B |
@@ -1,85 +0,0 @@
|
||||
basePath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\';
|
||||
useGui = 0;
|
||||
|
||||
db = DBHandler("pathToDB",[basePath,'silas_labor.db']);
|
||||
if useGui
|
||||
filterParams = db.promptFilterParameters();
|
||||
selectedFields = db.promptSelectFields();
|
||||
else
|
||||
filterParams = db.tables;
|
||||
filterParams.Configurations = struct( ...
|
||||
'bitrate', [], ...
|
||||
'db_mode', [], ...
|
||||
'fiber_length', 10, ...
|
||||
'interference_attenuation', [], ...
|
||||
'interference_path_length', [], ...
|
||||
'is_mpi', 0, ...
|
||||
'pam_level', [], ...
|
||||
'precomp_amp', [], ...
|
||||
'rop_attenuation', 0, ...
|
||||
'symbolrate', [], ...
|
||||
'v_awg', [], ...
|
||||
'v_bias', [], ...
|
||||
'wavelength', 1310 ...
|
||||
);
|
||||
filterParams.Equalizer.eq_type = equalizer_structure.vnle_pf_mlse;
|
||||
filterParams.Equalizer.eq_id = equalizer_structure.vnle;
|
||||
selectedFields = {'Runs.run_id','BERs.ber_id','Equalizer.eq_id','Equalizer.eq_type','BERs.ber','BERs.occurrence',...
|
||||
'Configurations.db_mode','Configurations.pam_level','Configurations.bitrate','Configurations.symbolrate','Configurations.fiber_length','Configurations.wavelength','Configurations.precomp_amp',...
|
||||
'Measurements.power_rop','Measurements.power_laser','Measurements.power_pd_in'};
|
||||
end
|
||||
|
||||
|
||||
[dataTable,~] = db.queryDB(filterParams, selectedFields);
|
||||
|
||||
% Calculate the mean BER for each combination of 'run_id' and 'eq_type'
|
||||
groupedData = groupsummary(dataTable, {'run_id', 'eq_type'}, 'mean', {'ber', 'power_rop','power_pd_in'});
|
||||
|
||||
% Extract unique rows from dataTable for each run_id with relevant configuration details
|
||||
uniqueConfigFields = {'run_id', 'pam_level', 'bitrate','symbolrate', 'fiber_length', 'wavelength', 'precomp_amp', 'db_mode'};
|
||||
[~, uniqueIdx] = unique(dataTable.run_id); % Get unique run_id indices
|
||||
configDetails = dataTable(uniqueIdx, uniqueConfigFields); % Extract unique configurations for each run_id
|
||||
|
||||
% Prepare the join key for both groupedData and configDetails
|
||||
groupedDataTable = table(groupedData.run_id, groupedData.eq_type, groupedData.GroupCount, groupedData.mean_ber,groupedData.mean_power_rop,groupedData.mean_power_pd_in, ...
|
||||
'VariableNames', {'run_id', 'eq_type', 'GroupCount', 'mean_ber','mean_power_rop','mean_power_pd_in'});
|
||||
|
||||
% Join groupedData with configDetails on the run_id field
|
||||
joinedData = join(groupedDataTable, configDetails, 'Keys', 'run_id');
|
||||
|
||||
|
||||
|
||||
|
||||
a=plot(fsym_vals.*1e-9.*log2(M_vals(modulation_iter)),ber_ffe(:,modulation_iter),...
|
||||
'Color',cols(modulation_iter,:),'MarkerSize',2,'LineWidth',1,...
|
||||
'Marker','o','MarkerFaceColor',cols(modulation_iter,:),'MarkerEdgeColor','black',...
|
||||
'DisplayName',['PAM ',num2str(M_vals(modulation_iter))]);
|
||||
|
||||
a.DataTipTemplate.DataTipRows(1).Label = 'Bitr';
|
||||
a.DataTipTemplate.DataTipRows(1).Format = ['%.1f',' Gbps'];
|
||||
|
||||
a.DataTipTemplate.DataTipRows(2).Label = 'BER';
|
||||
a.DataTipTemplate.DataTipRows(2).Format ='%.1e';
|
||||
|
||||
a.DataTipTemplate.DataTipRows(3).Label = 'P_{out}';
|
||||
a.DataTipTemplate.DataTipRows(3).Value = rop(:,modulation_iter);
|
||||
a.DataTipTemplate.DataTipRows(3).Format = ['%.2f',' dBm'];
|
||||
|
||||
a.DataTipTemplate.DataTipRows(4).Label = 'Baudr';
|
||||
a.DataTipTemplate.DataTipRows(4).Value = fsym_vals.*1e-9;
|
||||
a.DataTipTemplate.DataTipRows(4).Format = ['%.1f',' GBd'];
|
||||
|
||||
|
||||
a.DataTipTemplate.FontSize = 9;
|
||||
a.DataTipTemplate.FontName = 'arial';
|
||||
|
||||
% Continue with the rest of your plot settings
|
||||
title('Opt B2B')
|
||||
yline(3.8e-3, 'DisplayName', 'HD-FEC', 'LineStyle', '--', 'HandleVisibility', 'off');
|
||||
xlabel('Bit Rate in GBps');
|
||||
ylabel('Bit Error Rate (BER)');
|
||||
set(gca, 'yscale', 'log');
|
||||
set(gca, 'Box', 'on');
|
||||
grid on;
|
||||
grid minor;
|
||||
legend('Interpreter', 'none');
|
||||
@@ -0,0 +1,137 @@
|
||||
basePath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\';
|
||||
useGui = 0;
|
||||
pamlvls = [4, 6, 8];
|
||||
wlengths = [1310];
|
||||
db = DBHandler("pathToDB", [basePath, 'silas_labor.db']);
|
||||
|
||||
for w = 1:numel(wlengths)
|
||||
for p = 1:numel(pamlvls)
|
||||
% Load data from database
|
||||
joinedData = loadDataFromDB(db, pamlvls(p), wlengths(w), useGui);
|
||||
|
||||
% Plot filtered data
|
||||
figure(pamlvls(p));
|
||||
hold on;
|
||||
plotFilteredData(joinedData, wlengths(w));
|
||||
% Continue with the rest of your plot settings
|
||||
finalizePlot();
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
% Custom function to load data from database
|
||||
function joinedData = loadDataFromDB(db, pamlvl, wlength, useGui)
|
||||
if useGui
|
||||
filterParams = db.promptFilterParameters();
|
||||
selectedFields = db.promptSelectFields();
|
||||
else
|
||||
filterParams = db.tables;
|
||||
filterParams.Configurations = struct( ...
|
||||
'bitrate', [], 'db_mode', [], 'fiber_length', 1, ...
|
||||
'interference_attenuation', [], 'interference_path_length', [], ...
|
||||
'is_mpi', 0, 'pam_level', pamlvl, 'precomp_amp', [], ...
|
||||
'rop_attenuation', 0, 'symbolrate', [], 'v_awg', [], 'v_bias', [], ...
|
||||
'wavelength', wlength ...
|
||||
);
|
||||
|
||||
selectedFields = {'Runs.run_id', 'BERs.ber_id', 'Equalizer.eq_id', 'Equalizer.eq_type', 'BERs.ber', 'BERs.occurrence', ...
|
||||
'Configurations.db_mode', 'Configurations.pam_level', 'Configurations.bitrate', 'Configurations.symbolrate', ...
|
||||
'Configurations.fiber_length', 'Configurations.wavelength', 'Configurations.precomp_amp', ...
|
||||
'Measurements.power_rop', 'Measurements.power_laser', 'Measurements.power_pd_in'};
|
||||
end
|
||||
|
||||
% Get data table from DB
|
||||
[dataTable, ~] = db.queryDB(filterParams, selectedFields);
|
||||
|
||||
% Extract unique rows for each run_id
|
||||
uniqueConfigFields = {'run_id', 'pam_level', 'bitrate', 'symbolrate', 'fiber_length', 'wavelength', 'precomp_amp', 'db_mode'};
|
||||
[~, uniqueIdx] = unique(dataTable.run_id);
|
||||
configDetails = dataTable(uniqueIdx, uniqueConfigFields);
|
||||
|
||||
% Calculate the mean BER for each combination of 'run_id' and 'eq_type'
|
||||
groupedData = groupsummary(dataTable, {'run_id', 'eq_type'}, {'mean', 'min', @(x) meanExcludingOutliers(x)}, {'ber', 'power_rop', 'power_pd_in'});
|
||||
|
||||
% Join groupedData with configDetails on the run_id field
|
||||
joinedData = join(groupedData, configDetails, 'Keys', 'run_id');
|
||||
end
|
||||
|
||||
% Custom function to plot filtered data
|
||||
function plotFilteredData(joinedData, wlength)
|
||||
filterFields = {'eq_type'};
|
||||
cols = linspecer(8);
|
||||
lst = ["-", ":", "--"];
|
||||
|
||||
% Loop over each field you want to filter by
|
||||
for f = 1:numel(filterFields)
|
||||
currentField = filterFields{f};
|
||||
uniqueValues = unique(joinedData.(currentField));
|
||||
|
||||
for i = 1:numel(uniqueValues)
|
||||
currentValue = uniqueValues(i);
|
||||
|
||||
% Filter joinedData for the current value
|
||||
if isnumeric(currentValue)
|
||||
filteredData = joinedData(joinedData.(currentField) == currentValue, :);
|
||||
else
|
||||
filteredData = joinedData(strcmp(joinedData.(currentField), currentValue), :);
|
||||
end
|
||||
|
||||
% Group and average BERs of several run ids => repeated measurements in lab!
|
||||
groupVars = {'bitrate'};
|
||||
groupedDataWithMeans = groupsummary(filteredData, groupVars, {'mean', 'min'}, {'mean_ber', 'min_ber', 'fun1_ber', 'mean_power_rop', 'mean_power_pd_in'});
|
||||
[~, uniqueIdx] = unique(filteredData.bitrate);
|
||||
constantFields = filteredData(uniqueIdx, {'bitrate', 'GroupCount', 'pam_level', 'symbolrate', 'fiber_length', 'wavelength', 'precomp_amp', 'db_mode'});
|
||||
groupedRunIDs = varfun(@(x) {unique(x)}, filteredData, 'GroupingVariables', groupVars, 'InputVariables', 'run_id');
|
||||
groupedRunIDs.Properties.VariableNames(end) = {'GroupedRunIDs'};
|
||||
groupedDataWithMeans = join(groupedDataWithMeans, constantFields, 'Keys', 'bitrate');
|
||||
groupedDataWithMeans = join(groupedDataWithMeans, groupedRunIDs, 'Keys', 'bitrate');
|
||||
filteredData = groupedDataWithMeans;
|
||||
|
||||
% Plotting
|
||||
a = plot(filteredData.bitrate .* 1e-9, filteredData.mean_fun1_ber, ...
|
||||
'Color', cols(i, :), 'MarkerSize', 4, 'LineWidth', 1, 'LineStyle', lst(mod(wlength - 1, numel(lst)) + 1), ...
|
||||
'Marker', 'o', 'MarkerFaceColor', 'auto', 'MarkerEdgeColor', cols(i, :), ...
|
||||
'DisplayName', [char(currentValue), '; ', num2str(wlength), ' nm']);
|
||||
|
||||
a.DataTipTemplate.DataTipRows(1).Label = 'Bitrate';
|
||||
a.DataTipTemplate.DataTipRows(1).Format = ['%.1f', ' Gbit/s'];
|
||||
a.DataTipTemplate.DataTipRows(2).Label = 'BER';
|
||||
a.DataTipTemplate.DataTipRows(2).Format = '%.1e';
|
||||
a.DataTipTemplate.DataTipRows(3).Label = 'P_{out}';
|
||||
a.DataTipTemplate.DataTipRows(3).Value = filteredData.mean_mean_power_rop;
|
||||
a.DataTipTemplate.DataTipRows(3).Format = ['%.2f', ' dBm'];
|
||||
a.DataTipTemplate.DataTipRows(4).Label = 'Baudr';
|
||||
a.DataTipTemplate.DataTipRows(4).Value = filteredData.bitrate .* 1e-9;
|
||||
a.DataTipTemplate.DataTipRows(4).Format = ['%.1f', ' GBd'];
|
||||
a.DataTipTemplate.DataTipRows(5).Label = 'Run ID';
|
||||
a.DataTipTemplate.DataTipRows(5).Value = filteredData.GroupedRunIDs;
|
||||
a.DataTipTemplate.FontSize = 9;
|
||||
a.DataTipTemplate.FontName = 'arial';
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
% Custom function to finalize the plot settings
|
||||
function finalizePlot()
|
||||
yline(2e-2, 'DisplayName', '20% O-FEC', 'LineStyle', '--', 'HandleVisibility', 'off');
|
||||
yline(3.8e-3, 'DisplayName', 'HD-FEC', 'LineStyle', '--', 'HandleVisibility', 'off');
|
||||
xlabel('Bit Rate in GBps');
|
||||
ylabel('Bit Error Rate (BER)');
|
||||
xlim([300, 480]);
|
||||
set(gca, 'yscale', 'log');
|
||||
set(gca, 'Box', 'on');
|
||||
grid on;
|
||||
grid minor;
|
||||
legend('Interpreter', 'none');
|
||||
end
|
||||
|
||||
% Custom function using rmoutliers to calculate mean after removing outliers
|
||||
function meanWithoutOutliers = meanExcludingOutliers(x)
|
||||
[xWithoutOutliers,outlierpos] = rmoutliers(x);
|
||||
if isempty(xWithoutOutliers)
|
||||
meanWithoutOutliers = NaN;
|
||||
else
|
||||
meanWithoutOutliers = mean(xWithoutOutliers);
|
||||
end
|
||||
|
||||
end
|
||||
Binary file not shown.
170
projects/HighSpeedExperiment_2024/auswertung/ber_vs_bitrate.m
Normal file
170
projects/HighSpeedExperiment_2024/auswertung/ber_vs_bitrate.m
Normal file
@@ -0,0 +1,170 @@
|
||||
basePath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\';
|
||||
useGui = 0;
|
||||
pamlvls = [4,6,8];
|
||||
wlengths = [1302];
|
||||
figoffset = 0;
|
||||
|
||||
figure(30)
|
||||
tiledlayout(1, 3, 'TileSpacing', 'compact', 'Padding', 'compact');
|
||||
|
||||
for p = 1:numel(pamlvls)
|
||||
nexttile;
|
||||
|
||||
for w = 1:numel(wlengths)
|
||||
sgtitle(['Lambda: ',num2str(wlengths),' nm'])
|
||||
|
||||
hold on
|
||||
pamlvl = pamlvls(p);
|
||||
wlength = wlengths(w);
|
||||
db = DBHandler("pathToDB",[basePath,'silas_labor.db']);
|
||||
if useGui
|
||||
filterParams = db.promptFilterParameters();
|
||||
selectedFields = db.promptSelectFields();
|
||||
else
|
||||
filterParams = db.tables;
|
||||
filterParams.Configurations = struct( ...
|
||||
'bitrate', [], ...
|
||||
'db_mode', [], ...
|
||||
'fiber_length', 10, ...
|
||||
'interference_attenuation', [], ...
|
||||
'interference_path_length', [], ...
|
||||
'is_mpi', 0, ...
|
||||
'pam_level', pamlvl, ...
|
||||
'precomp_amp', [], ...
|
||||
'rop_attenuation', 0, ...
|
||||
'symbolrate', [], ...
|
||||
'v_awg', [], ...
|
||||
'v_bias', [], ...
|
||||
'wavelength', wlength ...
|
||||
);
|
||||
|
||||
selectedFields = {'Runs.run_id','BERs.ber_id','Equalizer.eq_id','Equalizer.eq_type','BERs.ber','BERs.occurrence',...
|
||||
'Configurations.db_mode','Configurations.pam_level','Configurations.bitrate','Configurations.symbolrate','Configurations.fiber_length','Configurations.wavelength','Configurations.precomp_amp',...
|
||||
'Measurements.power_rop','Measurements.power_laser','Measurements.power_pd_in'};
|
||||
end
|
||||
|
||||
% Get data table from DB
|
||||
[dataTable,~] = db.queryDB(filterParams, selectedFields);
|
||||
|
||||
% Grouping variables: 'bitrate' and 'eq_type'
|
||||
groupVars = {'bitrate', 'eq_type'};
|
||||
|
||||
% Calculate mean BER for each combination of 'bitrate' and 'eq_type'
|
||||
groupedData = groupsummary(dataTable, groupVars, {'mean', 'min', @(x) meanExcludingOutliers(x)}, {'ber', 'power_rop','power_pd_in'});
|
||||
|
||||
% Collect the run_id values for each group
|
||||
groupedRunIDs = varfun(@(x) {unique(x)}, dataTable, 'GroupingVariables', groupVars, 'InputVariables', 'run_id');
|
||||
groupedRunIDs.Properties.VariableNames(end) = {'GroupedRunIDs'};
|
||||
|
||||
% Join the grouped data with the grouped run_id list
|
||||
avgdBerTable = join(groupedData, groupedRunIDs, 'Keys', groupVars);
|
||||
|
||||
% Define the fields that you want to use for filtering
|
||||
filterFields = {'eq_type'};
|
||||
|
||||
% Loop over each field you want to filter by
|
||||
for f = 1:numel(filterFields)
|
||||
currentField = filterFields{f};
|
||||
|
||||
% Determine unique values for the current field
|
||||
uniqueValues = unique(avgdBerTable.(currentField));
|
||||
|
||||
% Loop over each unique value for the current field
|
||||
for i = 1:numel(uniqueValues)
|
||||
currentValue = uniqueValues(i);
|
||||
|
||||
% Filter joinedData for the current value
|
||||
if isnumeric(currentValue)
|
||||
filteredData = avgdBerTable(avgdBerTable.(currentField) == currentValue, :);
|
||||
else
|
||||
filteredData = avgdBerTable(strcmp(avgdBerTable.(currentField), currentValue), :);
|
||||
end
|
||||
|
||||
cols = linspecer(8);
|
||||
|
||||
lst = ["-",":","--"];
|
||||
a=plot(filteredData.bitrate.*1e-9,filteredData.min_ber,...
|
||||
'Color',cols(i,:),'MarkerSize',4,'LineWidth',1,'LineStyle',lst(w),...
|
||||
'Marker','o','MarkerFaceColor','auto','MarkerEdgeColor',cols(i,:),...
|
||||
'DisplayName',[char(currentValue),'; ',num2str(wlength),' nm' ]);
|
||||
a.DataTipTemplate.DataTipRows(1).Label = 'Bitrate';
|
||||
a.DataTipTemplate.DataTipRows(1).Format = ['%.1f',' Gbit/s'];
|
||||
|
||||
a.DataTipTemplate.DataTipRows(2).Label = 'BER';
|
||||
a.DataTipTemplate.DataTipRows(2).Format ='%.1e';
|
||||
|
||||
a.DataTipTemplate.DataTipRows(3).Label = 'P_{out}';
|
||||
a.DataTipTemplate.DataTipRows(3).Value = filteredData.mean_power_rop;
|
||||
a.DataTipTemplate.DataTipRows(3).Format = ['%.2f',' dBm'];
|
||||
|
||||
a.DataTipTemplate.DataTipRows(4).Label = 'Run ID';
|
||||
a.DataTipTemplate.DataTipRows(4).Value = filteredData.GroupedRunIDs;
|
||||
a.DataTipTemplate.DataTipRows(4).Format = ['%d',' '];
|
||||
|
||||
|
||||
a.DataTipTemplate.FontSize = 9;
|
||||
a.DataTipTemplate.FontName = 'arial';
|
||||
%
|
||||
% a=scatter(filteredData.bitrate.*1e-9,filteredData.min_ber,5,'Marker','diamond',...
|
||||
% 'Color',cols(i,:),'LineWidth',1,...
|
||||
% 'MarkerFaceColor','auto','MarkerEdgeColor',cols(i,:),...
|
||||
% 'DisplayName',currentValue);
|
||||
%
|
||||
% a.DataTipTemplate.DataTipRows(1).Label = 'Bitrate';
|
||||
% a.DataTipTemplate.DataTipRows(1).Format = ['%.1f',' Gbit/s'];
|
||||
%
|
||||
% a.DataTipTemplate.DataTipRows(2).Label = 'BER';
|
||||
% a.DataTipTemplate.DataTipRows(2).Format ='%.1e';
|
||||
%
|
||||
% a.DataTipTemplate.DataTipRows(3).Label = 'P_{out}';
|
||||
% a.DataTipTemplate.DataTipRows(3).Value = filteredData.mean_power_rop;
|
||||
% a.DataTipTemplate.DataTipRows(3).Format = ['%.2f',' dBm'];
|
||||
%
|
||||
% a.DataTipTemplate.DataTipRows(4).Label = 'Run ID';
|
||||
% a.DataTipTemplate.DataTipRows(4).Value = filteredData.GroupedRunIDs;
|
||||
% a.DataTipTemplate.DataTipRows(4).Format = ['%d',' '];
|
||||
%
|
||||
%
|
||||
% a.DataTipTemplate.FontSize = 9;
|
||||
% a.DataTipTemplate.FontName = 'arial';
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
% Continue with the rest of your plot settings
|
||||
title(sprintf('%d km | %d nm | PAM %d',unique(filterParams.Configurations.fiber_length),wlength,pamlvl));
|
||||
yline(2e-2, 'DisplayName', '20% O-FEC', 'LineStyle', '--', 'HandleVisibility', 'off','LineWidth',1);
|
||||
yline(3.8e-3, 'DisplayName', 'HD-FEC', 'LineStyle', '--', 'HandleVisibility', 'off','LineWidth',1);
|
||||
xlabel('Bit Rate in Gbps');
|
||||
ylabel('Bit Error Rate');
|
||||
xlim([300, 480])
|
||||
ylim([8e-4,0.5])
|
||||
set(gca, 'yscale', 'log');
|
||||
set(gca, 'Box', 'on');
|
||||
grid on;
|
||||
grid minor;
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
legend('Interpreter', 'none');
|
||||
set(gcf, 'Units', 'pixels', 'Position', 1.0e+03 * [0.2483 0.7303 1.2093 0.3980]);
|
||||
|
||||
% Custom function using rmoutliers to calculate mean after removing outliers
|
||||
function meanWithoutOutliers = meanExcludingOutliers(x)
|
||||
% Remove outliers using rmoutliers with default method (based on median)
|
||||
xWithoutOutliers = rmoutliers(x);
|
||||
|
||||
% Calculate the mean of the non-outliers
|
||||
if isempty(xWithoutOutliers)
|
||||
% Handle the case where all values are outliers
|
||||
meanWithoutOutliers = NaN;
|
||||
else
|
||||
meanWithoutOutliers = mean(xWithoutOutliers);
|
||||
end
|
||||
end
|
||||
192
projects/HighSpeedExperiment_2024/auswertung/ber_vs_length.m
Normal file
192
projects/HighSpeedExperiment_2024/auswertung/ber_vs_length.m
Normal file
@@ -0,0 +1,192 @@
|
||||
basePath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\';
|
||||
useGui = 0;
|
||||
pamlvls = [6];
|
||||
wlengths = [1293,1302,1310];%db.distinctValues.Configurations.wavelength
|
||||
figoffset = 20;
|
||||
|
||||
figure(21)
|
||||
tiledlayout(1, 3, 'TileSpacing', 'compact', 'Padding', 'compact');
|
||||
|
||||
|
||||
for w = 1:numel(wlengths)
|
||||
nexttile;
|
||||
for p = 1:numel(pamlvls)
|
||||
pamlvl = pamlvls(p);
|
||||
wlength = wlengths(w);
|
||||
db = DBHandler("pathToDB",[basePath,'silas_labor.db']);
|
||||
if useGui
|
||||
filterParams = db.promptFilterParameters();
|
||||
selectedFields = db.promptSelectFields();
|
||||
else
|
||||
filterParams = db.tables;
|
||||
filterParams.Configurations = struct( ...
|
||||
'bitrate', 420e9, ...
|
||||
'db_mode', [], ...
|
||||
'fiber_length', [], ...
|
||||
'interference_attenuation', [], ...
|
||||
'interference_path_length', [], ...
|
||||
'is_mpi', 0, ...
|
||||
'pam_level', pamlvl, ...
|
||||
'precomp_amp', [], ...
|
||||
'rop_attenuation', 0, ...
|
||||
'symbolrate', [], ...
|
||||
'v_awg', [], ...
|
||||
'v_bias', [], ...
|
||||
'wavelength', wlength ...
|
||||
);
|
||||
% filterParams.Equalizer.eq_type = equalizer_structure.vnle;
|
||||
|
||||
selectedFields = {'Runs.run_id','BERs.ber_id','Equalizer.eq_id','Equalizer.eq_type','BERs.ber','BERs.occurrence',...
|
||||
'Configurations.db_mode','Configurations.pam_level','Configurations.bitrate','Configurations.symbolrate','Configurations.fiber_length','Configurations.wavelength','Configurations.precomp_amp',...
|
||||
'Measurements.power_rop','Measurements.power_laser','Measurements.power_pd_in'};
|
||||
end
|
||||
sgtitle(['Rate: ',num2str(filterParams.Configurations.bitrate),' Gbit/s'])
|
||||
% Get data table from DB
|
||||
[dataTable,~] = db.queryDB(filterParams, selectedFields);
|
||||
|
||||
% Extract unique rows from dataTable for each run_id with relevant configuration details
|
||||
uniqueConfigFields = {'run_id', 'pam_level', 'bitrate','symbolrate', 'fiber_length', 'wavelength', 'precomp_amp', 'db_mode'};
|
||||
[~, uniqueIdx] = unique(dataTable.run_id); % Get unique run_id indices
|
||||
configDetails = dataTable(uniqueIdx, uniqueConfigFields); % Extract unique configurations for each run_id
|
||||
|
||||
% Calculate the mean BER for each combination of 'run_id' and 'eq_type'
|
||||
groupedData = groupsummary(dataTable, {'run_id', 'eq_type'}, {'mean','min'}, {'ber', 'power_rop','power_pd_in'});
|
||||
groupedData = groupsummary(dataTable, {'run_id', 'eq_type'}, {'mean', 'min', @(x) meanExcludingOutliers(x)}, {'ber', 'power_rop','power_pd_in'});
|
||||
|
||||
% Join groupedData with configDetails on the run_id field
|
||||
joinedData = join(groupedData, configDetails, 'Keys', 'run_id');
|
||||
|
||||
|
||||
% Define the fields that you want to use for filtering
|
||||
filterFields = {'eq_type'};
|
||||
|
||||
% Create a cell array to store filtered data tables for each filter field
|
||||
filteredDataByField = struct();
|
||||
|
||||
hold on
|
||||
% Loop over each field you want to filter by
|
||||
for f = 1:numel(filterFields)
|
||||
currentField = filterFields{f};
|
||||
|
||||
% Determine unique values for the current field
|
||||
uniqueValues = unique(joinedData.(currentField));
|
||||
|
||||
% Create a struct entry for the current field
|
||||
filteredDataByField.(currentField) = cell(numel(uniqueValues), 1);
|
||||
|
||||
% Loop over each unique value for the current field
|
||||
for i = 1:numel(uniqueValues)
|
||||
currentValue = uniqueValues(i);
|
||||
|
||||
% Filter joinedData for the current value
|
||||
if isnumeric(currentValue)
|
||||
filteredData = joinedData(joinedData.(currentField) == currentValue, :);
|
||||
else
|
||||
filteredData = joinedData(strcmp(joinedData.(currentField), currentValue), :);
|
||||
end
|
||||
|
||||
%%% workaround to average the BERs of several runs (ie in 1km case or trials)
|
||||
%%% Workaround to average the BERs of several runs (e.g., in 1 km case or trials)
|
||||
|
||||
% Grouping variable(s)
|
||||
groupVars = {'fiber_length'};
|
||||
|
||||
% Use groupsummary to calculate the mean and min of relevant fields
|
||||
groupedDataWithMeans = groupsummary(filteredData, groupVars, {'mean', 'min'}, {'mean_ber', 'min_ber', 'fun1_ber', 'mean_power_rop', 'mean_power_pd_in'});
|
||||
|
||||
% Extract representative values for constant fields
|
||||
[~, uniqueIdx] = unique(filteredData.(groupVars{1})); % Get the first occurrence of each bitrate value
|
||||
constantFields = filteredData(uniqueIdx, {'bitrate', 'GroupCount', 'pam_level', 'symbolrate', 'fiber_length', 'wavelength', 'precomp_amp', 'db_mode'});
|
||||
|
||||
% Keep track of which run_id values were grouped
|
||||
groupedRunIDs = varfun(@(x) {unique(x)}, filteredData, 'GroupingVariables', groupVars, 'InputVariables', 'run_id');
|
||||
groupedRunIDs.Properties.VariableNames(end) = {'GroupedRunIDs'};
|
||||
|
||||
% Join the grouped data with the constant fields
|
||||
groupedDataWithMeans = join(groupedDataWithMeans, constantFields, 'Keys', groupVars);
|
||||
|
||||
% Join the grouped data with the grouped run_id list
|
||||
groupedDataWithMeans = join(groupedDataWithMeans, groupedRunIDs, 'Keys', groupVars);
|
||||
|
||||
% Update filteredData to include the grouped information
|
||||
filteredData = groupedDataWithMeans;
|
||||
%%% end of workaround
|
||||
|
||||
|
||||
|
||||
cols = linspecer(8);
|
||||
% a=plot(filteredData.bitrate.*1e-9,filteredData.mean_mean_ber,...
|
||||
% 'Color',cols(i,:),'MarkerSize',4,'LineWidth',1,'LineStyle',':',...
|
||||
% 'Marker','o','MarkerFaceColor','auto','MarkerEdgeColor',cols(i,:),...
|
||||
% 'DisplayName',currentValue);
|
||||
|
||||
lst = ["-",":","--"];
|
||||
a=plot(filteredData.(groupVars{1}),filteredData.mean_fun1_ber,...
|
||||
'Color',cols(i,:),'MarkerSize',4,'LineWidth',1,'LineStyle',lst(1),...
|
||||
'Marker','o','MarkerFaceColor','auto','MarkerEdgeColor',cols(i,:),...
|
||||
'DisplayName',[char(currentValue),'; ',num2str(wlength),' nm' ]);
|
||||
%
|
||||
% scatter(filteredData.symbolrate.*1e-9,filteredData.min_min_ber,5,'Marker','_',...
|
||||
% 'Color',cols(i,:),'LineWidth',1,...
|
||||
% 'MarkerFaceColor',cols(i,:),'MarkerEdgeColor','black',...
|
||||
% 'DisplayName',currentValue);
|
||||
|
||||
a.DataTipTemplate.DataTipRows(1).Label = groupVars{1};
|
||||
a.DataTipTemplate.DataTipRows(1).Format = ['%.1f',''];
|
||||
|
||||
a.DataTipTemplate.DataTipRows(2).Label = 'BER';
|
||||
a.DataTipTemplate.DataTipRows(2).Format ='%.1e';
|
||||
|
||||
a.DataTipTemplate.DataTipRows(3).Label = 'P_{out}';
|
||||
a.DataTipTemplate.DataTipRows(3).Value = filteredData.mean_mean_power_rop;
|
||||
a.DataTipTemplate.DataTipRows(3).Format = ['%.2f',' dBm'];
|
||||
|
||||
a.DataTipTemplate.DataTipRows(4).Label = 'Baudr';
|
||||
a.DataTipTemplate.DataTipRows(4).Value = filteredData.bitrate .*1e-9;
|
||||
a.DataTipTemplate.DataTipRows(4).Format = ['%.1f',' GBd'];
|
||||
|
||||
a.DataTipTemplate.DataTipRows(5).Label = 'Run ID';
|
||||
a.DataTipTemplate.DataTipRows(5).Value = filteredData.GroupedRunIDs;
|
||||
a.DataTipTemplate.DataTipRows(5).Format = ['%f',' GBd'];
|
||||
|
||||
|
||||
a.DataTipTemplate.FontSize = 9;
|
||||
a.DataTipTemplate.FontName = 'arial';
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
% Continue with the rest of your plot settings
|
||||
title(sprintf('Lambda: %f',wlength));
|
||||
yline(2e-2, 'DisplayName', '20% O-FEC', 'LineStyle', '--', 'HandleVisibility', 'off');
|
||||
yline(3.8e-3, 'DisplayName', 'HD-FEC', 'LineStyle', '--', 'HandleVisibility', 'off');
|
||||
xlabel(groupVars{1},'Interpreter','none');
|
||||
ylabel('Bit Error Rate (BER)');
|
||||
%xlim([300, 480])
|
||||
ylim([8e-4,0.5])
|
||||
set(gca, 'yscale', 'log');
|
||||
set(gca, 'Box', 'on');
|
||||
grid on;
|
||||
grid minor;
|
||||
legend('Interpreter', 'none');
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
% Custom function using rmoutliers to calculate mean after removing outliers
|
||||
function meanWithoutOutliers = meanExcludingOutliers(x)
|
||||
% Remove outliers using rmoutliers with default method (based on median)
|
||||
xWithoutOutliers = rmoutliers(x);
|
||||
|
||||
% Calculate the mean of the non-outliers
|
||||
if isempty(xWithoutOutliers)
|
||||
% Handle the case where all values are outliers
|
||||
meanWithoutOutliers = NaN;
|
||||
else
|
||||
meanWithoutOutliers = mean(xWithoutOutliers);
|
||||
end
|
||||
end
|
||||
@@ -17,18 +17,56 @@ folderNames = folderNames(~ismember(folderNames, {'.', '..'}));
|
||||
|
||||
% Combine folder names with paths
|
||||
fullFolderPaths = flip(fullfile(folderPaths, folderNames));
|
||||
only_mpi=0;
|
||||
|
||||
% process only MPI?
|
||||
only_mpi=0;
|
||||
if only_mpi
|
||||
fullFolderPaths = fullFolderPaths(contains(fullFolderPaths,"mpi"));
|
||||
end
|
||||
|
||||
relativeFolderPaths = strrep(fullFolderPaths, sioe_labor_path, '');
|
||||
% Shorten folder paths to display only the folder name after the last filesep
|
||||
displayFolderPaths = cellfun(@(x) x(find(x == filesep, 1, 'last') + 1 : end), fullFolderPaths, 'UniformOutput', false);
|
||||
|
||||
% Create checkbox settings for each folder path
|
||||
numFolders = numel(fullFolderPaths);
|
||||
checkboxSettings = cell(1, 2 * numFolders);
|
||||
for i = 1:numFolders
|
||||
checkboxSettings{2*i-1} = {displayFolderPaths{i}; sprintf('Folder_%d', i)};
|
||||
checkboxSettings{2*i} = true; % Set false for unchecked by default
|
||||
end
|
||||
|
||||
% Create settings dialog using settingsdlg
|
||||
[settings, button] = settingsdlg( ...
|
||||
'Description', 'Select Folders to Process:', ...
|
||||
'title', 'Folder Selection', ...
|
||||
checkboxSettings{:});
|
||||
|
||||
% Check if the user pressed OK
|
||||
if strcmp(button, 'OK')
|
||||
% Get all the field names from settings
|
||||
allFields = fieldnames(settings);
|
||||
|
||||
% Determine which folders were selected
|
||||
selectedFoldersIdx = cellfun(@(x) settings.(x), allFields);
|
||||
|
||||
% Get the list of selected folders
|
||||
selectedFolders = fullFolderPaths(selectedFoldersIdx==1);
|
||||
|
||||
% Display the selected folders
|
||||
fprintf('Selected Folders to Process:\n');
|
||||
disp(selectedFolders);
|
||||
else
|
||||
fprintf('No folders selected.\n');
|
||||
end
|
||||
|
||||
|
||||
relativeFolderPaths = strrep(selectedFolders, sioe_labor_path, '');
|
||||
|
||||
disp(['Start to process ',num2str(numel(relativeFolderPaths)), ' folder in the directory']);
|
||||
|
||||
for f = 1:numel(fullFolderPaths)
|
||||
folder = fullFolderPaths{f};
|
||||
|
||||
for f = 1:numel(selectedFolders)
|
||||
folder = selectedFolders{n};
|
||||
relfolder = relativeFolderPaths{f};
|
||||
|
||||
|
||||
@@ -106,18 +144,18 @@ for f = 1:numel(fullFolderPaths)
|
||||
params_merge = struct;
|
||||
for c = 1:numel(big_wh_list)
|
||||
fnames = fieldnames(big_wh_list{c}.parameter);
|
||||
for f = 1:numel(fnames)
|
||||
for fn = 1:numel(fnames)
|
||||
% Initialize field if not already present
|
||||
if ~isfield(params_merge, fnames{f})
|
||||
params_merge.(fnames{f}) = [];
|
||||
if ~isfield(params_merge, fnames{fn})
|
||||
params_merge.(fnames{fn}) = [];
|
||||
end
|
||||
|
||||
% Merge unique parameter values into params_merge
|
||||
a = big_wh_list{c}.parameter.(fnames{f}).values;
|
||||
b = params_merge.(fnames{f});
|
||||
a = big_wh_list{c}.parameter.(fnames{fn}).values;
|
||||
b = params_merge.(fnames{fn});
|
||||
vals_to_add = setdiff(a, b); % New values in a that aren't in b
|
||||
b = sort([b, vals_to_add]); % Combine and sort values
|
||||
params_merge.(fnames{f}) = b;
|
||||
params_merge.(fnames{fn}) = b;
|
||||
end
|
||||
end
|
||||
|
||||
@@ -157,11 +195,11 @@ for f = 1:numel(fullFolderPaths)
|
||||
|
||||
isMPI = isfield(measurementStruct,'i_power');
|
||||
|
||||
% Process record if it contains data
|
||||
% Process record if it contains *any* data
|
||||
if recordIsFilled
|
||||
|
||||
if ~isMPI
|
||||
|
||||
|
||||
% Generate filenames with conditionally formatted parameters
|
||||
% Format the L parameter value (show decimal only if non-zero)
|
||||
if configStruct.lambda == floor(configStruct.lambda)
|
||||
@@ -175,8 +213,13 @@ for f = 1:numel(fullFolderPaths)
|
||||
configStruct.M, L_str, configStruct.bitrate, configStruct.duobinary, 0);
|
||||
fbody_tx = strrep(fbody_tx, '.', '_'); % Replace decimal point with underscore
|
||||
|
||||
fbody_rx = sprintf('%s_PAM_%d_L_%s_R_%d_DB_%d_ROP_%d', datebody, ...
|
||||
configStruct.M, L_str, configStruct.bitrate, configStruct.duobinary, configStruct.rop_atten);
|
||||
if configStruct.rop_atten == round(configStruct.rop_atten)
|
||||
fbody_rx = sprintf('%s_PAM_%d_L_%s_R_%d_DB_%d_ROP_%d', datebody, ...
|
||||
configStruct.M, L_str, configStruct.bitrate, configStruct.duobinary, configStruct.rop_atten);
|
||||
else
|
||||
fbody_rx = sprintf('%s_PAM_%d_L_%s_R_%d_DB_%d_ROP_%.1f', datebody, ...
|
||||
configStruct.M, L_str, configStruct.bitrate, configStruct.duobinary, configStruct.rop_atten);
|
||||
end
|
||||
fbody_rx = strrep(fbody_rx, '.', '_');
|
||||
|
||||
elseif isMPI
|
||||
@@ -185,8 +228,13 @@ for f = 1:numel(fullFolderPaths)
|
||||
configStruct.M, configStruct.bitrate, configStruct.duobinary, 0);
|
||||
fbody_tx = strrep(fbody_tx, '.', '_'); % Replace decimal point with underscore
|
||||
|
||||
fbody_rx = sprintf('%s_PAM_%d_R_%d_DB_%d_I_atten_%d', datebody, ...
|
||||
configStruct.M, configStruct.bitrate, configStruct.duobinary, configStruct.interference_atten);
|
||||
if configStruct.interference_atten == round(configStruct.interference_atten)
|
||||
fbody_rx = sprintf('%s_PAM_%d_R_%d_DB_%d_I_atten_%d', datebody, ...
|
||||
configStruct.M, configStruct.bitrate, configStruct.duobinary, configStruct.interference_atten);
|
||||
else
|
||||
fbody_rx = sprintf('%s_PAM_%d_R_%d_DB_%d_I_atten_%.1f', datebody, ...
|
||||
configStruct.M, configStruct.bitrate, configStruct.duobinary, configStruct.interference_atten);
|
||||
end
|
||||
fbody_rx = strrep(fbody_rx, '.', '_'); % Replace decimal point with underscore
|
||||
|
||||
end
|
||||
@@ -223,6 +271,7 @@ for f = 1:numel(fullFolderPaths)
|
||||
% SYNCHRONIZED RX SIGNAL
|
||||
fn_rxtsynch = [filesep, fbody_rx, '_rx_signal.mat'];
|
||||
fp_rxtsynch = fullfile([folder, fn_rxtsynch]);
|
||||
fn_rxtsynch_rel = [];
|
||||
if exist(fp_rxtsynch, "file") == 2
|
||||
fn_rxtsynch_rel = [relfolder, fn_rxtsynch];
|
||||
|
||||
@@ -244,13 +293,42 @@ for f = 1:numel(fullFolderPaths)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
elseif exist(fp_rxtsynch, "file") == 0
|
||||
|
||||
disp(['RX Signal not found at: ', fn_rxtsynch,' generate and save new one using symbols and raw signal']);
|
||||
|
||||
Scpe_sig_raw = load(fp_rxraw);
|
||||
Scpe_sig_raw = Scpe_sig_raw.Scpe_sig_raw;
|
||||
|
||||
Symbols = load(fp_symbols);
|
||||
Symbols = Symbols.Symbols;
|
||||
%%%%%% Sample to 2x fsym %%%%%%
|
||||
Scpe_sig_resampled = Scpe_sig_raw.resample("fs_in",Scpe_sig_raw.fs,"fs_out",2*Symbols.fs);
|
||||
%%%%%% Sync Rx signal with reference (S is a cell array with all occurences) %%%%%%
|
||||
[Scpe_sig_syncd,S,isFlipped] = Scpe_sig_resampled.tsynch("reference",Symbols,"fs_ref",Symbols.fs);
|
||||
%%%%% Plot and Save Routines: SAVE RECEIVED SIGNALS %%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
save(fp_rxtsynch,"S");
|
||||
|
||||
if exist(fp_rxtsynch, "file") == 0
|
||||
warndlg('Something still wromg... No rx file here but we just generated it from raw signal');
|
||||
end
|
||||
|
||||
fn_rxtsynch_rel = [relfolder, fn_rxtsynch];
|
||||
|
||||
elseif missing_raw_flag
|
||||
warning(['RX Signal not found at: ', fn_rxtsynch]);
|
||||
warndlg('No RAW or RX signal found! This is bad!');
|
||||
% look at measurementStruct and configStruct
|
||||
end
|
||||
else
|
||||
disp('Record not filled?')
|
||||
% look at measurementStruct and configStruct
|
||||
end
|
||||
|
||||
% Call the duplicate check function
|
||||
exists = db.checkIfRunExists('Runs', 'rx_sync_path', fn_rxtsynch_rel);
|
||||
if ~isempty(fn_rxtsynch_rel)
|
||||
exists = db.checkIfRunExists('Runs', 'rx_sync_path', fn_rxtsynch_rel);
|
||||
end
|
||||
|
||||
if ~exists
|
||||
|
||||
@@ -335,31 +413,32 @@ for f = 1:numel(fullFolderPaths)
|
||||
% Append the new row to the Measurements table
|
||||
db.appendToTable('Measurements', newMeas);
|
||||
|
||||
% Table 4: Append to Bers
|
||||
[ber, structure, settings] = getBers(configStruct,measurementStruct);
|
||||
for t = 1:numel(ber)
|
||||
|
||||
if iscell(ber(t))
|
||||
ber_ = ber(t);
|
||||
ber_ = ber_{1};
|
||||
else
|
||||
ber_ = ber(t);
|
||||
end
|
||||
|
||||
if ber_~=-1
|
||||
|
||||
newBer = struct(...
|
||||
'ber_id', NaN,...
|
||||
'run_id', run_id,...
|
||||
'processing_structure', structure(t),...
|
||||
'processing_settings', settings(t),...
|
||||
'ber', jsonencode(ber_)...
|
||||
);
|
||||
db.appendToTable('BERs', newBer);
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
% % Table 4: Append to Bers
|
||||
% [ber, structure, settings] = getBers(configStruct,measurementStruct);
|
||||
% for t = 1:numel(ber)
|
||||
%
|
||||
% if iscell(ber(t))
|
||||
% ber_ = ber(t);
|
||||
% ber_ = ber_{1};
|
||||
% else
|
||||
% ber_ = ber(t);
|
||||
% end
|
||||
%
|
||||
% if ber_~=-1
|
||||
%
|
||||
% newBer = struct(...
|
||||
% 'ber_id', NaN,...
|
||||
% 'run_id', run_id,...
|
||||
% 'processing_structure', structure(t),...
|
||||
% 'processing_settings', settings(t),...
|
||||
% 'ber', jsonencode(ber_)...
|
||||
% );
|
||||
%
|
||||
% db.appendToTable('BERs', newBer);
|
||||
%
|
||||
% end
|
||||
%
|
||||
% end
|
||||
|
||||
end
|
||||
|
||||
|
||||
42
projects/HighSpeedExperiment_2024/auswertung/checkDBpaths.m
Normal file
42
projects/HighSpeedExperiment_2024/auswertung/checkDBpaths.m
Normal file
@@ -0,0 +1,42 @@
|
||||
% Load the Runs table from the database
|
||||
db = DBHandler("pathToDB", 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\silas_labor.db');
|
||||
runsTable = db.queryDB(db.tables, {'Runs.run_id', 'Runs.tx_bits_path', 'Runs.tx_symbols_path', 'Runs.rx_sync_path', 'Runs.rx_raw_path', 'Runs.filename'});
|
||||
|
||||
% Initialize an array to store the result of existence check
|
||||
fileExistenceResults = false(height(runsTable), 4); % 4 columns for the paths: tx_bits, tx_symbols, rx_sync, rx_raw
|
||||
|
||||
% Main file path
|
||||
sioe_labor_path = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor';
|
||||
|
||||
% Loop through all rows in the table and check paths
|
||||
for i = 1:height(runsTable)
|
||||
fileExistenceResults(i, 1) = exist([sioe_labor_path, runsTable.tx_bits_path{i}], 'file') == 2;
|
||||
fileExistenceResults(i, 2) = exist([sioe_labor_path, runsTable.tx_symbols_path{i}], 'file') == 2;
|
||||
fileExistenceResults(i, 3) = exist([sioe_labor_path, runsTable.rx_sync_path{i}], 'file') == 2;
|
||||
fileExistenceResults(i, 4) = exist([sioe_labor_path, runsTable.rx_raw_path{i}], 'file') == 2;
|
||||
end
|
||||
|
||||
% Identify corrupted run_ids (where any path does not exist)
|
||||
corruptedRunIds = runsTable.run_id(~all(fileExistenceResults, 2));
|
||||
|
||||
% Delete entries in all tables related to corrupted run_ids
|
||||
for i = 1:numel(corruptedRunIds)
|
||||
run_id = corruptedRunIds(i);
|
||||
|
||||
% Delete from BERs table
|
||||
db.executeSQL(sprintf('DELETE FROM BERs WHERE run_id = %d;', run_id));
|
||||
|
||||
% Delete from Equalizer table (if applicable)
|
||||
db.executeSQL(sprintf('DELETE FROM Equalizer WHERE eq_id IN (SELECT eq_id FROM BERs WHERE run_id = %d);', run_id));
|
||||
|
||||
% Delete from Measurements table
|
||||
db.executeSQL(sprintf('DELETE FROM Measurements WHERE run_id = %d;', run_id));
|
||||
|
||||
% Delete from Configurations table
|
||||
db.executeSQL(sprintf('DELETE FROM Configurations WHERE run_id = %d;', run_id));
|
||||
|
||||
% Delete from Runs table
|
||||
db.executeSQL(sprintf('DELETE FROM Runs WHERE run_id = %d;', run_id));
|
||||
end
|
||||
%
|
||||
% disp('Entries for corrupted run_ids have been removed from the database.');
|
||||
@@ -0,0 +1,32 @@
|
||||
function [berTable, foundBerFlag] = getBerForRunId(db, run_id)
|
||||
% getBerForRunId Queries the BER data for the specified run_id.
|
||||
% Inputs:
|
||||
% db - The database handler object.
|
||||
% run_id - The run ID for which to get the BER data.
|
||||
% Outputs:
|
||||
% berData - A table containing BER results for the given run ID.
|
||||
|
||||
% Set up filter parameters to query the BER data for the specific run_id
|
||||
filterParams = db.tables;
|
||||
filterParams.Runs.run_id = run_id; % Filter by specific run_id
|
||||
|
||||
% Define the fields to be retrieved from the database
|
||||
selectedFields = {'Runs.run_id', 'BERs.ber_id', 'Equalizer.eq_id', 'Equalizer.eq_type', ...
|
||||
'BERs.ber', 'BERs.occurrence', 'Configurations.db_mode', ...
|
||||
'Configurations.pam_level', 'Configurations.bitrate', 'Configurations.symbolrate', ...
|
||||
'Configurations.fiber_length', 'Configurations.wavelength', ...
|
||||
'Configurations.precomp_amp', 'Measurements.power_rop', 'Measurements.power_laser', ...
|
||||
'Measurements.power_pd_in'};
|
||||
|
||||
% Query the database for the specified run_id
|
||||
[berTable, ~] = db.queryDB(filterParams, selectedFields);
|
||||
|
||||
if ~isnumeric(berTable.ber)
|
||||
foundBerFlag = ~isnan(str2num(berTable.ber));
|
||||
else
|
||||
foundBerFlag = 1;
|
||||
end
|
||||
|
||||
% Display information about the found BER entries
|
||||
% fprintf('Found %d BER entries for run_id %d.\n', size(berTable, 1), run_id);
|
||||
end
|
||||
@@ -0,0 +1,85 @@
|
||||
|
||||
precomp_path = "C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\precomp";
|
||||
precomp_fn = "lab_high_speed";
|
||||
precomp_mode = 2; %0=do nothing ; 1= measure; 2=precomp active
|
||||
db_precode = 1;
|
||||
db_coding_approach = 1;
|
||||
|
||||
fsym = 224e9;
|
||||
fdac = 256e9;
|
||||
random_key = 0;
|
||||
M = 4;
|
||||
|
||||
if (db_precode==1)&&(db_coding_approach==0)
|
||||
|
||||
if M == 4
|
||||
pulsef=1;
|
||||
precomp_amp_max = -50;
|
||||
elseif M == 6
|
||||
pulsef=0;
|
||||
precomp_amp_max = -50;
|
||||
elseif M == 8
|
||||
pulsef=0;
|
||||
precomp_amp_max = -50;
|
||||
end
|
||||
|
||||
elseif (db_precode==1)&&(db_coding_approach==1)
|
||||
|
||||
if M == 4
|
||||
pulsef=1;
|
||||
precomp_amp_max = -38;
|
||||
pulsef = 1;
|
||||
elseif M == 6
|
||||
pulsef=0;
|
||||
precomp_amp_max = -38;
|
||||
pulsef = 1;
|
||||
elseif M == 8
|
||||
pulsef=0;
|
||||
precomp_amp_max = -38;
|
||||
pulsef = 1;
|
||||
end
|
||||
|
||||
elseif (db_precode==0)&&(db_coding_approach==0)
|
||||
|
||||
if M == 4
|
||||
pulsef=1;
|
||||
precomp_amp_max = -37;
|
||||
pulsef = 1;
|
||||
elseif M == 6
|
||||
pulsef=0;
|
||||
precomp_amp_max = -34;
|
||||
pulsef = 1;
|
||||
elseif M == 8
|
||||
pulsef=0;
|
||||
precomp_amp_max = -34;
|
||||
pulsef = 0;
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
rcalpha = 0.05;
|
||||
Pform = Pulseformer("fsym",fsym,"fdac",4*fsym,"pulse","rrc","pulselength",16,"rrcalpha",rcalpha);
|
||||
|
||||
|
||||
Pamsource = PAMsource(...
|
||||
"fsym",fsym,"M",M,"order",19,"useprbs",1,...
|
||||
"fs_out",fdac,...
|
||||
"applyclipping",0,"clipfactor",1.2,...
|
||||
"applypulseform",pulsef,"pulseformer",Pform,...
|
||||
"randkey",random_key,...
|
||||
"db_precode",db_precode,"db_encode",db_coding_approach,...
|
||||
"mrds_code",0,"mrds_blocklength",512);
|
||||
|
||||
[Digi_sig,Symbols,Bits] = Pamsource.process();
|
||||
|
||||
Digi_sig.spectrum("displayname","TX with precomp","fignum",2223,"normalizeToNyquist",0,"normalizeTo0dB",0);
|
||||
|
||||
precomp_est = ChannelFreqResp("Nacq",2048,"Navg",100,"Ncp",63,'f_ref',Digi_sig.fs);
|
||||
|
||||
Digi_sig = precomp_est.precomp(Digi_sig,'maxampdb',precomp_amp_max,'loadPath',precomp_path,'fileName',precomp_fn);
|
||||
|
||||
Digi_sig = Digi_sig.resample("fs_out",fdac);
|
||||
Digi_sig= Digi_sig.normalize("mode","rms");
|
||||
Digi_sig.spectrum("displayname","TX After precomp","fignum",2223,"normalizeToNyquist",0,"normalizeTo0dB",0);
|
||||
|
||||
|
||||
@@ -1,23 +1,25 @@
|
||||
|
||||
tic
|
||||
basePath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\';
|
||||
useGui = 0;
|
||||
|
||||
db = DBHandler("pathToDB",[basePath,'silas_labor.db']);
|
||||
|
||||
toc
|
||||
|
||||
if useGui
|
||||
filterParams = db.promptFilterParameters();
|
||||
selectedFields = db.promptSelectFields();
|
||||
else
|
||||
filterParams = db.tables;
|
||||
filterParams.Configurations = struct( ...
|
||||
'bitrate', [], ...
|
||||
'db_mode', [], ...
|
||||
'fiber_length', 10, ...
|
||||
'bitrate', 300e9, ...
|
||||
'db_mode', 0, ...
|
||||
'fiber_length', 1, ...
|
||||
'interference_attenuation', [], ...
|
||||
'interference_path_length', [], ...
|
||||
'is_mpi', 0, ...
|
||||
'pam_level', [], ...
|
||||
'pam_level', 4, ...
|
||||
'precomp_amp', [], ...
|
||||
'rop_attenuation', 0, ...
|
||||
'rop_attenuation', [], ...
|
||||
'symbolrate', [], ...
|
||||
'v_awg', [], ...
|
||||
'v_bias', [], ...
|
||||
@@ -26,15 +28,30 @@ else
|
||||
% filterParams.Runs.run_id = 3303;
|
||||
%filterParams.Equalizer.eq_id = equalizer_structure.vnle;
|
||||
selectedFields = {'Runs.run_id','Runs.tx_bits_path', 'Runs.tx_symbols_path', 'Runs.rx_sync_path','Runs.rx_raw_path',...
|
||||
'Configurations.db_mode','Configurations.pam_level','Configurations.bitrate','Configurations.fiber_length','Configurations.wavelength','Configurations.precomp_amp'};
|
||||
'Configurations.db_mode','Configurations.pam_level','Configurations.bitrate','Configurations.fiber_length','Configurations.wavelength','Configurations.precomp_amp','BERs.ber'};
|
||||
end
|
||||
|
||||
[dataTable,sql_query] = db.queryDB(filterParams, selectedFields);
|
||||
fprintf('Found %d entries for requested Configuration. IDs are: %s \n',size(dataTable,1),jsonencode(dataTable.run_id));
|
||||
toc
|
||||
|
||||
[dataTable,sql_query] = db.queryDB(filterParams, selectedFields);
|
||||
[~, uniqueIdx] = unique(dataTable.run_id); % Get unique run_id indices
|
||||
dataTable = dataTable(uniqueIdx,:); % Extract unique configurations for each run_id
|
||||
fprintf('Found %d entries for requested Configuration. IDs are: %s \n \n',size(dataTable,1),jsonencode(dataTable.run_id(1:min(size(dataTable,1),100))));
|
||||
|
||||
toc
|
||||
|
||||
fprintf('Processing: %d%%', 0);
|
||||
%2) Process Measurement Config
|
||||
for i = 1:size(dataTable,1)
|
||||
fprintf('\n%s CURRENT ID: %d == %d KM == %s PAM %d == %d Gbit/s == %d nm %s \n \n', repmat('=', 1, 10), dataTable.run_id(i), dataTable.fiber_length(i) ,db_mode(dataTable.db_mode(i)), dataTable.pam_level(i) ,dataTable.bitrate(i).*1e-9,dataTable.wavelength(i), repmat('=', 1, 10)); % Print a blank line, then a thick line of 80 '=' characters, then another blank line
|
||||
|
||||
fprintf('\b\b\b\b%4d', i); % Backspace 3 characters, then overwrite
|
||||
|
||||
[~, foundBerFlag] = getBerForRunId(db, dataTable.run_id(i));
|
||||
if foundBerFlag
|
||||
continue
|
||||
end
|
||||
|
||||
fprintf('\n%s T: %f CURRENT ID: %d == %d KM == %s PAM %d == %d Gbit/s == %d nm %s \n \n', repmat('=', 1, 10), toc/60, dataTable.run_id(i), dataTable.fiber_length(i) ,db_mode(dataTable.db_mode(i)), dataTable.pam_level(i) ,dataTable.bitrate(i).*1e-9,dataTable.wavelength(i), repmat('=', 1, 10)); % Print a blank line, then a thick line of 80 '=' characters, then another blank line
|
||||
|
||||
% FROM NOW ON, ONE Run_id IS CHOSEN AND WILL BE DSP'd
|
||||
|
||||
@@ -74,13 +91,13 @@ for i = 1:size(dataTable,1)
|
||||
%VNLE
|
||||
eq_vnle(o) = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",0.05,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
[eq_sig,eq_noise,ber_vnle(o),totalErrors] = vnle(eq_vnle(o),M,rx_sig,tx_symbols, tx_bits);
|
||||
|
||||
|
||||
%VNLE + PF + MLSE
|
||||
eq_mlse(o) = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",0.05,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
pf_(o) = Postfilter("ncoeff",2);
|
||||
mlse_(o) = MLSE("DIR",[0,0],"duobinary_output",0,"M",[],"trellis_states",[]);
|
||||
[eq_sig,eq_noise,ber_mlse(o),totalErrors] = vnle_postfilter_mlse(eq_mlse(o) , pf_(o), mlse_(o),M, rx_sig,tx_symbols, tx_bits);
|
||||
|
||||
|
||||
case db_mode.db_precoded
|
||||
|
||||
%EQ targets DB => less precompensation; pre-coded
|
||||
@@ -141,7 +158,8 @@ for i = 1:size(dataTable,1)
|
||||
end
|
||||
end
|
||||
|
||||
fprintf('\n%s SIMULATION COMPLETE %s \n \n', repmat('=', 1, 35), repmat('=', 1, 35)); % Print a blank line, then a thick line of 80 '=' characters, then another blank line
|
||||
|
||||
fprintf('\n%s SIMULATION COMPLETE AFTER %f MINUTES %s \n \n', repmat('=', 1, 35), toc/60 ,repmat('=', 1, 35)); % Print a blank line, then a thick line of 80 '=' characters, then another blank line
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -13,9 +13,14 @@ rop_atten_vals = wh.parameter.rop_atten.values;
|
||||
figure(18)
|
||||
tiledlayout(3, 3, 'TileSpacing', 'compact', 'Padding', 'compact');
|
||||
|
||||
%CHANGE PAM FORMAT HERE (use 4,6,8)
|
||||
for M_choose = [8]
|
||||
sgtitle(['PAM',num2str(M_choose)])
|
||||
for l = 1:numel(lambda_vals)
|
||||
ber_vnle = [];
|
||||
ber_vnle_mlse= [];
|
||||
ber_db= [];
|
||||
ber_db_enc= [];
|
||||
for b = 1:numel(bitrate_vals)
|
||||
|
||||
cel = wh.getStoValue('ber_vnle',M_choose(1),lambda_vals(l),bitrate_vals(b),duobinary_vals(1),rop_atten_vals(1));
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
|
||||
|
||||
folderPath = "/Volumes/NT-Labor/2024/sioe/High Speed Messungen Oktober/";
|
||||
|
||||
% Get list of all files in the folder and subfolders
|
||||
fileList = dir(fullfile(folderPath, '**', '*'));
|
||||
|
||||
% Loop through each file
|
||||
for i = 1:length(fileList)
|
||||
% Get the file name and path
|
||||
oldFileName = fileList(i).name;
|
||||
oldFilePath = fullfile(fileList(i).folder, oldFileName);
|
||||
|
||||
% Skip if it’s a directory or hidden file
|
||||
if fileList(i).isdir || startsWith(oldFileName, '.')
|
||||
continue;
|
||||
end
|
||||
|
||||
ismat = strfind(oldFileName, '.mat');
|
||||
|
||||
if ismat
|
||||
continue;
|
||||
else
|
||||
|
||||
% Find position of last dot (for file extension)
|
||||
dotIndex = strfind(oldFileName, '.');
|
||||
|
||||
% Only proceed if there is more than one dot in the file name
|
||||
if ~isempty(dotIndex)
|
||||
|
||||
% Replace all dots in the "base name" with underscores
|
||||
sanitizedBaseName = strrep(oldFileName, '.', '_');
|
||||
|
||||
% Create the new file name with the corrected extension
|
||||
newFileName = [sanitizedBaseName, '.mat'];
|
||||
|
||||
% Full path of the new file
|
||||
newFilePath = fullfile(fileList(i).folder, newFileName);
|
||||
|
||||
% Rename the file
|
||||
movefile(oldFilePath, newFilePath);
|
||||
fprintf('Renamed: %s -> %s\n', oldFilePath, newFilePath);
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,6 +16,10 @@ l = 6;
|
||||
for m = 1:numel(M_vals)
|
||||
sgtitle(['Lambda: ',num2str(lambda_vals(l)),' nm'])
|
||||
%for l = 1:numel(lambda_vals)
|
||||
ber_vnle = [];
|
||||
ber_vnle_mlse= [];
|
||||
ber_db= [];
|
||||
ber_db_enc= [];
|
||||
for b = 1:numel(bitrate_vals)
|
||||
|
||||
M_choose = M_vals(m);
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
|
||||
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');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
220
projects/IMDD_base_system/imdd_example.m
Normal file
220
projects/IMDD_base_system/imdd_example.m
Normal file
@@ -0,0 +1,220 @@
|
||||
function [ber] = imdd_example(varargin)
|
||||
% BASIC IMDD Model...
|
||||
% varargin is either empty or a struct, i.e.:
|
||||
%
|
||||
|
||||
|
||||
|
||||
curFolder = pwd;
|
||||
funcFolder=fileparts(mfilename('fullpath'));
|
||||
if ~isempty(funcFolder)
|
||||
cd(funcFolder);
|
||||
end
|
||||
|
||||
% TX
|
||||
M = 4;
|
||||
fsym = 180e9;
|
||||
f_nyquist = fsym/2;
|
||||
apply_pulsef = 0;
|
||||
fdac = 2*fsym;%256e9;
|
||||
fadc = 2*fsym;%256e9;
|
||||
fdac = 256e9;
|
||||
fadc = 256e9;
|
||||
random_key = 1;
|
||||
db_precode = 0;
|
||||
emulate_precode = 0;
|
||||
discard_precode = 0;
|
||||
db_encode = 0;
|
||||
% duob_mode = db_mode.db_emulate;
|
||||
emulate_db = 1;
|
||||
rcalpha = 0.05;
|
||||
kover = 16;
|
||||
vbias_rel = 0.5;
|
||||
u_pi = 2.9;
|
||||
vbias = -vbias_rel*u_pi;
|
||||
laser_wavelength = 1310;
|
||||
laser_linewidth = 0;
|
||||
tx_bw_nyquist = 1.5;
|
||||
|
||||
% Channel
|
||||
link_length = 1;
|
||||
|
||||
% RX
|
||||
rop = -8;
|
||||
rx_bw_nyquist = 0.7;
|
||||
|
||||
% EQ
|
||||
eq_mode = equalizer_structure.vnle_pf_mlse;
|
||||
ffe_order=[50,0,0];
|
||||
vnle_order=[50,7,7];
|
||||
dfe_order = [2 0 0];
|
||||
|
||||
len_tr = 4096*2;
|
||||
mu_ffe = [0.0004 0.0004 0.0004];
|
||||
mu_dfe = 0.0004;
|
||||
mu_dc = 0.00;
|
||||
|
||||
dfe_ = sum(dfe_order)>0;
|
||||
|
||||
% Parse optional input arguments
|
||||
if ~isempty(varargin)
|
||||
var_s = varargin{1};
|
||||
if isstruct(var_s)
|
||||
fields = fieldnames(var_s);
|
||||
for i = 1:numel(fields)
|
||||
eval([fields{i}, ' = ', num2str( var_s.(fields{i}) ), ';']);
|
||||
fprintf("%s <-- %.2f \n", fields{i}, var_s.(fields{i}));
|
||||
end
|
||||
else
|
||||
error('Optional variables should be passed as a struct.');
|
||||
end
|
||||
end
|
||||
|
||||
%%%% TX Signal
|
||||
Pform = Pulseformer("fsym",fsym,"fdac",4*fsym,"pulse","rrc","pulselength",16,"rrcalpha",rcalpha);
|
||||
|
||||
[Digi_sig,Symbols,Bits] = PAMsource(...
|
||||
"fsym",fsym,"M",M,"order",19,"useprbs",1,...
|
||||
"fs_out",fdac,...
|
||||
"applyclipping",0,"clipfactor",1.5,...
|
||||
"applypulseform",apply_pulsef,"pulseformer",Pform,...
|
||||
"randkey",random_key,...
|
||||
"db_precode",db_precode,"db_encode",db_encode,...
|
||||
"mrds_code",0,"mrds_blocklength",512).process();
|
||||
|
||||
Digi_sig.spectrum("displayname",'Digi Spectrum','fignum',10,'normalizeTo0dB',1);
|
||||
|
||||
%%%%% AWG
|
||||
% El_sig = M8199A("kover",kover).process(Digi_sig);
|
||||
El_sig = AWG("fdac",fdac,"f_cutoff",fsym,"lpf_active",0,"kover",kover,"bit_resolution",12,"upsampling_method","samplehold","precomp_sinc_rolloff",1).process(Digi_sig);
|
||||
% El_sig.spectrum("displayname",'Digi Spectrum','fignum',100,'normalizeTo0dB',0);
|
||||
% El_sig = El_sig.setPower(0,"dBm");
|
||||
|
||||
%%%%% Low-pass el. components %%%%%%
|
||||
El_sig = Filter('filtdegree',4,"f_cutoff",tx_bw_nyquist.*f_nyquist,"fs",fdac*kover,"filterType",filtertypes.butterworth,"active",true).process(El_sig);
|
||||
|
||||
%%%%% Electrical Driver Amplifier %%%%%%
|
||||
El_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",3).process(El_sig);
|
||||
El_sig = El_sig.normalize("mode","oneone");
|
||||
|
||||
%%%%% MODULATE E/O CONVERSION %%%%%%
|
||||
[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).process(El_sig);
|
||||
|
||||
%%%%%% Fiber %%%%%%
|
||||
Opt_sig = Fiber("fsimu",Opt_sig.fs,"fiber_length",link_length/1000,"alpha",0.3,"D",0,"lambda0",1310,"gamma",0,"Dslope",0.07).process(Opt_sig);
|
||||
|
||||
%%%%%% ROP %%%%%%
|
||||
Rx_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",rop).process(Opt_sig);
|
||||
|
||||
|
||||
|
||||
%%%%%% PD Square Law %%%%%%
|
||||
Rx_sig = Photodiode("fsimu",fdac*kover,"dark_current",2e-08,"responsivity",1,"temperature",20,"nep",1.8e-11).process(Rx_sig);
|
||||
|
||||
|
||||
%%%%%% Low-pass RX (PD, El. Connectors and Scope %%%%%%
|
||||
Rx_sig = Filter('filtdegree',4,"f_cutoff",rx_bw_nyquist.*f_nyquist,"fs",fdac*kover,"filterType",filtertypes.butterworth,"active",true).process(Rx_sig);
|
||||
|
||||
% %%%%%% Low-pass Scope %%%%%%
|
||||
%dactivated in scope module!
|
||||
Lp_scpe = Filter('filtdegree',4,"f_cutoff",10e9,"fs",fadc,"filterType",filtertypes.butterworth,"active",true);
|
||||
|
||||
% Rx_sig.spectrum("displayname",'Analog Rx Spectrum','fignum',100,'normalizeTo0dB',1);
|
||||
|
||||
%%%%%% Scope %%%%%%
|
||||
Scpe_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',0,'H_lpf',Lp_scpe).process(Rx_sig);
|
||||
|
||||
% Scpe_sig.spectrum("displayname",'Digital (256 GSa/s) Rx Spectrum','fignum',100,'normalizeTo0dB',1);
|
||||
|
||||
%%%%%% Sample to 2x fsym %%%%%%
|
||||
Scpe_sig = Scpe_sig.resample("fs_in",fadc,"fs_out",2*fsym);
|
||||
|
||||
%%%%%% Sync Rx signal with reference %%%%%%
|
||||
[Scpe_sig,S] = Scpe_sig.tsynch("reference",Symbols,"fs_ref",fsym);
|
||||
|
||||
Scpe_sig.spectrum("displayname",'Prior DSP (2x fsym) Spectrum','fignum',100,'normalizeTo0dB',1);
|
||||
|
||||
%%% EQUALIZING
|
||||
ber = struct();
|
||||
switch eq_mode
|
||||
|
||||
case equalizer_structure.ffe
|
||||
|
||||
%FFE
|
||||
if db_precode
|
||||
Bits_ = PAMmapper(M,0).demap(Symbols);
|
||||
else
|
||||
Bits_ = Bits;
|
||||
end
|
||||
|
||||
eq_ffe = EQ("Ne",ffe_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
% eq_ffe = FFE("epochs_tr",5,"epochs_dd",5,"len_tr",len_tr,"mu_dd",mu_ffe(1),"mu_tr",0,"order",ffe_order(1),"sps",2,"decide",0);
|
||||
% eq_ffe = FFE_DCremoval("epochs_tr",5,"epochs_dd",5,"len_tr",len_tr,"mu_dd",mu_ffe(1),"mu_tr",0,"order",ffe_order(1),"sps",2,"decide",0,"dc_buffer_len",512,"mu_dc",0.05);
|
||||
|
||||
[eq_sig,eq_noise,ber.ber_ffe,totalErrors] = vnle( eq_ffe,M,Scpe_sig ,Symbols, Bits_);
|
||||
eq_noise.spectrum("displayname",'Noise Spectrum after FFE','fignum',41,'normalizeTo0dB',0);
|
||||
|
||||
case equalizer_structure.vnle
|
||||
|
||||
if db_precode
|
||||
Bits_ = PAMmapper(M,0).demap(Symbols);
|
||||
else
|
||||
Bits_ = Bits;
|
||||
end
|
||||
|
||||
|
||||
%VNLE
|
||||
eq_vnle = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
[eq_sig,eq_noise,ber.ber_vnle,totalErrors] = vnle(eq_vnle,M,Scpe_sig ,Symbols, Bits_);
|
||||
eq_noise.spectrum("displayname",'Noise Spectrum after VNLE','fignum',41,'normalizeTo0dB',0);
|
||||
case equalizer_structure.vnle_pf_mlse
|
||||
|
||||
if db_precode
|
||||
Bits_ = PAMmapper(M,0).demap(Symbols);
|
||||
else
|
||||
Bits_ = Bits;
|
||||
end
|
||||
|
||||
%VNLE + PF + MLSE
|
||||
eq_mlse = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
eq_mlse = FFE_DCremoval("epochs_tr",5,"epochs_dd",5,"len_tr",len_tr,"mu_dd",mu_ffe(1),"mu_tr",0,"order",ffe_order(1),"sps",2,"decide",0,"dc_buffer_len",512,"mu_dc",0.05);
|
||||
eq_mlse = FFE("epochs_tr",5,"epochs_dd",5,"len_tr",len_tr,"mu_dd",mu_ffe(1),"mu_tr",0,"order",ffe_order(1),"sps",2,"decide",0);
|
||||
|
||||
pf_ = Postfilter("ncoeff",1);
|
||||
mlse_ = MLSE("DIR",[0,0],"duobinary_output",0,"M",[],"trellis_states",[]);
|
||||
[eq_sig,eq_noise,ber.ber_mlse,totalErrors] = vnle_postfilter_mlse(eq_mlse , pf_, mlse_,M, Scpe_sig ,Symbols, Bits_);
|
||||
pf_.showFilter(eq_noise);
|
||||
eq_noise.spectrum("displayname",'Noise Spectrum after VNLE+PF','fignum',41,'normalizeTo0dB',0);
|
||||
case equalizer_structure.db_precoded
|
||||
|
||||
%EQ targets DB => less precompensation; pre-coded
|
||||
mlse_db_pre = MLSE("DIR",[1,1],"duobinary_output",1,"M",M,"trellis_states",PAMmapper(M,0).levels);
|
||||
eq_db_pre = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
[eq_sig,eq_noise,ber.ber_db,totalErrors] = duobinary_target(eq_db_pre, mlse_db_pre,M, Scpe_sig ,Symbols, Bits);
|
||||
eq_noise.spectrum("displayname",'Noise Spectrum after DB','fignum',41,'normalizeTo0dB',0);
|
||||
%->append BER to DB
|
||||
|
||||
case equalizer_structure.db_encoded
|
||||
|
||||
%db signaling => db encoded
|
||||
mlse_db_enc = MLSE("DIR",[1,1],"duobinary_output",1,"M",M,"trellis_states",PAMmapper(M,0).levels);
|
||||
eq_db_enc = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
[eq_sig,eq_noise,ber.ber_db_enc,totalErrors] = duobinary_signaling(eq_db_enc, mlse_db_enc,M, Scpe_sig ,Symbols, Bits);
|
||||
%->append BER to DB
|
||||
end
|
||||
|
||||
% fprintf('BER FFE: %.2e \n',ber.ber_mlse);
|
||||
% % El_sig.spectrum("displayname",'Tx Spectrum','fignum',10,'normalizeTo0dB',1);
|
||||
% Scpe_sig.spectrum("displayname",'Rx Spectrum','fignum',100,'normalizeTo0dB',1);
|
||||
|
||||
|
||||
|
||||
|
||||
if ~isempty(curFolder)
|
||||
cd(curFolder);
|
||||
end
|
||||
|
||||
end
|
||||
BIN
projects/IMDD_base_system/imdd_example_live.mlx
Normal file
BIN
projects/IMDD_base_system/imdd_example_live.mlx
Normal file
Binary file not shown.
26
projects/IMDD_base_system/imdd_it.m
Normal file
26
projects/IMDD_base_system/imdd_it.m
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
% basePath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\';
|
||||
% db = DBHandler("pathToDB",[basePath,'silas_labor.db']);
|
||||
|
||||
uloops = struct;
|
||||
uloops.bitrate = [300,330,360,390,420,450,480].*1e9;
|
||||
uloops.M = 4;
|
||||
|
||||
wh = DataStorage(uloops);
|
||||
wh.addStorage("ber");
|
||||
|
||||
wh = submit_simulations(wh,db,"parallel",0,"simulation_mode",0);
|
||||
|
||||
a = wh.getStoValue('ber', uloops.bitrate,uloops.M);
|
||||
for i = 1:numel(a)
|
||||
bers(i) = a{i}.ber_mlse;
|
||||
end
|
||||
|
||||
figure(2024)
|
||||
hold on
|
||||
plot(uloops.bitrate.*1e-9,bers);
|
||||
yline(3.8e-3,'LineWidth',2,'DisplayName','3.8e-3');
|
||||
yline(2e-2,'LineWidth',2,'LineStyle','--','DisplayName','2e-2');
|
||||
beautifyBERplot()
|
||||
legend
|
||||
|
||||
172
projects/IMDD_base_system/imdd_labdata_example.m
Normal file
172
projects/IMDD_base_system/imdd_labdata_example.m
Normal file
@@ -0,0 +1,172 @@
|
||||
% function [ber] = imdd_labdata_example(varargin)
|
||||
|
||||
% TX
|
||||
M = 4;
|
||||
fsym = 224e9;
|
||||
f_nyquist = fsym/2;
|
||||
apply_pulsef = 0;
|
||||
fdac = 2*fsym;%256e9;
|
||||
fadc = 2*fsym;%256e9;
|
||||
fdac = 256e9;
|
||||
fadc = 256e9;
|
||||
random_key = 1;
|
||||
db_precode = 1;
|
||||
db_encode = 0;
|
||||
rcalpha = 0.05;
|
||||
kover = 16;
|
||||
vbias_rel = 0.5;
|
||||
u_pi = 2.9;
|
||||
vbias = -vbias_rel*u_pi;
|
||||
laser_wavelength = 1293;
|
||||
laser_linewidth = 0;
|
||||
tx_bw_nyquist = 1.5;
|
||||
|
||||
% Channel
|
||||
link_length = 0;
|
||||
|
||||
% RX
|
||||
rop = -7.5;
|
||||
rx_bw_nyquist = 1.5;
|
||||
|
||||
% EQ
|
||||
eq_mode = equalizer_structure.vnle_pf_mlse;
|
||||
ffe_order=[50,0,0];
|
||||
vnle_order=[50,7,7];
|
||||
dfe_order = [0 0 0];
|
||||
|
||||
len_tr = 4096*2;
|
||||
mu_ffe = [0.0004 0.0004 0.0004];
|
||||
mu_dfe = 0.0004;
|
||||
mu_dc = 0.05;
|
||||
|
||||
dfe_ = sum(dfe_order)>0;
|
||||
|
||||
%
|
||||
% % Parse optional input arguments
|
||||
% if ~isempty(varargin)
|
||||
% var_s = varargin{1};
|
||||
% if isstruct(var_s)
|
||||
% fields = fieldnames(var_s);
|
||||
% for i = 1:numel(fields)
|
||||
% eval([fields{i}, ' = ', num2str( var_s.(fields{i}) ), ';']);
|
||||
% fprintf("%s <-- %.2f \n", fields{i}, var_s.(fields{i}));
|
||||
% end
|
||||
% else
|
||||
% error('Optional variables should be passed as a struct.');
|
||||
% end
|
||||
% end
|
||||
|
||||
basePath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\';
|
||||
useGui = 0;
|
||||
db = DBHandler("pathToDB",[basePath,'silas_labor.db']);
|
||||
filterParams = db.tables;
|
||||
% filterParams.Runs.run_id = 2958; % no db
|
||||
% filterParams.Runs.run_id = 2937; % no db
|
||||
filterParams.Configurations = struct( ...
|
||||
'bitrate', 300e9, ...
|
||||
'db_mode', 0, ...
|
||||
'fiber_length', 1, ...
|
||||
'interference_attenuation', [], ...
|
||||
'interference_path_length', [], ...
|
||||
'is_mpi', 0, ...
|
||||
'pam_level', 4, ...
|
||||
'precomp_amp', [], ...
|
||||
'rop_attenuation', 0, ...
|
||||
'symbolrate', [], ...
|
||||
'v_awg', [], ...
|
||||
'v_bias', [], ...
|
||||
'wavelength', 1310 ...
|
||||
);
|
||||
selectedFields = {'Runs.run_id','Runs.tx_bits_path', 'Runs.tx_symbols_path', 'Runs.rx_sync_path','Runs.rx_raw_path',...
|
||||
'Configurations.db_mode','Configurations.pam_level','Configurations.bitrate','Configurations.fiber_length','Configurations.wavelength','Configurations.precomp_amp','BERs.ber'};
|
||||
|
||||
[dataTable,sql_query] = db.queryDB(filterParams, selectedFields);
|
||||
[~, uniqueIdx] = unique(dataTable.run_id); % Get unique run_id indices
|
||||
dataTable = dataTable(uniqueIdx,:); % Extract unique configurations for each run_id
|
||||
fprintf('Found %d entries for requested Configuration. IDs are: %s \n \n',size(dataTable,1),jsonencode(dataTable.run_id(1:min(size(dataTable,1),100))));
|
||||
|
||||
tx_bits = load([basePath, char(dataTable.tx_bits_path(1))]);
|
||||
tx_bits = tx_bits.Bits;
|
||||
tx_symbols = load([basePath, char(dataTable.tx_symbols_path(1))]);
|
||||
tx_symbols = tx_symbols.Symbols;
|
||||
|
||||
rx_sync = load([basePath, char(dataTable.rx_sync_path(1))]);
|
||||
rx_sync = rx_sync.S;
|
||||
|
||||
fsym = tx_symbols.fs;
|
||||
|
||||
%%%%%% Sample to 2x fsym %%%%%%
|
||||
Scpe_sig = rx_sync{1}.resample("fs_in",rx_sync{1}.fs,"fs_out",2*fsym);
|
||||
|
||||
%%%%%% Sync Rx signal with reference %%%%%%
|
||||
[Scpe_sig,S] = Scpe_sig.tsynch("reference",tx_symbols,"fs_ref",fsym);
|
||||
|
||||
Scpe_sig.spectrum("displayname",'Rx (Scpe+Sync+Resample)','fignum',100,'normalizeTo0dB',0);
|
||||
|
||||
Scpe_sig = Filter('filtdegree',4,"f_cutoff",tx_symbols.fs.*0.6,"fs",Scpe_sig.fs,"filterType",filtertypes.gaussian,"active",true).process(Scpe_sig);
|
||||
|
||||
Scpe_sig.spectrum("displayname",'Rx (Scpe+Sync+Resample+LPF)','fignum',100,'normalizeTo0dB',0);
|
||||
|
||||
%%% EQUALIZING
|
||||
ber = struct();
|
||||
switch eq_mode
|
||||
|
||||
case equalizer_structure.ffe
|
||||
|
||||
%FFE
|
||||
if db_precode
|
||||
Bits_ = PAMmapper(M,0).demap(Symbols);
|
||||
else
|
||||
Bits_ = Bits;
|
||||
end
|
||||
|
||||
eq_ffe = EQ("Ne",ffe_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
eq_ffe = FFE("epochs_tr",5,"epochs_dd",5,"len_tr",len_tr,"mu_dd",mu_ffe(1),"mu_tr",0,"order",ffe_order(1),"sps",2,"decide",0);
|
||||
eq_ffe = FFE_DCremoval("epochs_tr",5,"epochs_dd",5,"len_tr",len_tr,"mu_dd",mu_ffe(1),"mu_tr",0,"order",ffe_order(1),"sps",2,"decide",0,"dc_buffer_len",512,"mu_dc",0.05);
|
||||
|
||||
[eq_sig,eq_noise,ber.ber_ffe,totalErrors] = vnle( eq_ffe,M,Scpe_sig ,Symbols, Bits_);
|
||||
eq_noise.spectrum("displayname",'Noise Spectrum after FFE','fignum',41,'normalizeTo0dB',0);
|
||||
|
||||
case equalizer_structure.vnle
|
||||
%VNLE
|
||||
eq_vnle = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
[eq_sig,eq_noise,ber.ber_vnle,totalErrors] = vnle(eq_vnle,M,Scpe_sig ,Symbols, Bits_);
|
||||
eq_noise.spectrum("displayname",'Noise Spectrum after VNLE','fignum',41,'normalizeTo0dB',0);
|
||||
case equalizer_structure.vnle_pf_mlse
|
||||
|
||||
%VNLE + PF + MLSE
|
||||
eq_mlse = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
pf_ = Postfilter("ncoeff",1);
|
||||
mlse_ = MLSE("DIR",[0,0],"duobinary_output",0,"M",[],"trellis_states",[]);
|
||||
[eq_sig,eq_noise,ber.ber_mlse,totalErrors] = vnle_postfilter_mlse(eq_mlse , pf_, mlse_,M, Scpe_sig ,Symbols, Bits_);
|
||||
pf_.showFilter(eq_noise);
|
||||
|
||||
eq_noise.spectrum("displayname",'Noise Spectrum after VNLE+PF','fignum',41,'normalizeTo0dB',0);
|
||||
|
||||
case equalizer_structure.db_precoded
|
||||
|
||||
%EQ targets DB => less precompensation; pre-coded
|
||||
mlse_db_pre = MLSE("DIR",[1,1],"duobinary_output",1,"M",M,"trellis_states",PAMmapper(M,0).levels);
|
||||
eq_db_pre = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
[eq_sig,eq_noise,ber.ber_db,totalErrors] = duobinary_target(eq_db_pre, mlse_db_pre,M, Scpe_sig ,Symbols, Bits);
|
||||
eq_noise.spectrum("displayname",'Noise Spectrum after DB','fignum',41,'normalizeTo0dB',0);
|
||||
%->append BER to DB
|
||||
|
||||
case equalizer_structure.db_encoded
|
||||
|
||||
%db signaling => db encoded
|
||||
mlse_db_enc = MLSE("DIR",[1,1],"duobinary_output",1,"M",M,"trellis_states",PAMmapper(M,0).levels);
|
||||
eq_db_enc = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
[eq_sig,eq_noise,ber.ber_db_enc,totalErrors] = duobinary_signaling(eq_db_enc, mlse_db_enc,M, Scpe_sig ,Symbols, Bits);
|
||||
%->append BER to DB
|
||||
end
|
||||
|
||||
fprintf('BER FFE: %.2e \n',ber.ber_mlse);
|
||||
% % El_sig.spectrum("displayname",'Tx Spectrum','fignum',10,'normalizeTo0dB',1);
|
||||
% Scpe_sig.spectrum("displayname",'Rx Spectrum','fignum',100,'normalizeTo0dB',1);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
% end
|
||||
353
projects/IMDD_base_system/imdd_model.m
Normal file
353
projects/IMDD_base_system/imdd_model.m
Normal file
@@ -0,0 +1,353 @@
|
||||
function [output] = imdd_model(simulation_mode,database,varargin)
|
||||
|
||||
|
||||
|
||||
|
||||
%%% Change folder
|
||||
curFolder = pwd;
|
||||
funcFolder=fileparts(mfilename('fullpath'));
|
||||
if ~isempty(funcFolder)
|
||||
cd(funcFolder);
|
||||
end
|
||||
|
||||
%%% Run parameters
|
||||
% TX
|
||||
M = 4;
|
||||
fsym = 180e9;
|
||||
f_nyquist = fsym/2;
|
||||
apply_pulsef = 1;
|
||||
fdac = 256e9;
|
||||
fadc = 256e9;
|
||||
random_key = 1;
|
||||
|
||||
db_precode = 1;
|
||||
emulate_precode = 0;
|
||||
discard_precode = 1;
|
||||
db_encode = 0;
|
||||
% duob_mode = db_mode.db_emulate;
|
||||
emulate_db = 1;
|
||||
|
||||
rcalpha = 0.05;
|
||||
kover = 16;
|
||||
vbias_rel = 0.5;
|
||||
u_pi = 2.9;
|
||||
vbias = -vbias_rel*u_pi;
|
||||
laser_wavelength = 1310;
|
||||
laser_linewidth = 0;
|
||||
tx_bw_nyquist = 0.9;
|
||||
|
||||
% Channel
|
||||
link_length = 1;
|
||||
|
||||
% RX
|
||||
rop = -8;
|
||||
rx_bw_nyquist = 0.7;
|
||||
|
||||
% EQ
|
||||
eq_mode = equalizer_structure.vnle_pf_mlse;
|
||||
ffe_order=[50,0,0];
|
||||
vnle_order=[50,7,7];
|
||||
dfe_order = [2 0 0];
|
||||
|
||||
len_tr = 4096*2;
|
||||
mu_ffe = [0.0004 0.0004 0.0004];
|
||||
mu_dfe = 0.0004;
|
||||
mu_dc = 0.00;
|
||||
|
||||
dfe_ = sum(dfe_order)>0;
|
||||
|
||||
%%% change specific parameter if given in varargin
|
||||
% Parse optional input arguments
|
||||
if ~isempty(varargin)
|
||||
var_s = varargin{1};
|
||||
if isstruct(var_s)
|
||||
fields = fieldnames(var_s);
|
||||
for i = 1:numel(fields)
|
||||
if isnumeric(fields{i})
|
||||
eval([fields{i}, ' = ', num2str( var_s.(fields{i}) ), ';']);
|
||||
fprintf("%s <-- %.2f \n", fields{i}, var_s.(fields{i}));
|
||||
else
|
||||
eval([fields{i}, ' = ', 'var_s.(fields{',num2str(i),'})' , ';']);
|
||||
end
|
||||
|
||||
end
|
||||
else
|
||||
error('Optional variables should be passed as a struct.');
|
||||
end
|
||||
end
|
||||
|
||||
%%% run the simulation or measurement or ...
|
||||
|
||||
|
||||
if simulation_mode
|
||||
|
||||
fsym_ = floor( bitrate*1e-9./log2(M) ).*1e9;
|
||||
|
||||
if fsym_ ~= fsym
|
||||
fsym = fsym_;
|
||||
fprintf('Adapted symbolrate to %d GBd, to match provided bitrate of %d GBit/s using PAM %d \n',fsym.*1e-9,bitrate.*1e-9, M);
|
||||
end
|
||||
|
||||
tx_simulation;
|
||||
|
||||
|
||||
|
||||
Opt_sig = Fiber("fsimu",Opt_sig.fs,"fiber_length",link_length/1000,"alpha",0.3,"D",0,"lambda0",1310,"gamma",0,"Dslope",0.07).process(Opt_sig);
|
||||
|
||||
rx_simulation;
|
||||
|
||||
Scpe_cell{1} = Scpe_sig;
|
||||
|
||||
else
|
||||
|
||||
basePath = 'C:\Users\Silas\Documents\MATLAB\Datensätze\sioe_labor\';
|
||||
useGui = 0;
|
||||
% db = DBHandler("pathToDB",[basePath,'silas_labor.db']);
|
||||
filterParams = database.tables;
|
||||
% filterParams.Runs.run_id = 2958; % no db
|
||||
% filterParams.Runs.run_id = 2937; % no db
|
||||
filterParams.Configurations = struct( ...
|
||||
'bitrate', bitrate, ...
|
||||
'db_mode', db_precode+db_encode, ...
|
||||
'fiber_length', link_length, ...
|
||||
'interference_attenuation', [], ...
|
||||
'interference_path_length', [], ...
|
||||
'is_mpi', 0, ...
|
||||
'pam_level', M, ...
|
||||
'precomp_amp', [], ...
|
||||
'rop_attenuation', 0, ...
|
||||
'symbolrate', [], ...
|
||||
'v_awg', [], ...
|
||||
'v_bias', [], ...
|
||||
'wavelength', 1310 ...
|
||||
);
|
||||
|
||||
selectedFields = {'Runs.run_id','Runs.tx_bits_path', 'Runs.tx_symbols_path', 'Runs.rx_sync_path','Runs.rx_raw_path',...
|
||||
'Configurations.db_mode','Configurations.pam_level','Configurations.bitrate','Configurations.symbolrate','Configurations.fiber_length','Configurations.wavelength','Configurations.precomp_amp','BERs.ber'};
|
||||
|
||||
[dataTable,sql_query] = database.queryDB(filterParams, selectedFields);
|
||||
[~, uniqueIdx] = unique(dataTable.run_id); % Get unique run_id indices
|
||||
dataTable = dataTable(uniqueIdx,:); % Extract unique configurations for each run_id
|
||||
fprintf('Found %d entries for requested Configuration. IDs are: %s \n \n',size(dataTable,1),jsonencode(dataTable.run_id(1:min(size(dataTable,1),100))));
|
||||
|
||||
Tx_bits = load([basePath, char(dataTable.tx_bits_path(2))]);
|
||||
Tx_bits = Tx_bits.Bits;
|
||||
|
||||
Symbols = load([basePath, char(dataTable.tx_symbols_path(2))]);
|
||||
Symbols = Symbols.Symbols;
|
||||
|
||||
Scpe_load = load([basePath, char(dataTable.rx_sync_path(2))]);
|
||||
Scpe_cell = Scpe_load.S;
|
||||
|
||||
% Raw_signal = load([basePath, char(dataTable.rx_raw_path(1))]);
|
||||
% Raw_signal = Raw_signal.Scpe_sig_raw;
|
||||
|
||||
fsym = Symbols.fs;
|
||||
|
||||
end
|
||||
|
||||
output = struct();
|
||||
|
||||
for occ = 1:1%length(Scpe_cell)
|
||||
|
||||
Scpe_sig = Scpe_cell{occ};
|
||||
|
||||
%%%%%% Sample to 2x fsym %%%%%%
|
||||
Scpe_sig = Scpe_sig.resample("fs_out",2*fsym);
|
||||
|
||||
%%%%%% Sync Rx signal with reference %%%%%%
|
||||
[Scpe_sig,S] = Scpe_sig.tsynch("reference",Symbols,"fs_ref",fsym);
|
||||
|
||||
% Scpe_sig.spectrum("displayname",'Rx (Scpe+Sync+Resample)','fignum',100,'normalizeTo0dB',0);
|
||||
|
||||
Scpe_sig = Filter('filtdegree',4,"f_cutoff",Symbols.fs.*0.6,"fs",Scpe_sig.fs,"filterType",filtertypes.gaussian,"active",true).process(Scpe_sig);
|
||||
|
||||
Scpe_sig.spectrum("displayname",'Rx (Scpe+Sync+Resample+LPF)','fignum',110,'normalizeTo0dB',0);
|
||||
|
||||
Scpe_sig.plot("displayname",'Filtered Scope Signal','fignum',111,'clear',1);
|
||||
|
||||
Scpe_sig.eye(fsym,M);
|
||||
|
||||
|
||||
|
||||
%%% EQUALIZING
|
||||
|
||||
switch eq_mode
|
||||
|
||||
case equalizer_structure.ffe
|
||||
|
||||
%FFE
|
||||
if db_precode
|
||||
Bits_ = PAMmapper(M,0).demap(Symbols);
|
||||
else
|
||||
Bits_ = Bits;
|
||||
end
|
||||
|
||||
eq_ffe = EQ("Ne",ffe_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
% eq_ffe = FFE("epochs_tr",5,"epochs_dd",5,"len_tr",len_tr,"mu_dd",mu_ffe(1),"mu_tr",0,"order",ffe_order(1),"sps",2,"decide",0);
|
||||
% eq_ffe = FFE_DCremoval("epochs_tr",5,"epochs_dd",5,"len_tr",len_tr,"mu_dd",mu_ffe(1),"mu_tr",0,"order",ffe_order(1),"sps",2,"decide",0,"dc_buffer_len",512,"mu_dc",0.05);
|
||||
|
||||
[eq_sig,Eq_noise,ber_ffe(occ),totalErrors] = vnle( eq_ffe,M,Scpe_sig ,Symbols, Bits_);
|
||||
Eq_noise.spectrum("displayname",'Noise Spectrum after FFE','fignum',41,'normalizeTo0dB',0);
|
||||
|
||||
fprintf('BER FFE: %.2e \n',ber_ffe(occ));
|
||||
|
||||
case equalizer_structure.vnle
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%VNLE
|
||||
eq_vnle = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",0);
|
||||
|
||||
[Eq_sig,Eq_noise] = eq_vnle.process(Scpe_sig,Symbols);
|
||||
|
||||
Eq_sig = PAMmapper(M,0).quantize(Eq_sig);
|
||||
|
||||
if emulate_precode && db_precode == 0
|
||||
% emulation
|
||||
Eq_sig = Duobinary().encode(Eq_sig);
|
||||
Eq_sig = Duobinary().decode(Eq_sig);
|
||||
|
||||
Symbols= Duobinary().encode(Symbols);
|
||||
Symbols = Duobinary().decode(Symbols);
|
||||
Tx_bits = PAMmapper(M,0).demap(Symbols);
|
||||
elseif db_precode == 1 && db_encode == 0 && discard_precode == 1
|
||||
% normal dsp for precoded sequence
|
||||
Tx_bits = PAMmapper(M,0).demap(Symbols);
|
||||
|
||||
elseif db_precode == 1 && db_encode == 1
|
||||
error('not implemented')
|
||||
|
||||
elseif db_precode == 1 && db_encode == 0
|
||||
Eq_sig = Duobinary().encode(Eq_sig);
|
||||
Eq_sig = Duobinary().decode(Eq_sig);
|
||||
end
|
||||
|
||||
% M = numel(unique(tx_symbols.signal));
|
||||
Rx_bits = PAMmapper(M,0).demap(Eq_sig);
|
||||
|
||||
[~,numErrors,ber,~] = calc_ber(Rx_bits.signal,Tx_bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
|
||||
|
||||
Eq_noise.spectrum("displayname",'Noise Spectrum after VNLE','fignum',41,'normalizeTo0dB',0);
|
||||
|
||||
output.ber_vnle(occ) = ber;
|
||||
|
||||
if 1c
|
||||
figure(51);
|
||||
clf
|
||||
title(sprintf('DB coded PAM after EQ ; BER: %1.2e',M, ber ));
|
||||
constellation = unique(Symbols.signal);
|
||||
received = NaN(numel(constellation),length(Symbols));
|
||||
for lvl = 1:numel(constellation)
|
||||
%Separate the equalized signal into the
|
||||
%respective levels based on the actually
|
||||
%transmitted level!
|
||||
received(lvl,Symbols.signal==constellation(lvl)) = Eq_sig.signal(Symbols.signal==constellation(lvl));
|
||||
intermediate = received(lvl,:);
|
||||
cnt(lvl) = numel(intermediate(~isnan(intermediate)));
|
||||
hold on
|
||||
histogram(received(lvl,:),1000,"EdgeAlpha",0,'DisplayName',['Lvl ',num2str(lvl),' | ',num2str(cnt(lvl)),' entries']);
|
||||
end
|
||||
legend
|
||||
end
|
||||
|
||||
Eq_sig.eye(fsym,M,"displayname",'Eye after EQ','fignum',52);
|
||||
Eq_sig.spectrum("displayname",'Spectrum after EQ','fignum',53,'normalizeTo0dB',1);
|
||||
Scpe_sig.spectrum("displayname",'Spectrum before EQ','fignum',53,'normalizeTo0dB',1);
|
||||
fprintf('BER FFE: %.2e \n',ber);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case equalizer_structure.vnle_pf_mlse
|
||||
|
||||
|
||||
%VNLE + PF + MLSE
|
||||
eq_mlse = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
% eq_mlse = FFE_DCremoval("epochs_tr",5,"epochs_dd",5,"len_tr",len_tr,"mu_dd",mu_ffe(1),"mu_tr",0,"order",ffe_order(1),"sps",2,"decide",0,"dc_buffer_len",1,"mu_dc",0.05);
|
||||
% eq_mlse = FFE("epochs_tr",5,"epochs_dd",5,"len_tr",len_tr,"mu_dd",mu_ffe(1),"mu_tr",0,"order",ffe_order(1),"sps",2,"decide",0);
|
||||
% eq_mlse = FFE_DCremoval("epochs_tr",5,"epochs_dd",5,"len_tr",len_tr,"mu_dd",mu_ffe(1),"mu_tr",0,"order",ffe_order(1),"sps",2,"decide",0,"dc_buffer_len",512,"mu_dc",0.05);
|
||||
|
||||
pf_ = Postfilter("ncoeff",2);
|
||||
mlse_ = MLSE("DIR",[0,0],"duobinary_output",0,"M",[],"trellis_states",[]);
|
||||
|
||||
%FFE or VNLE
|
||||
[Eq_sig,Eq_noise] = eq_mlse.process(Scpe_sig,Symbols);
|
||||
|
||||
Eq_sig = pf_.process(Eq_sig,Eq_noise);
|
||||
|
||||
%M = numel(unique(tx_symbols.signal));
|
||||
mlse_.DIR = pf_.burg_coeff;
|
||||
mlse_.trellis_states = PAMmapper(M,0).levels;
|
||||
mlse_.M = M;
|
||||
|
||||
Eq_sig = mlse_.process(Eq_sig);
|
||||
pf_.showFilter(Eq_noise);
|
||||
% Eq_noise.spectrum("displayname",'Noise Spectrum after VNLE+PF','fignum',41,'normalizeTo0dB',0);
|
||||
|
||||
if emulate_precode && db_precode == 0
|
||||
% emulation
|
||||
Eq_sig = Duobinary().encode(Eq_sig);
|
||||
Eq_sig = Duobinary().decode(Eq_sig);
|
||||
|
||||
Symbols= Duobinary().encode(Symbols);
|
||||
Symbols = Duobinary().decode(Symbols);
|
||||
Tx_bits = PAMmapper(M,0).demap(Symbols);
|
||||
elseif db_precode == 1 && db_encode == 0 && discard_precode == 1
|
||||
% normal dsp for precoded sequence
|
||||
Tx_bits = PAMmapper(M,0).demap(Symbols);
|
||||
|
||||
elseif db_precode == 1 && db_encode == 1
|
||||
error('not implemented')
|
||||
|
||||
elseif db_precode == 1 && db_encode == 0
|
||||
Eq_sig = Duobinary().encode(Eq_sig);
|
||||
Eq_sig = Duobinary().decode(Eq_sig);
|
||||
end
|
||||
|
||||
Rx_bits = PAMmapper(M,0).demap(Eq_sig);
|
||||
|
||||
[~,numErrors,ber,~] = calc_ber(Rx_bits.signal,Tx_bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
|
||||
|
||||
output.ber_mlse(occ) = ber;
|
||||
output.pf_taps(occ,:) = pf_.burg_coeff;
|
||||
|
||||
|
||||
fprintf('BER MLSE: %.2e \n',ber);
|
||||
|
||||
case equalizer_structure.db_precoded
|
||||
|
||||
%EQ targets DB => less precompensation; pre-coded
|
||||
mlse_db_pre = MLSE("DIR",[1,1],"duobinary_output",1,"M",M,"trellis_states",PAMmapper(M,0).levels);
|
||||
eq_db_pre = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
[eq_sig,Eq_noise,ber_db(occ),totalErrors] = duobinary_target(eq_db_pre, mlse_db_pre,M, Scpe_sig ,Symbols, Bits);
|
||||
Eq_noise.spectrum("displayname",'Noise Spectrum after DB','fignum',41,'normalizeTo0dB',0);
|
||||
%->append BER to DB
|
||||
|
||||
fprintf('BER VNLE+DB: %.2e \n',ber_db(occ));
|
||||
|
||||
case equalizer_structure.db_encoded
|
||||
|
||||
%db signaling => db encoded
|
||||
mlse_db_enc = MLSE("DIR",[1,1],"duobinary_output",1,"M",M,"trellis_states",PAMmapper(M,0).levels);
|
||||
eq_db_enc = EQ("Ne",vnle_order,"Nb",dfe_order,"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",0,"ideal_dfe",1);
|
||||
[eq_sig,Eq_noise,ber_db_enc,totalErrors] = duobinary_signaling(eq_db_enc, mlse_db_enc,M, Scpe_sig ,Symbols, Bits);
|
||||
%->append BER to DB
|
||||
|
||||
fprintf('BER DB: %.2e \n',ber_db_enc(occ));
|
||||
end
|
||||
autoArrangeFigures;
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
if ~isempty(curFolder)
|
||||
cd(curFolder);
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,227 +0,0 @@
|
||||
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
|
||||
46
projects/IMDD_base_system/parameters.m
Normal file
46
projects/IMDD_base_system/parameters.m
Normal file
@@ -0,0 +1,46 @@
|
||||
% TX
|
||||
M = 4;
|
||||
fsym = 180e9;
|
||||
f_nyquist = fsym/2;
|
||||
apply_pulsef = 0;
|
||||
fdac = 2*fsym;%256e9;
|
||||
fadc = 2*fsym;%256e9;
|
||||
fdac = 256e9;
|
||||
fadc = 256e9;
|
||||
random_key = 1;
|
||||
db_precode = 0;
|
||||
emulate_precode = 0;
|
||||
discard_precode = 0;
|
||||
db_encode = 0;
|
||||
% duob_mode = db_mode.db_emulate;
|
||||
emulate_db = 1;
|
||||
rcalpha = 0.05;
|
||||
kover = 16;
|
||||
vbias_rel = 0.5;
|
||||
u_pi = 2.9;
|
||||
vbias = -vbias_rel*u_pi;
|
||||
laser_wavelength = 1310;
|
||||
laser_linewidth = 0;
|
||||
tx_bw_nyquist = 1.5;
|
||||
|
||||
% Channel
|
||||
link_length = 1;
|
||||
|
||||
% RX
|
||||
rop = -8;
|
||||
rx_bw_nyquist = 0.7;
|
||||
|
||||
% EQ
|
||||
eq_mode = equalizer_structure.vnle_pf_mlse;
|
||||
ffe_order=[50,0,0];
|
||||
vnle_order=[50,7,7];
|
||||
dfe_order = [2 0 0];
|
||||
|
||||
len_tr = 4096*2;
|
||||
mu_ffe = [0.0004 0.0004 0.0004];
|
||||
mu_dfe = 0.0004;
|
||||
mu_dc = 0.00;
|
||||
|
||||
dfe_ = sum(dfe_order)>0;
|
||||
|
||||
|
||||
@@ -1,208 +0,0 @@
|
||||
|
||||
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
|
||||
|
||||
24
projects/IMDD_base_system/rx_simulation.m
Normal file
24
projects/IMDD_base_system/rx_simulation.m
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
|
||||
%%%%%% ROP %%%%%%
|
||||
Rx_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","output_power","amplification_db",rop).process(Opt_sig);
|
||||
|
||||
|
||||
%%%%%% PD Square Law %%%%%%
|
||||
Rx_sig = Photodiode("fsimu",fdac*kover,"dark_current",2e-08,"responsivity",1,"temperature",20,"nep",1.8e-11).process(Rx_sig);
|
||||
|
||||
|
||||
%%%%%% Low-pass RX (PD, El. Connectors and Scope %%%%%%
|
||||
Rx_sig = Filter('filtdegree',4,"f_cutoff",rx_bw_nyquist.*f_nyquist,"fs",fdac*kover,"filterType",filtertypes.butterworth,"active",true).process(Rx_sig);
|
||||
|
||||
% %%%%%% Low-pass Scope %%%%%%
|
||||
Lp_scpe = Filter('filtdegree',4,"f_cutoff",110e9,"fs",fadc,"filterType",filtertypes.butterworth,"active",true);
|
||||
|
||||
% Rx_sig.spectrum("displayname",'Analog Rx Spectrum','fignum',100,'normalizeTo0dB',1);
|
||||
|
||||
%%%%%% Scope %%%%%%
|
||||
Scpe_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);
|
||||
|
||||
@@ -1,399 +0,0 @@
|
||||
|
||||
|
||||
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
|
||||
|
||||
74
projects/IMDD_base_system/submit_simulations.m
Normal file
74
projects/IMDD_base_system/submit_simulations.m
Normal file
@@ -0,0 +1,74 @@
|
||||
function wh = submit_simulations(wh,db,options)
|
||||
|
||||
arguments
|
||||
wh
|
||||
db
|
||||
options.parallel = 1;
|
||||
options.simulation_mode = 1;
|
||||
end
|
||||
|
||||
%%% 2) SUBMIT SIMULATION
|
||||
% Initialize job results
|
||||
if options.parallel
|
||||
if isempty(gcp('nocreate'))
|
||||
parpool;
|
||||
end
|
||||
results = parallel.FevalFuture.empty();
|
||||
else
|
||||
results = [];
|
||||
end
|
||||
|
||||
|
||||
lin_idx = 1;
|
||||
for lin_idx = 1:wh.getLastLinIndice
|
||||
optionalVars = struct();
|
||||
if ~isempty(wh.getDimension)
|
||||
% Build the optionalVars struct
|
||||
[parametervalues,parameternames]=wh.getPhysIndicesByLinIndex(lin_idx);
|
||||
for pidx = 1:numel(parameternames)
|
||||
optionalVars.(parameternames{pidx}) = parametervalues{pidx};
|
||||
end
|
||||
end
|
||||
|
||||
%%% SIMULATION HERE
|
||||
if options.parallel
|
||||
|
||||
numOutputs = 1;
|
||||
results(lin_idx) = parfeval(@imdd_model, numOutputs, options.simulation_mode, db, optionalVars);
|
||||
|
||||
else
|
||||
|
||||
finalresults{lin_idx} = imdd_model(options.simulation_mode,db,optionalVars);
|
||||
wh.addValueToStorageByLinIdx(finalresults{lin_idx}, 'ber', lin_idx);
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
if options.parallel
|
||||
|
||||
%%% 4) Setup waitbar
|
||||
h = waitbar(0, 'Processing Simulations...');
|
||||
% Helper function to compute progress
|
||||
updateWaitbar = @(~) waitbar(mean(arrayfun(@(f) strcmp(f.State, 'finished'), results)), h);
|
||||
|
||||
fprintf('Fetching results... \n');
|
||||
|
||||
% Update the waitbar after each simulation
|
||||
updateWaitbarFutures = afterEach(results, updateWaitbar, 0);
|
||||
|
||||
% Close the waitbar after all simulations complete
|
||||
afterAll(updateWaitbarFutures, @(~) delete(h), 0);
|
||||
|
||||
%%% 7) Fetch final results after all computations
|
||||
fetchOutputs(results);
|
||||
|
||||
for ridx = 1:length(results)
|
||||
wh.addValueToStorageByLinIdx(results(ridx).OutputArguments{1}, 'ber', ridx);
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
31
projects/IMDD_base_system/tx_simulation.m
Normal file
31
projects/IMDD_base_system/tx_simulation.m
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
|
||||
Pform = Pulseformer("fsym",fsym,"fdac",4*fsym,"pulse","rrc","pulselength",16,"rrcalpha",rcalpha);
|
||||
|
||||
[Digi_sig,Symbols,Tx_bits] = PAMsource(...
|
||||
"fsym",fsym,"M",M,"order",19,"useprbs",1,...
|
||||
"fs_out",fdac,...
|
||||
"applyclipping",0,"clipfactor",1.5,...
|
||||
"applypulseform",apply_pulsef,"pulseformer",Pform,...
|
||||
"randkey",random_key,...
|
||||
"db_precode",db_precode,"db_encode",db_encode,...
|
||||
"mrds_code",0,"mrds_blocklength",512).process();
|
||||
|
||||
Digi_sig.spectrum("displayname",'Digi Spectrum','fignum',10,'normalizeTo0dB',1);
|
||||
|
||||
%%%%% AWG
|
||||
% El_sig = M8199A("kover",kover).process(Digi_sig);
|
||||
El_sig = AWG("fdac",fdac,"f_cutoff",fsym,"lpf_active",0,"kover",kover,"bit_resolution",12,"upsampling_method","samplehold","precomp_sinc_rolloff",1).process(Digi_sig);
|
||||
% El_sig.spectrum("displayname",'Digi Spectrum','fignum',100,'normalizeTo0dB',0);
|
||||
% El_sig = El_sig.setPower(0,"dBm");
|
||||
|
||||
%%%%% Low-pass el. components %%%%%%
|
||||
El_sig = Filter('filtdegree',4,"f_cutoff",tx_bw_nyquist.*f_nyquist,"fs",fdac*kover,"filterType",filtertypes.butterworth,"active",true).process(El_sig);
|
||||
|
||||
%%%%% Electrical Driver Amplifier %%%%%%
|
||||
El_sig = Amplifier("amp_mode","ideal_no_noise","gain_mode","gain","amplification_db",3).process(El_sig);
|
||||
El_sig = El_sig.normalize("mode","oneone");
|
||||
|
||||
%%%%% MODULATE E/O CONVERSION %%%%%%
|
||||
[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).process(El_sig);
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user