Files
imdd_silas/Theory/Mapping_Coding/partial_response/duobinary_back2back.m
Silas Oettinghaus 910486f536 Add partial response symbol mapping and IM/DD system example
- Implemented a new MATLAB script for partial response symbol mapping using Duobinary precoding.
- Added functions for printing constellation bit mapping and partial response state tables.
- Created a minimal example for an IM/DD system, including signal generation, modulation, and equalization processes.
- Integrated various components such as pulse shaping, optical modulation, and receiver processing.
- Included detailed configurations for parameters like bias, link length, and filter settings.
2026-04-24 09:04:44 +02:00

78 lines
2.8 KiB
Matlab

for M = [2 4 8]
bits = Signalgenerator("form", signalform.prms,"M", M,"order", 16).process();
mapper = PAMmapper(M,0);
symbols = mapper.map(bits);
db = Duobinary();
pr1 = Partialresponse();
symbols_pre = db.precode(symbols);
symbols_db = db.encode(symbols_pre);
symbols_rx = db.decode(symbols_db);
bits_rx = PAMmapper(M,0).demap(symbols_rx);
[~,~,ber,~] = calc_ber(bits.signal,bits_rx.signal,"skip_front",0,"skip_end",0,"returnErrorLocation",1);
disp(['Class BER: ',sprintf('%.1E',ber),' - PAM-',num2str(M)]);
symbols_pre_pr = pr1.precode(symbols,"M",M);
symbols_db_pr = pr1.encode(symbols_pre_pr,"M",M);
symbols_rx_pr = pr1.decode(symbols_db_pr,"M",M);
bits_rx_pr = mapper.demap(symbols_rx_pr);
[~,~,ber_pr,~] = calc_ber(bits.signal,bits_rx_pr.signal,"skip_front",0,"skip_end",0,"returnErrorLocation",1);
disp(['Partialresponse BER: ',sprintf('%.1E',ber_pr),' - PAM-',num2str(M)]);
pre_match = isequaln(symbols_pre.signal, symbols_pre_pr.signal);
enc_match = isequaln(symbols_db.signal, symbols_db_pr.signal);
dec_match = isequaln(symbols_rx.signal, symbols_rx_pr.signal);
pre_maxdiff = max(abs(symbols_pre.signal - symbols_pre_pr.signal));
enc_maxdiff = max(abs(symbols_db.signal - symbols_db_pr.signal));
dec_maxdiff = max(abs(symbols_rx.signal - symbols_rx_pr.signal));
disp(['Precode match: ',num2str(pre_match), ...
' | max abs diff: ',sprintf('%.3g',pre_maxdiff)]);
disp(['Encode match: ',num2str(enc_match), ...
' | max abs diff: ',sprintf('%.3g',enc_maxdiff)]);
disp(['Decode match: ',num2str(dec_match), ...
' | max abs diff: ',sprintf('%.3g',dec_maxdiff)]);
disp('---');
f = figure("Name",sprintf("PAM-%d Partial-Response Histograms",M));
t = tiledlayout(f,1,4,"TileSpacing","compact","Padding","compact");
title(t,sprintf("PAM-%d Symbol Histograms",M));
nexttile;
plotDiscreteHistogram(symbols.signal,sprintf("PAM-%d",M));
nexttile;
plotDiscreteHistogram(symbols_db_pr.signal,"Duobinary 1st Order");
nexttile;
plotDiscreteHistogram(getEncodedSymbols(symbols,M,2),"Duobinary 2nd Order");
nexttile;
plotDiscreteHistogram(getEncodedSymbols(symbols,M,3),"Duobinary 3rd Order");
end
function y = getEncodedSymbols(symbols, M, order)
pr = Partialresponse("order",order);
y = pr.encode(pr.precode(symbols,"M",M),"M",M).signal;
end
function plotDiscreteHistogram(x, plot_title)
levels = unique(x(:)).';
counts = zeros(size(levels));
for idx = 1:numel(levels)
counts(idx) = sum(abs(x - levels(idx)) < 1e-12);
end
bar(levels, counts, 0.9, "FaceColor", [0.2 0.45 0.75], "EdgeColor", "none");
grid on;
box on;
xlabel("Level");
ylabel("Count");
title(plot_title);
xticks(levels);
end