| 1 | function [yCDComp, kstart] = CDCompensation(y, D, lambda, z, Tsamp) |
| 2 | %% Chromatic dispersion compensation. |
| 3 | %% Params: |
| 4 | %% - y: received waveform with CD |
| 5 | %% - D: dispersion coefficient (ps / (nm km)) |
| 6 | %% - lambda: wavelength (nm) |
| 7 | %% - z: length of fibre (km) |
| 8 | %% - Tsamp: sampling time (s) |
| 9 | %% Output: |
| 10 | %% - yCDComp: y after performing CD compensation |
| 11 | |
| 12 | %% Convert everything to SI base units |
| 13 | c = 299792458; % m/s |
| 14 | D = D * 1e-6; % s/m^2 |
| 15 | lambda = lambda * 1e-9; % m |
| 16 | z = z * 1e3; % m |
| 17 | |
| 18 | %% Implementing Eq. (9) in [1]. |
| 19 | N = 2 * floor(abs(D) * lambda^2 * z / (2 * c * Tsamp^2)) + 1; |
| 20 | k = -floor(N / 2) : floor(N / 2); |
| 21 | kstart = -floor(N/2); |
| 22 | |
| 23 | % h: FIR filter |
| 24 | h = exp(-j * pi * c * Tsamp^2 * k .^ 2 / (D * lambda^2 * z)); |
| 25 | |
| 26 | len_fft = max(length(y), length(h)); |
| 27 | H = fft(h, len_fft); |
| 28 | Y = fft(y, len_fft); |
| 29 | |
| 30 | yCDComp = ifft(H.' .* Y); |
| 31 | l = (length(h) - 1) / 2; |
| 32 | if l > 0 |
| 33 | yCDComp = [yCDComp(l:end); yCDComp(1:l-1)]; |
| 34 | else |
| 35 | yCDComp = [yCDComp(end); yCDComp(1:end-1)]; |
| 36 | end |
| 37 | |
| 38 | end |
| 39 | %% References |
| 40 | %% [1]: S.J. Savory, Digital filters for coherent optical receivers, 2008. |