
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');







