changes from zurich; my mac
This commit is contained in:
@@ -355,14 +355,14 @@ classdef Signal
|
|||||||
end
|
end
|
||||||
|
|
||||||
if isempty(options.fft_length)
|
if isempty(options.fft_length)
|
||||||
options.fft_length = 2^(nextpow2(length(obj.signal))-7);
|
options.fft_length = 2^(nextpow2(length(obj.signal))-6);
|
||||||
end
|
end
|
||||||
|
|
||||||
if options.normalizeToNyquist == 0
|
if options.normalizeToNyquist == 0
|
||||||
[p_lin,w] = pwelch(obj.signal,hanning(options.fft_length),options.fft_length/2,options.fft_length,obj.fs,"centered","psd","mean");
|
[p_lin,w] = pwelch(obj.signal,hanning(options.fft_length),options.fft_length/2,options.fft_length,obj.fs,"centered","power","mean");
|
||||||
w = w.*1e-9;
|
w = w.*1e-9;
|
||||||
else
|
else
|
||||||
[p_lin,w] = pwelch(obj.signal,hanning(options.fft_length),options.fft_length/2,options.fft_length,"centered","psd","mean");
|
[p_lin,w] = pwelch(obj.signal,hanning(options.fft_length),options.fft_length/2,options.fft_length,"centered","power","mean");
|
||||||
end
|
end
|
||||||
|
|
||||||
if options.normalizeTo0dB
|
if options.normalizeTo0dB
|
||||||
@@ -411,8 +411,9 @@ classdef Signal
|
|||||||
try
|
try
|
||||||
ylim([max(min(floor(min(p_dbm))-3, ax.YLim(1)),-40), min(max(ceil(max(p_dbm))+3, ax.YLim(2)),10)]);
|
ylim([max(min(floor(min(p_dbm))-3, ax.YLim(1)),-40), min(max(ceil(max(p_dbm))+3, ax.YLim(2)),10)]);
|
||||||
catch
|
catch
|
||||||
ylim([min(floor(min(p_dbm))-3, ax.YLim(1)), max(ceil(max(p_dbm))+3, ax.YLim(2))]);
|
ylim([floor(min(p_dbm))-3, ceil(max(p_dbm))+3]);
|
||||||
end
|
end
|
||||||
|
ylim([floor(min(p_dbm))-3, ceil(max(p_dbm))+3]);
|
||||||
yticks(-200:10:10);
|
yticks(-200:10:10);
|
||||||
grid on; grid minor;
|
grid on; grid minor;
|
||||||
legend
|
legend
|
||||||
@@ -661,6 +662,7 @@ classdef Signal
|
|||||||
obj Signal
|
obj Signal
|
||||||
options.reference Signal
|
options.reference Signal
|
||||||
options.fs_ref = 0;
|
options.fs_ref = 0;
|
||||||
|
options.debug_plots = 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
%normalize the signal
|
%normalize the signal
|
||||||
@@ -680,6 +682,12 @@ classdef Signal
|
|||||||
%estimate start pos of signal
|
%estimate start pos of signal
|
||||||
maxpeaknum = floor(length(a)/length(b));
|
maxpeaknum = floor(length(a)/length(b));
|
||||||
[pks,pkpos] = findpeaks(abs(co./max(co)),'MinPeakDistance',length(b)/2,'MinPeakHeight',0.2,'NPeaks',maxpeaknum,'SortStr','descend');
|
[pks,pkpos] = findpeaks(abs(co./max(co)),'MinPeakDistance',length(b)/2,'MinPeakHeight',0.2,'NPeaks',maxpeaknum,'SortStr','descend');
|
||||||
|
|
||||||
|
if options.debug_plots
|
||||||
|
figure()
|
||||||
|
findpeaks(abs(co./max(co)),'MinPeakDistance',length(b)/2,'MinPeakHeight',0.2,'NPeaks',maxpeaknum,'SortStr','descend')
|
||||||
|
end
|
||||||
|
|
||||||
shifts = lags(pkpos);
|
shifts = lags(pkpos);
|
||||||
|
|
||||||
shifts = shifts(shifts>=0);
|
shifts = shifts(shifts>=0);
|
||||||
@@ -722,8 +730,7 @@ classdef Signal
|
|||||||
end
|
end
|
||||||
|
|
||||||
%plot all synced signals and the ref signal
|
%plot all synced signals and the ref signal
|
||||||
debug = 0;
|
if options.debug_plots
|
||||||
if debug
|
|
||||||
figure;hold on;
|
figure;hold on;
|
||||||
for i = 1:size(S,1)
|
for i = 1:size(S,1)
|
||||||
plot(S{i}.normalize('mode','oneone').signal(1000:1100),'LineWidth',0.1,'Color',[0.2157 0.4941 0.7216]);
|
plot(S{i}.normalize('mode','oneone').signal(1000:1100),'LineWidth',0.1,'Color',[0.2157 0.4941 0.7216]);
|
||||||
@@ -837,9 +844,9 @@ classdef Signal
|
|||||||
|
|
||||||
mode = 1;
|
mode = 1;
|
||||||
|
|
||||||
histpoints = 1024; %% verticale resolution
|
histpoints = 1024*2; %% verticale resolution
|
||||||
histpoints = floor(histpoints/2)*2+1; %% to have the eye digram centered around one point make the vertical resolution uneven
|
histpoints = floor(histpoints/2)*2+1; %% to have the eye digram centered around one point make the vertical resolution uneven
|
||||||
histpoints_horizontal = 512; %% horizontal resolution
|
histpoints_horizontal = 512*2; %% horizontal resolution
|
||||||
hist_data=zeros(histpoints,histpoints_horizontal ); %% initilize eye diagram
|
hist_data=zeros(histpoints,histpoints_horizontal ); %% initilize eye diagram
|
||||||
|
|
||||||
if isa(obj,'Opticalsignal')
|
if isa(obj,'Opticalsignal')
|
||||||
@@ -850,7 +857,10 @@ classdef Signal
|
|||||||
sig = obj.signal;
|
sig = obj.signal;
|
||||||
end
|
end
|
||||||
|
|
||||||
x = (sig); %% make input signal rea)l
|
startpos = floor(0.1*length(sig));
|
||||||
|
endpos = floor(0.9*length(sig));
|
||||||
|
endpos = min(endpos,startpos+200000);
|
||||||
|
x = sig(startpos:endpos); %% make input signal rea)l
|
||||||
|
|
||||||
x = resample(x,fsym*histpoints_horizontal/2,obj.fs); %% up sample to original fsym rate
|
x = resample(x,fsym*histpoints_horizontal/2,obj.fs); %% up sample to original fsym rate
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,21 @@ classdef PAMmapper
|
|||||||
thresholds
|
thresholds
|
||||||
levels
|
levels
|
||||||
scaling
|
scaling
|
||||||
|
eth_style
|
||||||
end
|
end
|
||||||
|
|
||||||
methods
|
methods
|
||||||
function obj = PAMmapper(M, unipolar)
|
function obj = PAMmapper(M, unipolar, options)
|
||||||
%PAMMAPPER Construct an instance of this class
|
%PAMMAPPER Construct an instance of this class
|
||||||
% Detailed explanation goes here
|
% Detailed explanation goes here
|
||||||
|
arguments
|
||||||
|
M
|
||||||
|
unipolar
|
||||||
|
options.eth_style = 0;
|
||||||
|
end
|
||||||
|
|
||||||
obj.M = M;
|
obj.M = M;
|
||||||
|
|
||||||
obj.unipolar = unipolar;
|
obj.unipolar = unipolar;
|
||||||
|
|
||||||
obj.thresholds = obj.get_demodulation_thresholds();
|
obj.thresholds = obj.get_demodulation_thresholds();
|
||||||
@@ -23,6 +31,8 @@ classdef PAMmapper
|
|||||||
|
|
||||||
obj.scaling = rms(obj.get_levels());
|
obj.scaling = rms(obj.get_levels());
|
||||||
|
|
||||||
|
obj.eth_style = options.eth_style;
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function out = map(obj,signal_in)
|
function out = map(obj,signal_in)
|
||||||
@@ -66,19 +76,26 @@ classdef PAMmapper
|
|||||||
switch obj.M
|
switch obj.M
|
||||||
case 2
|
case 2
|
||||||
% 2-ASK: BPSK / OOK
|
% 2-ASK: BPSK / OOK
|
||||||
|
if ~obj.eth_style
|
||||||
pam_sig = bitpattern(:,1);
|
pam_sig = bitpattern(:,1);
|
||||||
|
|
||||||
if obj.unipolar==0
|
if obj.unipolar==0
|
||||||
pam_sig=2*pam_sig-1;
|
pam_sig=2*pam_sig-1;
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
pam_sig = -2*bitpattern(:,1) + 1;
|
||||||
|
end
|
||||||
|
|
||||||
case 4
|
case 4
|
||||||
% 4-ASK:
|
% 4-ASK:
|
||||||
|
if ~obj.eth_style
|
||||||
pam_sig=2*bitpattern(:,1)+(bitpattern(:,1)==bitpattern(:,2));
|
pam_sig=2*bitpattern(:,1)+(bitpattern(:,1)==bitpattern(:,2));
|
||||||
|
|
||||||
if obj.unipolar==0
|
if obj.unipolar==0
|
||||||
pam_sig=2*pam_sig-3;
|
pam_sig=2*pam_sig-3;
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
pam_sig = (2*bitpattern(:,1)-1).*(-2*bitpattern(:,2)+3);
|
||||||
|
end
|
||||||
|
|
||||||
pam_sig = pam_sig/sqrt(5);
|
pam_sig = pam_sig/sqrt(5);
|
||||||
|
|
||||||
@@ -97,7 +114,9 @@ classdef PAMmapper
|
|||||||
pam_sig = pam_sig/sqrt(10);
|
pam_sig = pam_sig/sqrt(10);
|
||||||
|
|
||||||
case 8
|
case 8
|
||||||
|
|
||||||
% 8-ASK:
|
% 8-ASK:
|
||||||
|
if ~obj.eth_style
|
||||||
x1 = bitpattern(:,1);
|
x1 = bitpattern(:,1);
|
||||||
x2 = (bitpattern(:,1)==bitpattern(:,3));
|
x2 = (bitpattern(:,1)==bitpattern(:,3));
|
||||||
x3 = x2~=bitpattern(:,2);
|
x3 = x2~=bitpattern(:,2);
|
||||||
@@ -107,6 +126,11 @@ classdef PAMmapper
|
|||||||
if obj.unipolar==0
|
if obj.unipolar==0
|
||||||
pam_sig=2*pam_sig-7;
|
pam_sig=2*pam_sig-7;
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
|
||||||
|
pam_sig = (bitpattern(:,1)*2-1).*(4+(2*bitpattern(:,2)-1).*(-2*bitpattern(:,3)+3));
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
pam_sig = pam_sig/sqrt(21);
|
pam_sig = pam_sig/sqrt(21);
|
||||||
|
|
||||||
@@ -233,13 +257,19 @@ classdef PAMmapper
|
|||||||
|
|
||||||
case 2
|
case 2
|
||||||
% 2-ASK
|
% 2-ASK
|
||||||
|
if ~obj.eth_style
|
||||||
data_out=comp_real(:,:,1);
|
data_out=comp_real(:,:,1);
|
||||||
|
else
|
||||||
|
data_out=abs(comp_real(:,:,1)-1);
|
||||||
|
end
|
||||||
|
|
||||||
case 4
|
case 4
|
||||||
% 4-ASK
|
% 4-ASK
|
||||||
|
if ~obj.eth_style
|
||||||
data_out=[comp_real(:,:,2); ones(s1,s2) - comp_real(:,:,1) + comp_real(:,:,3)];
|
data_out=[comp_real(:,:,2); ones(s1,s2) - comp_real(:,:,1) + comp_real(:,:,3)];
|
||||||
|
else
|
||||||
|
data_out= [(data_in>=0); (abs(data_in)<=1)];
|
||||||
|
end
|
||||||
|
|
||||||
case 6
|
case 6
|
||||||
|
|
||||||
@@ -264,11 +294,16 @@ classdef PAMmapper
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case 8
|
case 8
|
||||||
% 8-ASK
|
% 8-ASK
|
||||||
|
if ~obj.eth_style
|
||||||
data_out=[comp_real(:,:,4);
|
data_out=[comp_real(:,:,4);
|
||||||
comp_real(:,:,1)-comp_real(:,:,3)+comp_real(:,:,5)-comp_real(:,:,7);
|
comp_real(:,:,1)-comp_real(:,:,3)+comp_real(:,:,5)-comp_real(:,:,7);
|
||||||
1-comp_real(:,:,2)+comp_real(:,:,6)];
|
1-comp_real(:,:,2)+comp_real(:,:,6)];
|
||||||
|
else
|
||||||
|
data_out = [(data_in>=0); (abs(data_in)>(4/sqrt(21))); (abs(data_in)>=(2/sqrt(21)))&(abs(data_in)<=(6/sqrt(21)))];
|
||||||
|
end
|
||||||
|
|
||||||
case 16
|
case 16
|
||||||
% 16-ASK
|
% 16-ASK
|
||||||
|
|||||||
@@ -83,6 +83,8 @@ classdef PAMsource
|
|||||||
|
|
||||||
%%%%% MOVE-IT PRMS %%%%
|
%%%%% MOVE-IT PRMS %%%%
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
state = struct();
|
state = struct();
|
||||||
|
|
||||||
para = struct();
|
para = struct();
|
||||||
@@ -103,6 +105,8 @@ classdef PAMsource
|
|||||||
para.reset_prms = 0;
|
para.reset_prms = 0;
|
||||||
para.method = 1;
|
para.method = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
data_in = [];
|
data_in = [];
|
||||||
global loop;
|
global loop;
|
||||||
loop = 0;
|
loop = 0;
|
||||||
@@ -151,11 +155,15 @@ classdef PAMsource
|
|||||||
sym_max = max(symbols.signal);
|
sym_max = max(symbols.signal);
|
||||||
end
|
end
|
||||||
|
|
||||||
% symbols.move_it_spectrum("fignum",222,"displayname","Symbols only");
|
% symbols.spectrum("fignum",111,"displayname","1) RAW SIGNAL");
|
||||||
|
|
||||||
|
pulsf = Moveit_wrapper('pulsef');
|
||||||
|
pulsf.para.alpharacos = obj.pulseformer.alpha;
|
||||||
|
pulsf.para.f_sym = obj.fsym;
|
||||||
|
pulsf.para.fs = obj.fsym;
|
||||||
|
pulsf.para.pulse = 'racos';
|
||||||
|
|
||||||
% symbols.spectrum("fignum",222,"displayname","Symbols only","normalizeTo0dB",1);
|
pulsf.process(symbols);
|
||||||
|
|
||||||
|
|
||||||
%%%%% Pulse-forming %%%%%%
|
%%%%% Pulse-forming %%%%%%
|
||||||
if obj.applypulseform
|
if obj.applypulseform
|
||||||
@@ -164,10 +172,13 @@ classdef PAMsource
|
|||||||
digi_sig = symbols;
|
digi_sig = symbols;
|
||||||
end
|
end
|
||||||
|
|
||||||
%%%%% Re-sample to f DAC %%%%%%
|
% digi_sig.spectrum("fignum",112,"displayname","2) after pulseforming");
|
||||||
digi_sig = digi_sig.resample("fs_in",digi_sig.fs,"fs_out",obj.fs_out,"n",10,"beta",5);
|
|
||||||
|
%%%%% Re-sample to f DAC %%%%%%
|
||||||
|
n = 10;
|
||||||
|
digi_sig = digi_sig.resample("fs_in",digi_sig.fs,"fs_out",obj.fs_out,"n",n,"beta",5);
|
||||||
|
% digi_sig.spectrum("fignum",111,"displayname",['3) Shaped + Resampled; n: ',num2str(n)]);
|
||||||
|
|
||||||
% digi_sig.spectrum("fignum",111,"displayname","after pulseforming");
|
|
||||||
|
|
||||||
%%%%% Hard clip digital signal to PAM range before DAC %%%%%%
|
%%%%% Hard clip digital signal to PAM range before DAC %%%%%%
|
||||||
if obj.applyclipping
|
if obj.applyclipping
|
||||||
|
|||||||
@@ -3,13 +3,15 @@ classdef Pulseformer
|
|||||||
% Detailed explanation goes here
|
% Detailed explanation goes here
|
||||||
|
|
||||||
properties(Access=public)
|
properties(Access=public)
|
||||||
fdac
|
|
||||||
end
|
end
|
||||||
properties(Access=private)
|
properties(Access=public)
|
||||||
|
fdac
|
||||||
fsym
|
fsym
|
||||||
pulse
|
pulse
|
||||||
pulselength
|
pulselength
|
||||||
rrcalpha
|
alpha
|
||||||
|
matched
|
||||||
end
|
end
|
||||||
|
|
||||||
methods (Access=public)
|
methods (Access=public)
|
||||||
@@ -20,9 +22,10 @@ classdef Pulseformer
|
|||||||
arguments
|
arguments
|
||||||
options.fdac double
|
options.fdac double
|
||||||
options.fsym double
|
options.fsym double
|
||||||
options.pulse pulseform = pulseform.rrc
|
options.pulse pulseform = pulseform.rc
|
||||||
options.pulselength double {mustBeInteger} = 32
|
options.pulselength double {mustBeInteger} = 32
|
||||||
options.rrcalpha double = 0.05
|
options.alpha double = 0.05
|
||||||
|
options.matched = 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
%
|
%
|
||||||
@@ -86,48 +89,71 @@ classdef Pulseformer
|
|||||||
sps= up;
|
sps= up;
|
||||||
end
|
end
|
||||||
|
|
||||||
if obj.pulse == pulseform.rrc
|
if obj.pulse == pulseform.rc
|
||||||
%Bau das Filter (hier rrc)
|
filtertype = 'normal';
|
||||||
racos_len = obj.pulselength*2;
|
elseif pulseform.rrc
|
||||||
alpha = obj.rrcalpha;
|
filtertype = 'sqrt';
|
||||||
h = rcosdesign(alpha,racos_len,sps,"normal");
|
|
||||||
h = h./ max(h);
|
|
||||||
end
|
end
|
||||||
|
|
||||||
% Apply filter the long way (from move_it)
|
%Bau das Filter (hier rc)
|
||||||
% block length in samples
|
racos_len = obj.pulselength*2;
|
||||||
|
h = rcosdesign(obj.alpha,racos_len,sps,filtertype);
|
||||||
|
h = h./ max(h);
|
||||||
|
|
||||||
|
if obj.matched
|
||||||
|
h = 1./h;
|
||||||
|
end
|
||||||
|
|
||||||
|
manual_cyclic_convolution = 1;
|
||||||
|
upfirdn_convolution = 0;
|
||||||
|
|
||||||
|
if manual_cyclic_convolution
|
||||||
|
|
||||||
|
% Apply filter the long way (from move_it)
|
||||||
data_in = data_in';
|
data_in = data_in';
|
||||||
blen = length(data_in)*sps;
|
blen = length(data_in)*sps;
|
||||||
|
|
||||||
% oversample symbol sequence
|
% oversample symbol sequence
|
||||||
|
|
||||||
symbolov=zeros(size(data_in,1),blen);
|
symbolov=zeros(size(data_in,1),blen);
|
||||||
symbolov(:,1:sps:blen-sps+1)=data_in;
|
symbolov(:,1:sps:blen-sps+1)=data_in;
|
||||||
|
|
||||||
H=fft(h,blen);
|
H=fft(h,blen);
|
||||||
|
|
||||||
% Convolution of Bit sequence with impulse response
|
% Convolution of Bit sequence with impulse response
|
||||||
|
|
||||||
% cyclic convolution
|
|
||||||
data_out=ifft( fft(symbolov.') .* repmat( H,size(data_in,1),1 ).' ).';
|
data_out=ifft( fft(symbolov.') .* repmat( H,size(data_in,1),1 ).' ).';
|
||||||
|
|
||||||
data_out = circshift(data_out,[0 -(obj.pulselength*sps)]);
|
data_out = circshift(data_out,[0 -(obj.pulselength*sps)]);
|
||||||
|
|
||||||
if rem(obj.fdac,obj.fsym)
|
if rem(obj.fdac,obj.fsym)
|
||||||
data_out = data_out(1:dn:end); %!
|
data_out = data_out(1:dn:end);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
% %Apply Filter using Matlab build in fctn.
|
if upfirdn_convolution
|
||||||
% h = rcosdesign(alpha,racos_len,sps);
|
|
||||||
% h = h./ max(h);
|
%Apply Filter using Matlab build in fctn.
|
||||||
%data_out_ = upfirdn(data_in,h,up,dn);
|
h = rcosdesign(obj.alpha,racos_len,sps,"normal");
|
||||||
%
|
h = h./ max(h);
|
||||||
% %cut signal, which is longer due to fir filter
|
data_out_ = upfirdn(data_in,h,up,dn);
|
||||||
% st = round(up/dn*racos_len/2); %we need to cut y_out
|
|
||||||
% en = round(st + (length(data_in)*up/dn) -1);
|
%cut signal, which is longer due to fir filter
|
||||||
% data_out = data_out(st:en);
|
st = round(up/dn*racos_len/2)+1; %we need to cut y_out
|
||||||
|
en = round(st + (length(data_in)*up/dn));
|
||||||
|
data_out_ = data_out_(st:en);
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
if upfirdn_convolution && manual_cyclic_convolution
|
||||||
|
figure()
|
||||||
|
subplot(2,1,1)
|
||||||
|
title("Convolution vs. Upfirdn and Cut")
|
||||||
|
hold on
|
||||||
|
plot(data_out_(1:200),'DisplayName','Matlab upfirdn');
|
||||||
|
plot(data_out(1:200),'DisplayName','By Hand cyclic convolution')
|
||||||
|
subplot(2,1,2)
|
||||||
|
hold on
|
||||||
|
plot(data_out(1:2000),'DisplayName','OUT');
|
||||||
|
plot(data_in(1:2000),'DisplayName','IN');
|
||||||
|
end
|
||||||
|
|
||||||
%scaling?! see pulsef module line 696
|
%scaling?! see pulsef module line 696
|
||||||
% scale = max(max([abs(real(data_out)) abs(imag(data_out))])); %find max value from real and imag part
|
% scale = max(max([abs(real(data_out)) abs(imag(data_out))])); %find max value from real and imag part
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ classdef DataStorage < handle
|
|||||||
for p = 1:numel(obj.fn)
|
for p = 1:numel(obj.fn)
|
||||||
name = obj.fn(p);
|
name = obj.fn(p);
|
||||||
values = obj.inputParams.(name);
|
values = obj.inputParams.(name);
|
||||||
obj.parameter.(name) = Parameter(name,values);
|
obj.parameter.(name) = StorageParameter(name,values);
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
classdef Parameter < handle
|
|
||||||
%PARAMETER Summary of this class goes here
|
|
||||||
% Detailed explanation goes here
|
|
||||||
|
|
||||||
properties
|
|
||||||
name
|
|
||||||
values
|
|
||||||
indices
|
|
||||||
length
|
|
||||||
getPhysForIndex = dictionary;
|
|
||||||
getIndexForPhys = dictionary;
|
|
||||||
end
|
|
||||||
|
|
||||||
methods
|
|
||||||
function obj = Parameter(name, values)
|
|
||||||
%PARAMETER Construct
|
|
||||||
obj.name = name;
|
|
||||||
obj.values = values;
|
|
||||||
obj.indices = [1:numel(obj.values)];
|
|
||||||
obj.length = length(obj.values);
|
|
||||||
obj = obj.buildIndexForPhysDict();
|
|
||||||
obj = obj.buildPhysForIndexDict();
|
|
||||||
end
|
|
||||||
|
|
||||||
function obj = buildPhysForIndexDict(obj)
|
|
||||||
%take Index
|
|
||||||
%return Phys
|
|
||||||
for idx = 1:numel(obj.values)
|
|
||||||
obj.getPhysForIndex(idx) = obj.values(idx);
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function obj = buildIndexForPhysDict(obj)
|
|
||||||
%take Phys
|
|
||||||
%return Index
|
|
||||||
for idx = 1:numel(obj.values)
|
|
||||||
obj.getIndexForPhys(obj.values(idx)) = idx;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
classdef pulseform < int32
|
classdef pulseform < int32
|
||||||
|
|
||||||
enumeration
|
enumeration
|
||||||
rrc (1)
|
rc (1) %raised cosine (use this at Tx without matched filter)
|
||||||
|
rrc (2) %root raised cosine (usually with matched filter)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -22,6 +22,7 @@ function [eq_package] = vnle(eq_,M,rx_signal,tx_symbols,tx_bits,options)
|
|||||||
tx_bits
|
tx_bits
|
||||||
options.precode_mode db_mode
|
options.precode_mode db_mode
|
||||||
options.showAnalysis = 0
|
options.showAnalysis = 0
|
||||||
|
options.eth_style = 0;
|
||||||
end
|
end
|
||||||
|
|
||||||
%FFE or VNLE
|
%FFE or VNLE
|
||||||
@@ -46,7 +47,7 @@ function [eq_package] = vnle(eq_,M,rx_signal,tx_symbols,tx_bits,options)
|
|||||||
tx_symbols_precoded = Duobinary().encode(tx_symbols);
|
tx_symbols_precoded = Duobinary().encode(tx_symbols);
|
||||||
tx_symbols_precoded = Duobinary().decode(tx_symbols_precoded);
|
tx_symbols_precoded = Duobinary().decode(tx_symbols_precoded);
|
||||||
|
|
||||||
tx_bits = PAMmapper(M,0).demap(tx_symbols_precoded);
|
tx_bits = PAMmapper(M,0,"eth_style",options.eth_style).demap(tx_symbols_precoded);
|
||||||
|
|
||||||
case db_mode.db_discard
|
case db_mode.db_discard
|
||||||
|
|
||||||
@@ -64,23 +65,31 @@ function [eq_package] = vnle(eq_,M,rx_signal,tx_symbols,tx_bits,options)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
rx_bits = PAMmapper(M,0).demap(eq_signal_hd);
|
rx_bits = PAMmapper(M,0,"eth_style",options.eth_style).demap(eq_signal_hd);
|
||||||
|
|
||||||
[~,numErrors,ber,~] = calc_ber(rx_bits.signal,tx_bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
|
[~,numErrors,ber,~] = calc_ber(rx_bits.signal,tx_bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
|
||||||
[evm_total,evm_lvl] = calc_evm(eq_signal_sd,tx_symbols);
|
[evm_total,evm_lvl] = calc_evm(eq_signal_sd,tx_symbols);
|
||||||
[inf_rate] = calc_air(eq_signal_sd,tx_symbols,"skip_front",10000,"skip_end",10000);
|
[inf_rate] = calc_air(eq_signal_sd,tx_symbols,"skip_front",10000,"skip_end",10000);
|
||||||
|
snr(eq_signal_sd.signal,eq_noise.signal)
|
||||||
|
|
||||||
|
|
||||||
eq_package.ber_vnle = ber;
|
eq_package.ber_vnle = ber;
|
||||||
eq_package.evm_total = evm_total;
|
eq_package.evm_total = evm_total;
|
||||||
eq_package.evm_lvl = evm_lvl;
|
eq_package.evm_lvl = evm_lvl;
|
||||||
eq_package.inf_rate_vnle = inf_rate;
|
eq_package.inf_rate_vnle = inf_rate;
|
||||||
|
|
||||||
|
|
||||||
if options.showAnalysis
|
if options.showAnalysis
|
||||||
|
|
||||||
fprintf(['VNLE EVM lvl: ',repmat('%.3f ',1,numel(evm_lvl)),' \n'],evm_lvl);
|
fprintf(['VNLE EVM lvl: ',repmat('%.3f ',1,numel(evm_lvl)),' \n'],evm_lvl);
|
||||||
|
|
||||||
fprintf('VNLE BER: %.2e \n',ber);
|
fprintf('VNLE BER: %.2e \n',ber);
|
||||||
|
|
||||||
|
showEQNoiseSNR(tx_symbols,eq_noise,"displayname",'SNR after VNLE','fignum',301);
|
||||||
|
|
||||||
|
showLevelHistogram(eq_signal_sd,tx_symbols,"fignum",302);
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -99,7 +99,7 @@ end
|
|||||||
|
|
||||||
fprintf('MLSE BER: %.2e \n',ber_mlse);
|
fprintf('MLSE BER: %.2e \n',ber_mlse);
|
||||||
|
|
||||||
showEQNoisePSD(eq_noise,"fignum",336,"displayname",'VNLE+DFE','postfilter_taps',pf_.coefficients);
|
showEQNoisePSD(eq_noise,"fignum",336,"displayname",'Residual Noise after VNLE','postfilter_taps',pf_.coefficients);
|
||||||
|
|
||||||
|
|
||||||
rx_signal.spectrum("normalizeTo0dB",1,"fignum",337,"displayname",'Rx Signal');
|
rx_signal.spectrum("normalizeTo0dB",1,"fignum",337,"displayname",'Rx Signal');
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
function showEQNoiseSNR(tx_signal, rx_signal, options)
|
function showEQNoiseSNR(eq_signal, noise_signal, options)
|
||||||
arguments
|
arguments
|
||||||
tx_signal
|
eq_signal
|
||||||
rx_signal
|
noise_signal
|
||||||
options.fs_tx
|
options.fs_tx
|
||||||
options.fs_rx
|
options.fs_rx
|
||||||
options.fignum (1,1) double = NaN % Default to NaN if not provided
|
options.fignum (1,1) double = NaN % Default to NaN if not provided
|
||||||
@@ -16,13 +16,13 @@ end
|
|||||||
fig = figure(options.fignum); % Use the specified figure number
|
fig = figure(options.fignum); % Use the specified figure number
|
||||||
end
|
end
|
||||||
|
|
||||||
if isa(tx_signal,'Signal')
|
if isa(eq_signal,'Signal')
|
||||||
options.fs_tx = tx_signal.fs;
|
options.fs_tx = eq_signal.fs;
|
||||||
tx_signal = tx_signal.signal;
|
eq_signal = eq_signal.signal;
|
||||||
end
|
end
|
||||||
if isa(rx_signal,'Signal')
|
if isa(noise_signal,'Signal')
|
||||||
options.fs_rx = rx_signal.fs;
|
options.fs_rx = noise_signal.fs;
|
||||||
rx_signal = rx_signal.signal;
|
noise_signal = noise_signal.signal;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -37,10 +37,10 @@ end
|
|||||||
% Ensure the figure is ready before calling spectrum
|
% Ensure the figure is ready before calling spectrum
|
||||||
title('SNR of received Signal')
|
title('SNR of received Signal')
|
||||||
|
|
||||||
fft_length = 2^(nextpow2(length(tx_signal))-7);
|
fft_length = 2^(nextpow2(length(eq_signal))-7);
|
||||||
|
|
||||||
[s_lin,w] = pwelch(tx_signal,hanning(fft_length),fft_length/2,fft_length,options.fs_tx,"centered","psd","mean");
|
[s_lin,w] = pwelch(eq_signal,hanning(fft_length),fft_length/2,fft_length,options.fs_tx,"centered","psd","mean");
|
||||||
[n_lin,w] = pwelch(rx_signal,hanning(fft_length),fft_length/2,fft_length,options.fs_rx,"centered","psd","mean");
|
[n_lin,w] = pwelch(noise_signal,hanning(fft_length),fft_length/2,fft_length,options.fs_rx,"centered","psd","mean");
|
||||||
|
|
||||||
w = w.*1e-9;
|
w = w.*1e-9;
|
||||||
snr_dbm = 10*log10(s_lin./n_lin);
|
snr_dbm = 10*log10(s_lin./n_lin);
|
||||||
@@ -48,6 +48,7 @@ end
|
|||||||
% figure(231)
|
% figure(231)
|
||||||
hold on
|
hold on
|
||||||
plot(w,snr_dbm,'DisplayName','SNR','LineWidth',0.5,'Color',options.color);
|
plot(w,snr_dbm,'DisplayName','SNR','LineWidth',0.5,'Color',options.color);
|
||||||
|
yline(mean(snr_dbm),'HandleVisibility','off','Color',options.color);
|
||||||
xlabel("Frequency in GHz");
|
xlabel("Frequency in GHz");
|
||||||
|
|
||||||
edgetick = 2^(nextpow2(options.fs_tx*1e-9));
|
edgetick = 2^(nextpow2(options.fs_tx*1e-9));
|
||||||
|
|||||||
BIN
projects/.DS_Store
vendored
BIN
projects/.DS_Store
vendored
Binary file not shown.
@@ -3,13 +3,13 @@
|
|||||||
% db = DBHandler("pathToDB",[basePath,'silas_labor.db']);
|
% db = DBHandler("pathToDB",[basePath,'silas_labor.db']);
|
||||||
if 1
|
if 1
|
||||||
uloops = struct;
|
uloops = struct;
|
||||||
uloops.precomp = [0,1];
|
uloops.precomp = [0];
|
||||||
uloops.db_precode = [0,1];
|
uloops.db_precode = [0];
|
||||||
uloops.bitrate = [300,330,360,390,420,450,480].*1e9; %[300,330,360,390,420,450,480]
|
uloops.bitrate = [330].*1e9; %[300,330,360,390,420,450,480]
|
||||||
% uloops.bitrate = 390e9;
|
% uloops.bitrate = 390e9;
|
||||||
% uloops.laser_wavelength = [1293,1297.5,1302,1306.5,1310,1313.4,1318,1322.7,1327.4];
|
% uloops.laser_wavelength = [1293,1297.5,1302,1306.5,1310,1313.4,1318,1322.7,1327.4];
|
||||||
uloops.laser_wavelength = [1293];
|
uloops.laser_wavelength = [1293];
|
||||||
uloops.M = [4,6,8];
|
uloops.M = [4];
|
||||||
uloops.link_length = [2]; % 1,2,3,5,6,8,10
|
uloops.link_length = [2]; % 1,2,3,5,6,8,10
|
||||||
wh = DataStorage(uloops);
|
wh = DataStorage(uloops);
|
||||||
wh.addStorage("ber");
|
wh.addStorage("ber");
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ if simulation_mode
|
|||||||
Pform = Pulseformer("fsym",fsym,"fdac",4*fsym,"pulse","rrc","pulselength",16,"rrcalpha",rcalpha);
|
Pform = Pulseformer("fsym",fsym,"fdac",4*fsym,"pulse","rrc","pulselength",16,"rrcalpha",rcalpha);
|
||||||
|
|
||||||
[Digi_sig,Symbols,Tx_bits] = PAMsource(...
|
[Digi_sig,Symbols,Tx_bits] = PAMsource(...
|
||||||
"fsym",fsym,"M",M,"order",17,"useprbs",1,...
|
"fsym",fsym,"M",M,"order",16,"useprbs",0,...
|
||||||
"fs_out",fdac,...
|
"fs_out",fdac,...
|
||||||
"applyclipping",0,"clipfactor",1.5,...
|
"applyclipping",0,"clipfactor",1.5,...
|
||||||
"applypulseform",apply_pulsef,"pulseformer",Pform,...
|
"applypulseform",apply_pulsef,"pulseformer",Pform,...
|
||||||
@@ -268,7 +268,7 @@ for occ = 1:proc_occ
|
|||||||
Scpe_sig = Scpe_sig.resample("fs_out",2*fsym);
|
Scpe_sig = Scpe_sig.resample("fs_out",2*fsym);
|
||||||
|
|
||||||
%%%%%% Sync Rx signal with reference %%%%%%
|
%%%%%% Sync Rx signal with reference %%%%%%
|
||||||
% [Scpe_sig,~] = Scpe_sig.tsynch("reference",Symbols,"fs_ref",fsym);
|
[Scpe_sig,~] = Scpe_sig.tsynch("reference",Symbols,"fs_ref",fsym);
|
||||||
|
|
||||||
Scpe_sig = Filter('filtdegree',4,"f_cutoff",Symbols.fs.*0.5,"fs",Scpe_sig.fs,"filterType",filtertypes.gaussian,"active",true).process(Scpe_sig);
|
Scpe_sig = Filter('filtdegree',4,"f_cutoff",Symbols.fs.*0.5,"fs",Scpe_sig.fs,"filterType",filtertypes.gaussian,"active",true).process(Scpe_sig);
|
||||||
|
|
||||||
@@ -284,10 +284,10 @@ for occ = 1:proc_occ
|
|||||||
mu_ffe = [mu_ffe1 mu_ffe2 mu_ffe3];
|
mu_ffe = [mu_ffe1 mu_ffe2 mu_ffe3];
|
||||||
|
|
||||||
% %%%%% VNLE + DFE %%%%
|
% %%%%% VNLE + DFE %%%%
|
||||||
if 0
|
if 1
|
||||||
eq_vnle_dfe = EQ("Ne",vnle_order,"Nb",[0,0,0],"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",1,"ideal_dfe",0);
|
eq_vnle_dfe = EQ("Ne",vnle_order,"Nb",[0,0,0],"training_length",len_tr,"training_loops",5,"dd_loops",5,"K",2,"DCmu",mu_dc,"DDmu",[mu_ffe mu_dfe],"DFEmu",0.005,"FFEmu",0,"plotfinal",1,"ideal_dfe",0);
|
||||||
|
|
||||||
[result] = vnle(eq_vnle_dfe,M,Scpe_sig,Symbols,Tx_bits,"precode_mode",doub_mode,"showAnalysis",0);
|
[result] = vnle(eq_vnle_dfe,M,Scpe_sig,Symbols,Tx_bits,"precode_mode",doub_mode,"showAnalysis",1);
|
||||||
vnle_dfe_package{occ} = result;
|
vnle_dfe_package{occ} = result;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user