From 8fd68c0a548b4fd905b18ee07cd1af9c8b1647e2 Mon Sep 17 00:00:00 2001 From: Silas Oettinghaus Date: Thu, 23 Apr 2026 16:16:45 +0200 Subject: [PATCH] PR and DB fummelei --- .../duobinary_emulation_minimal_example.m | 26 ++--- .../duobinary_minimal_example.m | 47 +------- .../pam_6_differential_code_understand.m | 8 +- .../partial_response_filter.m | 86 +++++++++++++++ .../test_db_minimal_example.m | 20 ++-- .../partial_response_filter.m | 100 ------------------ 6 files changed, 104 insertions(+), 183 deletions(-) rename Theory/Mapping_Coding/{ => partial_response}/duobinary_emulation_minimal_example.m (69%) rename Theory/Mapping_Coding/{ => partial_response}/duobinary_minimal_example.m (76%) rename Theory/Mapping_Coding/{ => partial_response}/pam_6_differential_code_understand.m (88%) create mode 100644 Theory/Mapping_Coding/partial_response/partial_response_filter.m rename Theory/Mapping_Coding/{ => partial_response}/test_db_minimal_example.m (80%) delete mode 100644 Theory/Signal_Processing/partial_response_filter.m diff --git a/Theory/Mapping_Coding/duobinary_emulation_minimal_example.m b/Theory/Mapping_Coding/partial_response/duobinary_emulation_minimal_example.m similarity index 69% rename from Theory/Mapping_Coding/duobinary_emulation_minimal_example.m rename to Theory/Mapping_Coding/partial_response/duobinary_emulation_minimal_example.m index a5444f8..95fa05e 100644 --- a/Theory/Mapping_Coding/duobinary_emulation_minimal_example.m +++ b/Theory/Mapping_Coding/partial_response/duobinary_emulation_minimal_example.m @@ -3,22 +3,12 @@ M = 4; apply_precode = 1; -bitpattern = []; -s = RandStream('twister','Seed',1); -for i = 1:log2(M) - N = 2^(17-1); %length of prbs - 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); +bits = Signalgenerator( ... + "form", signalform.prms, ... + "M", M, ... + "order", 15).process(); symbols = PAMmapper(M,0).map(bits); - bits_rx = PAMmapper(M,0).demap(symbols); [~,~,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 symbols_tx = symbols; 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); @@ -62,7 +48,7 @@ disp(['BER: ',sprintf('%.1E',ber),' - - PAM-',num2str(M)]); figure() subplot(1,2,1) -histogram(symbols_tx.signal,100,'Normalization','count') +histogram(symbols_tx.signal,100,'Normalization','probability') subplot(1,2,2) -histogram(symbols_db.signal,100,'Normalization','count') \ No newline at end of file +histogram(symbols_db.signal,100,'Normalization','probability') \ No newline at end of file diff --git a/Theory/Mapping_Coding/duobinary_minimal_example.m b/Theory/Mapping_Coding/partial_response/duobinary_minimal_example.m similarity index 76% rename from Theory/Mapping_Coding/duobinary_minimal_example.m rename to Theory/Mapping_Coding/partial_response/duobinary_minimal_example.m index c39183e..b8f0703 100644 --- a/Theory/Mapping_Coding/duobinary_minimal_example.m +++ b/Theory/Mapping_Coding/partial_response/duobinary_minimal_example.m @@ -4,46 +4,10 @@ randkey = 1; datarate = 448e9; fsym = round(datarate / log2(M)) ; -%%%%% PRBS Generation in correct shape for Modulation Format %%%%%% -O = 16; %O of prbs -N = 2^(O); %length of prbs -[~,seed] = prbs(O,1); %initialize first seed of prbs -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); +Tx_bits = Signalgenerator( ... + "form", signalform.prms, ... + "M", M, ... + "order", 15).process(); %%%%% Duobinary %%%%%% close all @@ -96,8 +60,7 @@ for n = 10 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); % disp(['BER: ',sprintf('%.1E',ber),sprintf(' - Num. Err: %.1d',error_num(n+1)-2),' - - PAM-',num2str(M)]); diff --git a/Theory/Mapping_Coding/pam_6_differential_code_understand.m b/Theory/Mapping_Coding/partial_response/pam_6_differential_code_understand.m similarity index 88% rename from Theory/Mapping_Coding/pam_6_differential_code_understand.m rename to Theory/Mapping_Coding/partial_response/pam_6_differential_code_understand.m index 3f13c5a..c019c12 100644 --- a/Theory/Mapping_Coding/pam_6_differential_code_understand.m +++ b/Theory/Mapping_Coding/partial_response/pam_6_differential_code_understand.m @@ -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]); h.XLabel = 'From state (level)'; h.YLabel = 'To state (level)'; -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); \ No newline at end of file +h.Title = 'P(to | from)'; \ No newline at end of file diff --git a/Theory/Mapping_Coding/partial_response/partial_response_filter.m b/Theory/Mapping_Coding/partial_response/partial_response_filter.m new file mode 100644 index 0000000..f5361d0 --- /dev/null +++ b/Theory/Mapping_Coding/partial_response/partial_response_filter.m @@ -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 \ No newline at end of file diff --git a/Theory/Mapping_Coding/test_db_minimal_example.m b/Theory/Mapping_Coding/partial_response/test_db_minimal_example.m similarity index 80% rename from Theory/Mapping_Coding/test_db_minimal_example.m rename to Theory/Mapping_Coding/partial_response/test_db_minimal_example.m index 55ee52a..e0ef0af 100644 --- a/Theory/Mapping_Coding/test_db_minimal_example.m +++ b/Theory/Mapping_Coding/partial_response/test_db_minimal_example.m @@ -2,19 +2,10 @@ M = 4; apply_precode_at_tx = 1; -bitpattern = []; -s = RandStream('twister','Seed',1); -for i = 1:log2(M) - N = 2^(17-1); %length of prbs - 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); +bits = Signalgenerator( ... + "form", signalform.prms, ... + "M", M, ... + "order", 15).process(); symbols = PAMmapper(M,0).map(bits); @@ -23,12 +14,13 @@ if apply_precode_at_tx else symbols_tx = symbols; end + disp(['Tx Sequenz: -- RMS:',sprintf('%.1f',rms(symbols_tx.signal)),' - - Levels -',num2str(numel(unique(symbols_tx.signal)))]); unique(symbols_tx.signal) disp('- - - - - - - - - -'); 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 diff --git a/Theory/Signal_Processing/partial_response_filter.m b/Theory/Signal_Processing/partial_response_filter.m deleted file mode 100644 index 95db41f..0000000 --- a/Theory/Signal_Processing/partial_response_filter.m +++ /dev/null @@ -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); \ No newline at end of file