PR and DB fummelei

This commit is contained in:
Silas Oettinghaus
2026-04-23 16:16:45 +02:00
parent 5446275a5b
commit 8fd68c0a54
6 changed files with 104 additions and 183 deletions

View File

@@ -3,22 +3,12 @@
M = 4; M = 4;
apply_precode = 1; apply_precode = 1;
bitpattern = []; bits = Signalgenerator( ...
s = RandStream('twister','Seed',1); "form", signalform.prms, ...
for i = 1:log2(M) "M", M, ...
N = 2^(17-1); %length of prbs "order", 15).process();
bitpattern(:,i) = randi(s,[0 1], N, 1);
end
if M == 6
bitpattern = reshape(bitpattern',[],1);
bitpattern = bitpattern(1:end-mod(length(bitpattern),5));
end
bits = Informationsignal(bitpattern);
symbols = PAMmapper(M,0).map(bits); symbols = PAMmapper(M,0).map(bits);
bits_rx = PAMmapper(M,0).demap(symbols); bits_rx = PAMmapper(M,0).demap(symbols);
[~,~,ber_direct,~] = calc_ber(bits.signal,bits_rx.signal,"skip_front",0,"skip_end",0,"returnErrorLocation",1); [~,~,ber_direct,~] = calc_ber(bits.signal,bits_rx.signal,"skip_front",0,"skip_end",0,"returnErrorLocation",1);
@@ -27,10 +17,6 @@ if apply_precode
else else
symbols_tx = symbols; symbols_tx = symbols;
end end
disp(['Tx Sequenz: -- RMS:',sprintf('%.1f',rms(symbols_rx.signal)),' - - Levels -',num2str(numel(unique(symbols_rx.signal)))]);
unique(symbols_tx.signal)
disp('- - - - - - - - - -');
show2Dconstellation(symbols_tx,symbols_tx,"displayname",'VNLE Out','fignum',2241); show2Dconstellation(symbols_tx,symbols_tx,"displayname",'VNLE Out','fignum',2241);
@@ -62,7 +48,7 @@ disp(['BER: ',sprintf('%.1E',ber),' - - PAM-',num2str(M)]);
figure() figure()
subplot(1,2,1) subplot(1,2,1)
histogram(symbols_tx.signal,100,'Normalization','count') histogram(symbols_tx.signal,100,'Normalization','probability')
subplot(1,2,2) subplot(1,2,2)
histogram(symbols_db.signal,100,'Normalization','count') histogram(symbols_db.signal,100,'Normalization','probability')

View File

@@ -4,46 +4,10 @@ randkey = 1;
datarate = 448e9; datarate = 448e9;
fsym = round(datarate / log2(M)) ; fsym = round(datarate / log2(M)) ;
%%%%% PRBS Generation in correct shape for Modulation Format %%%%%% Tx_bits = Signalgenerator( ...
O = 16; %O of prbs "form", signalform.prms, ...
N = 2^(O); %length of prbs "M", M, ...
[~,seed] = prbs(O,1); %initialize first seed of prbs "order", 15).process();
bitpattern=[];
state = struct();
para = struct();
if M == 6
para.bl = 2^(O-2);
para.dimension = 5;
else
para.bl = 2^(O-1);
para.dimension = log2(M); %2.5bits/sym -> 2 bit/sym
end
para.rand = 0;
para.order = floor(O / log2(M));
para.skip =0;
para.bruijn = 0;
para.reset_prms = 0;
para.method = 1;
data_in = [];
global loop;
loop = 0;
[data_out,state_] = prms(data_in, state, para);
loop = 1;
[data_out,state_out] = prms(data_in, state_, para);
bitpattern = data_out';
if M == 6
bitpattern = reshape(bitpattern',[],1);
bitpattern = bitpattern(1:end-mod(length(bitpattern),5));
end
Tx_bits = Informationsignal(bitpattern);
%%%%% Duobinary %%%%%% %%%%% Duobinary %%%%%%
close all close all
@@ -96,8 +60,7 @@ for n = 10
Rx_bits = PAMmapper(M,0).demap(Symbols_rx); Rx_bits = PAMmapper(M,0).demap(Symbols_rx);
%%%%% Check BER of Bit Sequence %%%%%% %%%%% Check BER of Bit Sequence %%%%%
[~,error_num(n+1),ber,error_pos] = calc_ber(Tx_bits.signal,Rx_bits.signal,"skip_front",10,"skip_end",10,"returnErrorLocation",1); [~,error_num(n+1),ber,error_pos] = calc_ber(Tx_bits.signal,Rx_bits.signal,"skip_front",10,"skip_end",10,"returnErrorLocation",1);
% disp(['BER: ',sprintf('%.1E',ber),sprintf(' - Num. Err: %.1d',error_num(n+1)-2),' - - PAM-',num2str(M)]); % disp(['BER: ',sprintf('%.1E',ber),sprintf(' - Num. Err: %.1d',error_num(n+1)-2),' - - PAM-',num2str(M)]);

View File

@@ -70,10 +70,4 @@ h = heatmap(levels, levels, P, 'Colormap', parula, 'ColorbarVisible','on');
colormap(gca,[[1,1,1];flip(cbrewer2('Spectral',100))]);clim([0,ceil(max(P(:))*10)/10]); colormap(gca,[[1,1,1];flip(cbrewer2('Spectral',100))]);clim([0,ceil(max(P(:))*10)/10]);
h.XLabel = 'From state (level)'; h.XLabel = 'From state (level)';
h.YLabel = 'To state (level)'; h.YLabel = 'To state (level)';
h.Title = 'P(to | from)'; h.Title = 'P(to | from)';
%% 2) WEIGHTED TRANSITION GRAPH
% Use dtmc if you have Econometrics Toolbox:
mc = dtmc(P, 'StateNames', string(levels));
figure('Name','Markov Graph (dtmc)');
gp = graphplot(mc, 'ColorEdges',true, 'LabelEdges',true);

View File

@@ -0,0 +1,86 @@
% DUOBINARY CLASSES
% Define the filter taps
h_ = {1,[1 1],[1 2 1],[1 3 3 1]};
desc = {'$1$','$(1+D)$','$(1+D)^2$','$(1+D)^3$'};
for i = 1:length(h_)
h = h_{i};
[H, w] = freqz(h, 1, 1024, 1);
figure(1);
hold on
plot(w, 10*log10(abs(H)), 'LineWidth', 1, 'DisplayName',desc{i}); %todo
xlabel('Normalized Frequency');
ylabel('Amplitude in dB');
grid on;
ylim([-20,10]);
end
legend
beautifyBERplot("logscale",false,"setmarkers",false);
% mat2tikz_improved("C:/Users/Silas/Documents/6971e0b65b380ca6d71c837f/03_DSP_Techniques/tikz/duobinary_response.tikz")
%%
% 1+ alpha D
% Define the filter taps
h_ = {[1, 0],[1 0.3],[1 0.6],[1 0.9],[1 1],[1 2 1],[1 3 3 1]};
col = {[0 0 0],[0.2000,0.6275,0.1725],[0.1216, 0.4706, 0.7059],[0.8902,0.1020,0.1098],...
[0.2000,0.6275,0.1725],[0.9333, 0.9451, 0.9490],[0.9333, 0.9451, 0.9490]};
sty = {':','-','-','-','--','--','--'};
for i = 1:length(h_)
h = h_{i};
[H, w] = freqz(h, 1, 1024, 1);
figure(2);
hold on
dn = sprintf('$(1+ %.1f \\, D)$', h(end));
if i == 5
dn = sprintf('$(1+D)$', h(end));
elseif i == 6
dn = sprintf('$(1+D)^2$');
elseif i == 7
dn = sprintf('$(1+D)^3$');
elseif i == 1
dn = sprintf('$1$');
end
plot(w, 10*log10(abs(H)), 'LineWidth', 2,'DisplayName',dn,'Color',col{i},'LineStyle',sty{i}); %todo
xlabel('Normalized Frequency');
ylabel('Amplitude in dB');
grid on;
ylim([-20,10])
end
legend
beautifyBERplot("logscale",false,"setmarkers",false,"setcolors",false);
% mat2tikz_improved("C:/Users/Silas/Documents/6971e0b65b380ca6d71c837f/03_DSP_Techniques/tikz/partial_response_2.tikz")
%%
useprbs = 0;
M = 4;
randkey = 2;
fsym = 112e9;
Tx_bits = Signalgenerator("form", signalform.prms,"M", M,"order", 17).process();
Symbols_tx = PAMmapper(M,0).map(Tx_bits);
Symbols_tx.fs = fsym;
cnt = 1;
Symbols = Symbols_tx;
Symbols = Duobinary().precode(Symbols);
Symbols = Duobinary().encode(Symbols);
Symbols = Duobinary().decode(Symbols);
for alpha = 0:0.2:1
Symbols.signal = filter([1,alpha], 1, Symbols.signal);
Symbols.spectrum("fignum",2,"displayname",['coeff:',num2str(alpha)],"normalizeTo0dB",1,"normalizeToNyquist",0,"normalizeToSamplingRate",1);
end

View File

@@ -2,19 +2,10 @@
M = 4; M = 4;
apply_precode_at_tx = 1; apply_precode_at_tx = 1;
bitpattern = []; bits = Signalgenerator( ...
s = RandStream('twister','Seed',1); "form", signalform.prms, ...
for i = 1:log2(M) "M", M, ...
N = 2^(17-1); %length of prbs "order", 15).process();
bitpattern(:,i) = randi(s,[0 1], N, 1);
end
if M == 6
bitpattern = reshape(bitpattern',[],1);
bitpattern = bitpattern(1:end-mod(length(bitpattern),5));
end
bits = Informationsignal(bitpattern);
symbols = PAMmapper(M,0).map(bits); symbols = PAMmapper(M,0).map(bits);
@@ -23,12 +14,13 @@ if apply_precode_at_tx
else else
symbols_tx = symbols; symbols_tx = symbols;
end end
disp(['Tx Sequenz: -- RMS:',sprintf('%.1f',rms(symbols_tx.signal)),' - - Levels -',num2str(numel(unique(symbols_tx.signal)))]); disp(['Tx Sequenz: -- RMS:',sprintf('%.1f',rms(symbols_tx.signal)),' - - Levels -',num2str(numel(unique(symbols_tx.signal)))]);
unique(symbols_tx.signal) unique(symbols_tx.signal)
disp('- - - - - - - - - -'); disp('- - - - - - - - - -');
symbols_tx.signal = awgn(symbols_tx.signal,20,"measured",1); symbols_tx.signal = awgn(symbols_tx.signal,20,"measured",1);
% show2Dconstellation(symbols_tx,symbols_tx,"displayname",'VNLE Out','fignum',2241); show2Dconstellation(symbols_tx,symbols_tx,"displayname",'VNLE Out','fignum',2241);
if apply_precode_at_tx if apply_precode_at_tx

View File

@@ -1,100 +0,0 @@
% DUOBINARY CLASSES
% Define the filter taps
h_ = {1,[1 1],[1 2 1],[1 3 3 1]};
desc = {'$1$','$(1+D)$','$(1+D)^2$','$(1+D)^3$'};
for i = 1:length(h_)
h = h_{i};
[H, w] = freqz(h, 1, 1024, 1);
figure(1);
hold on
plot(w, 10*log10(abs(H)), 'LineWidth', 1, 'DisplayName',desc{i}); %todo
xlabel('Normalized Frequency');
ylabel('Amplitude in dB');
grid on;
ylim([-20,10]);
end
legend
beautifyBERplot("logscale",false,"setmarkers",false);
% mat2tikz_improved("C:/Users/Silas/Documents/6971e0b65b380ca6d71c837f/03_DSP_Techniques/tikz/duobinary_response.tikz")
%%
% 1+ alpha D
% Define the filter taps
h_ = {[1, 0],[1 0.2],[1 0.4],[1 0.6],[1 0.8],[1 1]};
for i = 1:length(h_)
h = h_{i};
[H, w] = freqz(h, 1, 1024, 1);
figure(2);
hold on
plot(w, 10*log10(abs(H)), 'LineWidth', 2,'DisplayName',sprintf('$\\alpha = %.1f$', h(end))); %todo
xlabel('Normalized Frequency');
ylabel('Amplitude in dB');
grid on;
ylim([-15,5])
end
legend
beautifyBERplot("logscale",false,"setmarkers",false);
% mat2tikz_improved("C:/Users/Silas/Documents/6971e0b65b380ca6d71c837f/03_DSP_Techniques/tikz/partial_response.tikz")
%%
useprbs = 0;
M = 4;
randkey = 2;
fsym = 112e9;
%%%%% PRBS Generation in correct shape for Modulation Format %%%%%%
O = 19; %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;
cnt = 1;
Symbols = Symbols_tx;
Symbols = Duobinary().precode(Symbols);
Symbols = Duobinary().encode(Symbols);
figure()
histogram()
% Symbols = Duobinary().decode(Symbols);
% coeff = [1,0.5];
%
% Symbols.signal = filter(coeff, 1, Symbols.signal);
% Symbols.spectrum("fignum",2,"displayname",['coeff:',num2str(coeff)],"normalizeTo0dB",1);