Start Commit

start implementation of class based simulation of a IM/DD communication system. Mostly based on Move-It but cleaned up and with focus on direct detection, however I try to keep the versatility of move-it alive.
This commit is contained in:
Silas Oettinghaus
2023-05-12 15:28:23 +02:00
parent 69df41340f
commit 6d53823466
109 changed files with 1824 additions and 0 deletions

146
comm_tb.asv Normal file
View File

@@ -0,0 +1,146 @@
O = 10; %order of prbs
N = 64; %length of prbs
[~,seed] = prbs(O,1); %initialize first seed of prbs
% Modulation
M = 4;
bitpattern = zeros(N,log2(M));
% Symbol Rate
fsym = 56e9;
% DAC Rate
fdac = 120e9;
% Simulation oversampling rate "k";
kover = 16;
% Simulation frequency in "analog domain"
fsimu = kover * fdac ;
%SIMULATE
for i = 1:log2(M)
[bitpattern(:,i),seed] = prbs(O,N,seed);
end
pamData = pam_mapping(bitpattern,M,0);
shapedData = applyPulseShaping(pamData,fsym,fdac);
awg = AWG('preset','M8196A','fdac',fdac,'kover',kover,'lpf_active',1);
awgSignal = awg.process_channel(shapedData);
fil = Filter('filtdegree',4,"f_cutoff",50e9,"fdac",fdac,"filterType",filtertypes.bessel_bilin);
filtered = fil.process(awgSignal);
u_pi = 3.5;
vbias = (0.5*u_pi)-u_pi;
eml = EML("mode",emlmodes.im_cosinus,"power",10,"fsimu",fsimu,"lambda",1550,"bias",vbias,"u_pi",u_pi,"linewidth",1000000);
laserfield = eml.process(filtered);
att = Amplifier("amplification_db",10,"amp_mode","gain","type","ideal","saturation_mode",0,'saturation_power',10);
att_out = att.process(laserfield);
%fib = Fiber("fiber_length",2,"alpha",0.2,"D",17,"lambda0",1550);
figure;
plot(shapedData);
hold on
plot(awgSignal,'DisplayName','skew 0');
plot(filtered,'DisplayName','filtered');
plot(abs(laserfield),'DisplayName','laser');
plot(abs(att_out),'DisplayName','att_out');
hold off
function pam_sig = pam_mapping(bitpattern, M, unipolar)
switch log2(M)
case 1
% 2-ASK: BPSK / OOK
pam_sig=bitpattern(:,1);
if unipolar==0
pam_sig=2*pam_sig-1;
end
case 2
% 4-ASK:
pam_sig=2*bitpattern(:,1)+(bitpattern(:,1)==bitpattern(:,2));
if unipolar==0
pam_sig=2*pam_sig-3;
end
case 3
% 8-ASK:
x1 = bitpattern(:,1);
x2 = (bitpattern(:,1)==bitpattern(:,3));
x3 = x2~=bitpattern(:,2);
pam_sig = 4*x1 + 2*x2 + x3;
if unipolar==0
pam_sig=2*pam_sig-7;
end
case 4
% 16-ASK:
x1 = bitpattern(:,1);
x2 = (bitpattern(:,1)==bitpattern(:,4));
x3 = x2~=bitpattern(:,3);
x4 = x3~=bitpattern(:,2);
pam_sig = 8*x1 + 4*x2 + 2*x3 + x4;
if unipolar==0
pam_sig=2*pam_sig-15;
end
end
end
function yout = applyPulseShaping(xin,fsym,fdac)
if ~rem(fdac,fsym)
%ist ein Vielfaches
sps = fdac / fsym;
up = sps;
dn = 1;
else
%ist kein Vielfaches
up = fdac / gcd(fdac, fsym);
dn = fsym / gcd(fdac, fsym);
sps= up;
end
%Bau das Filter (hier rrc)
racos_len = 2048;
alpha = 0.1;
h = rcosdesign(alpha,racos_len,sps);
%Apply Filter using Matlab build in fctn.
yout = upfirdn(xin,h,up,dn);
%cut signal, which is longer due to fir filter
st = up/dn*racos_len/2; %we need to cut y_out
en = st + (length(xin)*up/dn) -1;
yout = yout(st:en);
%Check output integrity
if (up/dn * length(xin)) ~= length(yout)
warning('Check signal length after pulse shaping');
end
end
function yout = applyBandwidthLimitation(xin)
data_out=ifft(repmat(state.H,1,size(data_in,1)).*fft(data_in.')).';
end