269 lines
8.3 KiB
Matlab
269 lines
8.3 KiB
Matlab
function [output] = imdd_model(varargin)
|
|
|
|
simulation_mode = 1;
|
|
|
|
%%% Change folder
|
|
% curFolder = pwd;
|
|
% funcFolder=fileparts(mfilename('fullpath'));
|
|
% if ~isempty(funcFolder)
|
|
% cd(funcFolder);
|
|
% end
|
|
|
|
%%% Run parameters
|
|
% TX
|
|
M = 4;
|
|
fsym = 150e9;
|
|
bitrate = [];
|
|
|
|
apply_pulsef = 0;
|
|
fdac = 256e9;
|
|
fadc = 256e9;
|
|
random_key = 1;
|
|
|
|
rcalpha = 0.05;
|
|
kover = 16;
|
|
|
|
vbias_rel = 0.5;
|
|
u_pi = 3;
|
|
vbias = -vbias_rel*u_pi;
|
|
|
|
laser_wavelength = 1293;
|
|
laser_linewidth = 0;
|
|
tx_bw_nyquist = 0.65;
|
|
|
|
% Channel
|
|
link_length = 1;
|
|
channel_mode = "physical";
|
|
channel_snr_dB = 20;
|
|
channel_alpha = 0;
|
|
channel_delay_symbols = 1;
|
|
|
|
% RX
|
|
rop = 2;
|
|
rx_bw_nyquist = 0.8;
|
|
|
|
vnle_order1 = 50;
|
|
vnle_order2 = 7;
|
|
vnle_order3 = 7;
|
|
|
|
vnle_order=[vnle_order1,vnle_order2,vnle_order3];
|
|
dfe_order = [0 0 0];
|
|
|
|
pf_ncoeffs = 1;
|
|
|
|
eml_alpha = 0;
|
|
|
|
len_tr = 4096*2;
|
|
|
|
mu_ffe1 = 0.0001;
|
|
mu_ffe2 = 0.0008;
|
|
mu_ffe3 = 0.001;
|
|
mu_dc = 0.005;
|
|
% mu_dc = 0;
|
|
|
|
mu_ffe = [mu_ffe1 mu_ffe3 mu_ffe3];
|
|
mu_dfe = 0.0004;
|
|
|
|
|
|
dfe_ = sum(dfe_order)>0;
|
|
|
|
duob_mode = db_mode.no_db;
|
|
decoding_mode = [];
|
|
providedFields = string.empty;
|
|
|
|
%%% 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);
|
|
providedFields = string(fields);
|
|
for i = 1:numel(fields)
|
|
fieldName = fields{i};
|
|
if ~isvarname(fieldName)
|
|
error('Invalid parameter name "%s".', fieldName);
|
|
end
|
|
eval([fieldName, ' = var_s.(fieldName);']);
|
|
end
|
|
else
|
|
error('Optional variables should be passed as a struct.');
|
|
end
|
|
end
|
|
|
|
hasFsym = any(providedFields == "fsym");
|
|
hasBitrate = any(providedFields == "bitrate");
|
|
|
|
if M == 6
|
|
bitsPerSymbol = 2.5;
|
|
else
|
|
bitsPerSymbol = log2(M);
|
|
if abs(bitsPerSymbol - round(bitsPerSymbol)) > 1e-12
|
|
error('Unsupported PAM order M=%d. Only powers of two and PAM-6 are supported.', M);
|
|
end
|
|
end
|
|
|
|
if hasFsym && hasBitrate
|
|
error('either bitrate or symbolrate!')
|
|
elseif hasBitrate
|
|
fsym = bitrate / bitsPerSymbol;
|
|
else
|
|
bitrate = fsym * bitsPerSymbol;
|
|
end
|
|
|
|
f_nyquist = fsym/2;
|
|
|
|
|
|
%%%%% START SIMULATION
|
|
|
|
measure_tf = 0;
|
|
if measure_tf
|
|
freqresp = ChannelFreqResp("Nacq",1024,"Navg",64,"Ncp",70,"f_ref",fadc);
|
|
Digi_sig = freqresp.buildOFDM();
|
|
else
|
|
Pform = Pulseformer("fsym",fsym,"fdac",4*fsym,"pulse","rc","pulselength",16,"alpha",rcalpha);
|
|
[Digi_sig,Symbols,Tx_bits] = PAMsource(...
|
|
"fsym",fsym,"M",M,"order",18,"useprbs",0,...
|
|
"fs_out",fdac,...
|
|
"applyclipping",0,"clipfactor",1.5,...
|
|
"applypulseform",apply_pulsef,"pulseformer",Pform,...
|
|
"randkey",random_key,...
|
|
'duobinary_mode',duob_mode,...
|
|
"mrds_code",0,"mrds_blocklength",512).process();
|
|
end
|
|
|
|
% Digi_sig.spectrum("displayname",'Digi Spectrum','fignum',10,'normalizeTo0dB',1);
|
|
|
|
channel_mode = lower(string(channel_mode));
|
|
|
|
switch channel_mode
|
|
case "physical"
|
|
|
|
%%%%% AWG
|
|
El_sig = M8199B("kover",kover).process(Digi_sig);
|
|
% El_sig = AWG("fdac",fdac,"f_cutoff",fsym,"lpf_active",1,"kover",kover,"bit_resolution",12,"upsampling_method","samplehold","precomp_sinc_rolloff",0,"H_lpf",H_awg).process(Digi_sig);
|
|
% El_sig.spectrum("displayname",'Digi Spectrum','fignum',100,'normalizeTo0dB',0);
|
|
% El_sig = El_sig.setPower(0,"dBm");
|
|
|
|
%%%%% Low-pass el. components %%%%%%
|
|
% tx_bwl = tx_bw_nyquist.*f_nyquist;
|
|
tx_bwl = 85e9;
|
|
El_sig = Filter('filtdegree',4,"f_cutoff",tx_bwl,"fs",fdac*kover,"filterType",filtertypes.bessel_inp,"active",true).process(El_sig);
|
|
% El_sig.spectrum("displayname",'Digi Spectrum','fignum',100,'normalizeTo0dB',1);
|
|
|
|
%%%%% 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");
|
|
scaling = 0.7*(u_pi/2-abs(vbias-u_pi/2));
|
|
El_sig = El_sig .* scaling;
|
|
|
|
%%%%% 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,"alpha",eml_alpha).process(El_sig);
|
|
|
|
% figure(10)
|
|
% hold on
|
|
% scatter(El_sig.signal(1:100000)+vbias,(abs(Opt_sig.signal(1:100000)).^2)*1e3,0.1,'.','DisplayName','Modulator TF')
|
|
% ylim([0 u_pi]);
|
|
% xlim([-u_pi/2, u_pi/2]+vbias);
|
|
% xlabel('Input in V')
|
|
% ylabel('abs(Output) in mW')
|
|
|
|
|
|
% Opt_sig.spectrum("displayname",'Opt Spectrum','fignum',10,'normalizeTo0dB',1);
|
|
Opt_sig = Fiber("fsimu",Opt_sig.fs,"fiber_length",link_length,"alpha",0.3,"D",0,"lambda0",1310,"gamma",0,"Dslope",0.07).process(Opt_sig);
|
|
|
|
%%%%%% 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_bwl = rx_bw_nyquist.*f_nyquist;
|
|
rx_bwl = 90e9;
|
|
Rx_sig = Filter('filtdegree',4,"f_cutoff",rx_bwl,"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',10,'normalizeTo0dB',1);
|
|
|
|
%%%%%% Scope %%%%%%
|
|
Rx_sig = Scope("fsimu",fdac*kover,"fadc",fadc,...
|
|
"delay",0,"fixed_delay",0,"filtertype",filtertypes.butterworth,...
|
|
"samplingdelay",0,"rand_samplingdelay",0,"freq_offset",0,"samp_jitter",0,...
|
|
"adcresolution",8,"quantbuffer",0.1,'block_dc',1,'lpf_active',1,'H_lpf',Lp_scpe).process(Rx_sig);
|
|
|
|
case "awgn"
|
|
Rx_sig = awgn_channel(Digi_sig, ...
|
|
"snr_dB", channel_snr_dB, ...
|
|
"randkey", random_key + 2);
|
|
|
|
case {"awgn_alphad", "awgn_1alphad", "awgn_1_plus_alpha_d"}
|
|
delaySamples = max(1, round(channel_delay_symbols * Digi_sig.fs / fsym));
|
|
Rx_sig = awgn_alpha_d_channel(Digi_sig, ...
|
|
"alpha", channel_alpha, ...
|
|
"delay_samples", delaySamples, ...
|
|
"snr_dB", channel_snr_dB, ...
|
|
"randkey", random_key + 2);
|
|
|
|
otherwise
|
|
error('Unknown channel_mode "%s". Supported: physical, awgn, awgn_alphaD.', channel_mode);
|
|
end
|
|
|
|
if measure_tf
|
|
Rx_sig = Rx_sig.resample("fs_out",freqresp.f_ref);
|
|
freqresp.estimate(Rx_sig,"fileName",'','save',false);
|
|
freqresp.plot()
|
|
return;
|
|
end
|
|
|
|
Rx_sig.spectrum("displayname",'Sampled Rx Spectrum','fignum',1996,'normalizeTo0dB',1);
|
|
|
|
txPulseformer = [];
|
|
if apply_pulsef
|
|
txPulseformer = Pform;
|
|
end
|
|
|
|
dspParameters = struct();
|
|
dspParameters.len_tr = len_tr;
|
|
dspParameters.mu_ffe = mu_ffe;
|
|
dspParameters.mu_dfe = mu_dfe;
|
|
dspParameters.mu_dc = mu_dc;
|
|
dspParameters.use_ffe = 1;
|
|
dspParameters.use_dfe = 0;
|
|
dspParameters.use_vnle_mlse = 0;
|
|
dspParameters.use_dbtgt = 0;
|
|
dspParameters.use_dbenc = 0;
|
|
dspParameters.use_ml_mlse = 0;
|
|
dspParameters.pf_ncoeffs = pf_ncoeffs;
|
|
dspParameters.ffe_order_ffe = [50, 0, 0];
|
|
dspParameters.ffe_order_dfe = [50, 0, 0];
|
|
dspParameters.dfe_feedback_order = [2, 0, 0];
|
|
dspParameters.ffe_order_vnle = [50, 4, 4];
|
|
dspParameters.dfe_order_vnle = dfe_order;
|
|
dspParameters.ffe_order_dbtgt = [50, 4, 4];
|
|
dspParameters.dfe_order_dbtgt = dfe_order;
|
|
dspParameters.decoding_mode = decoding_mode;
|
|
|
|
scopeOutput = dsp_scope_signal(Rx_sig, Symbols, Tx_bits, ...
|
|
"fsym", fsym, ...
|
|
"M", M, ...
|
|
"duob_mode", duob_mode, ...
|
|
"parameters", dspParameters, ...
|
|
"preprocess_mode", "auto", ...
|
|
"tx_pulseformer", txPulseformer, ...
|
|
"debug_plots", true);
|
|
|
|
output = struct();
|
|
output.ffe_results = scopeOutput.ffe_package;
|
|
output.dfe_results = scopeOutput.dfe_package;
|
|
output.vnle_results = scopeOutput.vnle_package;
|
|
output.mlse_results = scopeOutput.mlse_package;
|
|
output.dbt_results = scopeOutput.dbtgt_package;
|
|
output.dbenc_results = scopeOutput.dbenc_package;
|
|
output.mlmlse_results = scopeOutput.mlmlse_package;
|
|
|
|
disp('- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ')
|
|
fprintf('\n')
|
|
end
|