From: Adrian Iain Lam Date: Sun, 26 May 2019 02:04:18 +0000 (+0100) Subject: Minor bug fixes and code formatting X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=refs%2Fheads%2Fmaster;p=100GbE-PON.git Minor bug fixes and code formatting --- diff --git a/main.m b/main.m index 38dcccc..8b96d33 100644 --- a/main.m +++ b/main.m @@ -8,7 +8,6 @@ Rsym = 28e9; % symbol rate (sym/sec) zs = 42; plotlen = length(zs); - %% Tx RRC filter properties rolloff = 0.25; span = 6; % filter span @@ -54,7 +53,7 @@ Eperphoton = hc / (lambda * 1e-9); % J %% Stores result to be plotted ber = zeros(plotlen, 1); if plotlen > 1 - fig = figure; hold on; + fig = figure; end %% sps and Tsamp change at Tx/Rx, save these for later. @@ -118,16 +117,16 @@ for i = 1 : plotlen Tsamp = TsampOrig; %% Split-step Fourier - [A_x, A_y] = ssfs(A_x, A_y, D, lambda, z, dz, Tsamp, gamma, alpha); + [Al_x, Al_y] = ssfs(A_x, A_y, D, lambda, z, dz, Tsamp, gamma, alpha); %% Phase noise - A_x = phaseNoise(A_x, linewidthTx, linewidthLO, Tsamp); - A_y = phaseNoise(A_y, linewidthTx, linewidthLO, Tsamp); + Al_x = phaseNoise(Al_x, linewidthTx, linewidthLO, Tsamp); + Al_y = phaseNoise(Al_y, linewidthTx, linewidthLO, Tsamp); %% Here, only receive the central channel 1. - % For channel n: A_x .* conj(carriers(:, n)); etc. - r_x = rxFilter(A_x, rolloff, span, sps); - r_y = rxFilter(A_y, rolloff, span, sps); + % For channel n: Al_x .* conj(carriers(:, n)); etc. + r_x = rxFilter(Al_x, rolloff, span, sps); + r_y = rxFilter(Al_y, rolloff, span, sps); % Rx filter performs downsampling as well, keep track of this sps = 2; Tsamp = Tsamp * spsOrig / sps; @@ -160,7 +159,7 @@ for i = 1 : plotlen [~, ber(i)] = biterr([data_x(:, 1); data_y(:, 1)], [demod_x; demod_y]); q = 20 * log10(erfcinv(2*ber)*sqrt(2)); - if plotlen > 1 + if i > 1 figure(fig); plot(zs, q); end diff --git a/pdm_adaptiveCMA.m b/pdm_adaptiveCMA.m index 6dca946..a5abf73 100644 --- a/pdm_adaptiveCMA.m +++ b/pdm_adaptiveCMA.m @@ -3,7 +3,7 @@ function [x, y] = pdm_adaptiveCMA(rx, ry) %% Input: rx, ry: Both polarizations of received signal %% Output: x, y: Equalizaed signal - taps = 19; % Number of taps. Should be odd. + taps = 15; % Number of taps. Should be odd. mu = 1e-3; % Convergence parameter for gradient descent. hxx = zeros(taps, 1); @@ -39,8 +39,10 @@ function [x, y] = pdm_adaptiveCMA(rx, ry) yp = [zeros((taps - 1) / 2 - it + 1, 1); ry(1:it + (taps - 1) / 2)]; elseif it + (taps - 1) / 2 > numSymbs %% If near the end, append zeros - xp = [rx(it - (taps - 1) / 2 : end); zeros(it + (taps - 1) / 2 - numSymbs, 1)]; - yp = [ry(it - (taps - 1) / 2 : end); zeros(it + (taps - 1) / 2 - numSymbs, 1)]; + xp = [rx(it - (taps - 1) / 2 : end); ... + zeros(it + (taps - 1) / 2 - numSymbs, 1)]; + yp = [ry(it - (taps - 1) / 2 : end); ... + zeros(it + (taps - 1) / 2 - numSymbs, 1)]; else %% Just slice the signal xp = rx(it - (taps - 1) / 2 : it + (taps - 1) / 2); diff --git a/phaseNoise.m b/phaseNoise.m index 4363c22..65dcde9 100644 --- a/phaseNoise.m +++ b/phaseNoise.m @@ -1,4 +1,4 @@ -function [xPN, phasenoise] = phaseNoise(x, linewidthTx, linewidthLO, Tsamp) +function [xPN, phasenoise] = phaseNoise(x, linewidthTx, linewidthLO, Tsamp) %% Simulates laser phase noise. %% Inputs: %% - x: input waveform