classdef PAMsource %NAME Summary of this class goes here % Detailed explanation goes here properties(Access=public) order useprbs M fsym randkey applypulseform pulseformer fs_out applyclipping clipfactor end methods (Access=public) function obj = PAMsource(options) %NAME Construct an instance of this class % Detailed explanation goes here arguments options.order = 16; options.useprbs = true; options.M = true options.fsym = 112e9; options.randkey = 0; options.applypulseform = 1; options.pulseformer Pulseformer; options.fs_out ; options.applyclipping = 0; options.clipfactor = 10; end fn = fieldnames(options); for n = 1:numel(fn) try obj.(fn{n}) = options.(fn{n}); end end if boolean(obj.applypulseform) && isempty(obj.pulseformer) warning('No Pulseformer given. Proceeding with RRC and alpha 0.05'); options.pulseformer = Pulseformer("fsym",obj.fsym,"fdac",obj.fs_out,"pulse","rrc","pulselength",16,"rrcalpha",0.05); end end function [digi_sig,symbols,bits] = process(obj) %%%%% PRBS Generation in correct shape for Modulation Format %%%%%% O = obj.order; %order of prbs N = 2^(O-1); %length of prbs [~,seed] = prbs(O,1); %initialize first seed of prbs bitpattern=[]; if obj.useprbs for i = 1:log2(obj.M) [bitpattern(:,i),seed] = prbs(O,N,seed); end else s = RandStream('twister','Seed',obj.randkey); for i = 1:log2(obj.M) bitpattern(:,i) = randi(s,[0 1], N, 1); end end if obj.M == 6 bitpattern = reshape(bitpattern,[],1); bitpattern = bitpattern(1:end-mod(length(bitpattern),5)); end bits = Informationsignal(bitpattern); symbols = PAMmapper(obj.M,0).map(bits); symbols.fs = obj.fsym; if obj.applyclipping sym_min = min(symbols.signal); sym_max = max(symbols.signal); end %%%%% Pulseforming %%%%%% if obj.applypulseform digi_sig = obj.pulseformer.process(symbols); else digi_sig = symbols; end %%%%% Resample to f DAC %%%%%% digi_sig = digi_sig.resample("fs_in",digi_sig.fs,"fs_out",obj.fs_out,"n",10,"beta",5); %%%%% Hard clip digital signal to PAM range before DAC %%%%%% if obj.applyclipping digi_sig.signal = clip(digi_sig.signal , sym_min * obj.clipfactor , sym_max * obj.clipfactor); end % append to logbook lbdesc = ['Generated PAM Signal']; digi_sig = digi_sig.logbookentry(lbdesc); end end end