178 lines
4.5 KiB
Matlab
178 lines
4.5 KiB
Matlab
O = 14; %order of prbs
|
|
N = 2^(O-1); %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;
|
|
% ADC Rate
|
|
fadc = 256e9;
|
|
% Simulation frequency in "analog domain"
|
|
fsimu = kover * fdac ;
|
|
|
|
|
|
%SIMULATE
|
|
|
|
for i = 1:log2(M)
|
|
[bitpattern(:,i),seed] = prbs(O,N,seed);
|
|
end
|
|
|
|
Bits = Informationsignal(bitpattern);
|
|
|
|
Bits.signal = pam_mapping(Bits.signal,M,0);
|
|
|
|
Bits.signal = applyPulseShaping(Bits.signal,fsym,fdac);
|
|
|
|
|
|
awg = AWG('preset','M8196A','fdac',fdac,'kover',kover,'lpf_active',1);
|
|
awgSignal = awg.process_channel(Bits);
|
|
|
|
fil = Filter('filtdegree',4,"f_cutoff",50e9,"fsamp",fdac,"filterType",filtertypes.bessel_bilin);
|
|
filtered = fil.process(awgSignal);
|
|
|
|
u_pi = 3.5;
|
|
vbias = (0.5*u_pi)-u_pi;
|
|
extmodlaser = EML("mode",emlmodes.im_cosinus,"power",10,"fsimu",fsimu,"lambda",1550,"bias",vbias,"u_pi",u_pi,"linewidth",1000000);
|
|
laserfield = extmodlaser.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("fsimu",fdac*kover,"fiber_length",0,"alpha",0.2,"D",17,"lambda0",1550);
|
|
fib_out = fib.process(att_out);
|
|
|
|
phdiode = Photodiode("fsimu",fdac*kover,"dark_current",2e-08,"responsivity",1,"temperature",20);
|
|
phdiod_out = phdiode.process(fib_out);
|
|
|
|
fil = Filter('filtdegree',4,"f_cutoff",70e9,"fsamp",fdac,"filterType",filtertypes.bessel_bilin);
|
|
phdiod_out2 = fil.process(phdiod_out);
|
|
|
|
|
|
scp = Scope("fsimu",fdac*kover,"fadc",fadc,...
|
|
"delay",0,"fixed_delay",0,"lpf_bw",120e9,"filtertype",filtertypes.bessel_inp,...
|
|
"samplingdelay",0,"rand_samplingdelay",0,"freq_offset",0,"samp_jitter",0,...
|
|
"adcresolution",6,"quantbuffer",0.1);
|
|
|
|
scope_out = scp.process(phdiod_out2);
|
|
|
|
figure;
|
|
hold on
|
|
plot( nmlze(resample(shapedData,fadc,fdac)),'DisplayName','shapedData Data');
|
|
plot( nmlze(resample(awgSignal,fadc,fdac*kover)),'DisplayName','AWG Data');
|
|
plot( nmlze(scope_out),'DisplayName','scope out out');
|
|
hold off
|
|
|
|
resample_out = resample(scope_out,fsym,fadc);
|
|
|
|
|
|
% figure;
|
|
% hold on
|
|
% plot(awgSignal,'DisplayName','skew 0');
|
|
% plot(filtered,'DisplayName','filtered');
|
|
% plot(abs(laserfield),'DisplayName','laser');
|
|
% plot(abs(att_out),'DisplayName','att_out');
|
|
% plot(abs(fib_out),'DisplayName','fiber_out');
|
|
% plot(abs(phdiod_out),'DisplayName','photo diode out');
|
|
% hold off
|
|
|
|
% figure;
|
|
% hold on
|
|
% plot(nmlze(pamData),'DisplayName','PAM Data');
|
|
% plot(nmlze(resample_out),'DisplayName','system out');
|
|
% hold off
|
|
|
|
|
|
function y = nmlze(x)
|
|
y = (x-min(x)) / max((x-min(x)));
|
|
end
|
|
|
|
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 |