Hoffice push

This commit is contained in:
Silas
2024-09-06 15:53:32 +02:00
parent 03bfd70470
commit 179a7f9682
50 changed files with 921 additions and 93 deletions

View File

@@ -1,6 +1,8 @@
useprbs = 1;
M = 8;
randkey = 1;
fsym = 112e9;
%%%%% PRBS Generation in correct shape for Modulation Format %%%%%%
O = 18; %order of prbs
N = 2^(O-1); %length of prbs
@@ -28,28 +30,33 @@ Tx_bits = Informationsignal(bitpattern);
Symbols_tx = PAMmapper(M,0).map(Tx_bits);
Symbols_tx.fs = fsym;
% Symbols = Duobinary().precode(Symbols_tx);
Symbols = Duobinary().precode(Symbols_tx);
Symbols = Duobinary().encode(Symbols_tx);
Symbols = Duobinary().encode(Symbols);
% Symbols.spectrum("displayname","db","fignum",12)
Symbols = Duobinary().feedbackdetector(Symbols);
% Symbols = Duobinary().feedbackdetector(Symbols);
% Symbols.eye(fsym,M);
% Symbols = Duobinary().decode(Symbols);
Symbols = Duobinary().decode(Symbols);
Rx_bits = PAMmapper(M,0).demap(Symbols);
[~,error_num,ber,error_pos] = calc_ber(Tx_bits.signal,Rx_bits.signal,"skip_front",0,"skip_end",1,"returnErrorLocation",1);
[~,error_num,ber,error_pos] = calc_ber(Tx_bits.signal,Rx_bits.signal,"skip_front",0,"skip_end",0,"returnErrorLocation",1);
disp(['BER: ',sprintf('%.1E',ber),' - - PAM-',num2str(M)]);
%
figure;hold on
stairs(Rx_bits.signal(1:100,1),'LineWidth',2)
stairs(Tx_bits.signal(1:100,1),'LineStyle',':','LineWidth',2);
figure;hold on
stairs(Symbols_tx.signal(1:100,1),'LineWidth',2)
stairs(Symbols.signal(1:100,1),'LineStyle',':','LineWidth',2);
subplot(2,1,1)
title('Bits Compare')
stairs(Rx_bits.signal(1:100,1),'LineWidth',2,'DisplayName','Rx Bits')
stairs(Tx_bits.signal(1:100,1),'LineStyle',':','LineWidth',2,'DisplayName','Tx Bits');
legend
subplot(2,1,2)
hold on
title('Symbols Compare')
stairs(Symbols.signal(1:100,1),'LineStyle',':','LineWidth',2,'DisplayName','Rx Symbols');
stairs(Symbols_tx.signal(1:100,1),'LineWidth',2,'DisplayName','Tx Symbols')
legend

View File

@@ -0,0 +1,71 @@
%%%%% SETTINGS %%%%%%
useprbs = 1;
M = 8;
randkey = 1;
fsym = 112e9;
viewresults = 0;
%%%%% PRBS Generation in correct shape for Modulation Format %%%%%%
O = 10; %order of prbs
N = 2^(O-1); %length of prbs
[~,seed] = prbs(O,1); %initialize first seed of prbs
bitpattern=[];
if useprbs
for i = 1:log2(M)
[bitpattern(:,i),seed] = prbs(O,N,seed);
end
else
s = RandStream('twister','Seed',randkey);
for i = 1:log2(M)
bitpattern(:,i) = randi(s,[0 1], N, 1);
end
end
if M == 6
bitpattern = reshape(bitpattern,[],1);
bitpattern = bitpattern(1:end-mod(length(bitpattern),5));
end
Tx_bits = Informationsignal(bitpattern);
%%%%% ACTUAL TEST: Back to Back Mapping: Bits -> Symbols and Symbols -> Bits %%%%%%
Digi_Mod = PAMmapper(M,0);
Symbols = Digi_Mod.map(Tx_bits);
Rx_bits = PAMmapper(M,0).demap(Symbols);
%%%%% VALIDATION: BER is required to be zero %%%%%%
[~,error_num,ber,error_pos] = calc_ber(Tx_bits.signal,Rx_bits.signal,"skip_front",0,"skip_end",0,"returnErrorLocation",1);
%%%%% For User: Show Debug Info and Results %%%%%%
if viewresults
disp(['BER: ',sprintf('%.1E',ber),' - - PAM-',num2str(M)]);
figure
subplot(1,2,1)
hold on
title('Symbols Out')
stairs(Symbols_tx.signal(1:100,1),'LineWidth',2,'DisplayName','Tx Symbols')
legend
grid
subplot(1,2,2)
u = unique(Symbols_tx.signal);
scatter(0,u,'filled','o','LineWidth',2,'MarkerFaceColor',linspecer(1));
grid
end

View File

@@ -0,0 +1,59 @@
useprbs = 1;
M = 8;
randkey = 1;
fsym = 112e9;
%%%%% PRBS Generation in correct shape for Modulation Format %%%%%%
O = 18; %order of prbs
N = 2^(O-1); %length of prbs
[~,seed] = prbs(O,1); %initialize first seed of prbs
bitpattern=[];
if useprbs
for i = 1:log2(M)
[bitpattern(:,i),seed] = prbs(O,N,seed);
end
else
s = RandStream('twister','Seed',randkey);
for i = 1:log2(M)
bitpattern(:,i) = randi(s,[0 1], N, 1);
end
end
if M == 6
bitpattern = reshape(bitpattern,[],1);
bitpattern = bitpattern(1:end-mod(length(bitpattern),5));
end
Tx_bits = Informationsignal(bitpattern);
Digi_Mod = PAMmapper(M,0);
Symbols_tx = Digi_Mod.map(Tx_bits);
Symbols_tx.fs = fsym;
Symbols = Duobinary().precode(Symbols_tx);
Symbols = Duobinary().encode(Symbols);
Symbols = MLSE("DIR",[1,1],"duobinary_output",1,"trellis_states",Digi_Mod.levels,"M",M).process(Symbols);
Symbols = Duobinary().decode(Symbols);
Rx_bits = PAMmapper(M,0).demap(Symbols);
[~,error_num,ber,error_pos] = calc_ber(Tx_bits.signal,Rx_bits.signal,"skip_front",0,"skip_end",0,"returnErrorLocation",1);
disp(['BER: ',sprintf('%.1E',ber),' - - PAM-',num2str(M)]);
%
figure;hold on
subplot(2,1,1)
title('Bits Compare')
stairs(Rx_bits.signal(1:100,1),'LineWidth',2,'DisplayName','Rx Bits')
stairs(Tx_bits.signal(1:100,1),'LineStyle',':','LineWidth',2,'DisplayName','Tx Bits');
legend
subplot(2,1,2)
hold on
title('Symbols Compare')
stairs(Symbols.signal(1:100,1),'LineStyle',':','LineWidth',2,'DisplayName','Rx Symbols');
stairs(Symbols_tx.signal(1:100,1),'LineWidth',2,'DisplayName','Tx Symbols')
legend