WIP - implementation and debugging of 224 Gbd PAM4 system
This commit is contained in:
@@ -6,13 +6,15 @@ classdef Filter
|
||||
H
|
||||
filterType
|
||||
f_cutoff
|
||||
|
||||
lowpass
|
||||
|
||||
signal_length
|
||||
filtdegree
|
||||
passband_ripple
|
||||
passband_ripple
|
||||
stopband_ripple
|
||||
fsamp
|
||||
|
||||
w
|
||||
end
|
||||
|
||||
methods
|
||||
@@ -20,36 +22,34 @@ classdef Filter
|
||||
%FILTER Construct an instance of this class
|
||||
% Detailed explanation goes here
|
||||
arguments
|
||||
options.filterType = 1;
|
||||
options.filterType filtertypes = filtertypes.bessel_inp ;
|
||||
options.f_cutoff = 0;
|
||||
options.fsamp = 0;
|
||||
options.filtdegree = 3;
|
||||
options.passband_ripple = 0.5;
|
||||
options.stopband_ripple = 0.5;
|
||||
options.lowpass = 1;
|
||||
end
|
||||
|
||||
|
||||
obj.filterType = options.filterType;
|
||||
|
||||
obj.f_cutoff = options.f_cutoff;
|
||||
obj.filtdegree = options.filtdegree;
|
||||
obj.passband_ripple = options.passband_ripple;
|
||||
obj.stopband_ripple = options.stopband_ripple;
|
||||
obj.fsamp = options.fsamp;
|
||||
|
||||
fn = fieldnames(options);
|
||||
for n = 1:numel(fn)
|
||||
obj.(fn{n}) = options.(fn{n});
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
function signalclass_out = process(obj,signalclass_in)
|
||||
function signalclass_out = process(obj,signalclass_in)
|
||||
|
||||
% actual processing of the signal
|
||||
signalclass_in.signal = obj.process_(signalclass_in.signal);
|
||||
% actual processing of the signal
|
||||
signalclass_in.signal = obj.process_(signalclass_in.signal);
|
||||
|
||||
% append to logbook
|
||||
% append to logbook
|
||||
filterdesc = [num2str(obj.filtdegree),'. order ',char(obj.filterType),' filter with f_cutoff at ', num2str(obj.f_cutoff*1e-9), ' GHz.'];
|
||||
signalclass_in = signalclass_in.logbookentry(filterdesc);
|
||||
|
||||
% write to output
|
||||
% write to output
|
||||
signalclass_out = signalclass_in;
|
||||
|
||||
end
|
||||
@@ -58,7 +58,7 @@ classdef Filter
|
||||
|
||||
obj.signal_length = length(xin);
|
||||
|
||||
obj.H = obj.buildFilter(obj.filterType);
|
||||
[obj.H,obj.w] = obj.buildFilter(obj.filterType);
|
||||
|
||||
yout = obj.applyFilter(xin);
|
||||
|
||||
@@ -70,8 +70,8 @@ classdef Filter
|
||||
|
||||
end
|
||||
|
||||
function H = buildFilter(obj,filterType)
|
||||
|
||||
function [H,w] = buildFilter(obj,filterType)
|
||||
w = [];
|
||||
rp = obj.passband_ripple; %passband ripple
|
||||
rs = obj.stopband_ripple; %stopband ripple
|
||||
|
||||
@@ -143,9 +143,22 @@ classdef Filter
|
||||
B = wc*sinc(wc*(-g:g));
|
||||
A=1;
|
||||
|
||||
case 10
|
||||
|
||||
% Gaussian Filter
|
||||
%check if order ist multiple of 1/2
|
||||
blocklen=obj.signal_length;
|
||||
|
||||
faxis=linspace(-obj.fsamp/2,obj.fsamp/2,blocklen+1)';%generates arow vector faxis of blocklen+1 points linearly spaced between and including -para.fs/2 and para.fs/2
|
||||
faxis=ifftshift(faxis(1:end-1));
|
||||
|
||||
H=exp(-((faxis)/(obj.f_cutoff*2)).^(2*obj.filtdegree)*log(2)*2^(2*obj.filtdegree-1));
|
||||
end
|
||||
|
||||
H = freqz(B, A, obj.signal_length,'whole');
|
||||
% Build Filter from coefficients
|
||||
if filterType ~= 10
|
||||
[H,w] = freqz(B, A, obj.signal_length,'whole');
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user