├── AFDM_demod.m ├── AFDM_mod.m ├── README.md ├── LICENSE ├── Gen_channel_mtx.m └── main_AFDM_sim.m /AFDM_demod.m: -------------------------------------------------------------------------------- 1 | % Description: AFDM demodulation 2 | % y: received data 3 | % c1, c2: AFDM parameters 4 | 5 | function [out] = AFDM_demod(y, c1, c2) 6 | 7 | N = size(y,1); 8 | F = dftmtx(N); 9 | F = F./norm(F); 10 | L1 = diag(exp(-1i*2*pi*c1*((0:N-1).^2))); 11 | L2 = diag(exp(-1i*2*pi*c2*((0:N-1).^2))); 12 | A = L2*F*L1; 13 | out = A*y; 14 | 15 | end -------------------------------------------------------------------------------- /AFDM_mod.m: -------------------------------------------------------------------------------- 1 | % Description: AFDM Modulation 2 | % x: input data vector 3 | % c1, c2: AFDM parameters 4 | 5 | function [out] = AFDM_mod(x, c1, c2) 6 | 7 | N = size(x,1); 8 | F = dftmtx(N); 9 | F = F./norm(F); 10 | L1 = diag(exp(-1i*2*pi*c1*((0:N-1).^2))); 11 | L2 = diag(exp(-1i*2*pi*c2*((0:N-1).^2))); 12 | A = L2*F*L1; 13 | out = A'*x; 14 | 15 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## AFDM-simple-simulation 2 | A simple implementation of affine frequency division multiplexing (AFDM) system. 3 | 4 | ## References 5 | [R1]. Bemani, Ali, Nassar Ksairi, and Marios Kountouris. "Affine frequency division multiplexing for next generation wireless communications." IEEE Transactions on Wireless Communications 22.11 (2023): 8214-8229. 6 | 7 | [R2]. T. Thaj and E. Viterbo,``Low Complexity Iterative Rake Decision Feedback Equalizer for ZeroPadded OTFS Systems’’, in IEEE Transactions on Vehicular Technology, vol. 69, no. 12, pp. 15606- 15622, Dec. 2020, doi: 10.1109/TVT.2020.3044276. 8 | 9 | [R3]. 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2025, jerryz 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | 3. Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /Gen_channel_mtx.m: -------------------------------------------------------------------------------- 1 | % Copyright (c) 2025, Ruijie Zhang, University of Chinese Academy of Sciences 2 | % All rights reserved. 3 | % 4 | % Redistribution and use in source and binary forms, with or without 5 | % modification, are permitted provided that the following conditions are met: 6 | % 7 | % 1. Redistributions of source code must retain the above copyright notice, this 8 | % list of conditions and the following disclaimer. 9 | % 2. Redistributions in binary form must reproduce the above copyright notice, 10 | % this list of conditions and the following disclaimer in the documentation 11 | % and/or other materials provided with the distribution. 12 | % 3. The reference listed below should be cited if the corresponding codes are used for 13 | % publication. 14 | % 15 | %THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | %ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | %WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | %DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | %ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | %(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | %LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | %ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | %(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | %SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | % 26 | % - Freely distributed for educational and research purposes 27 | 28 | % [R1]. Bemani, Ali, Nassar Ksairi, and Marios Kountouris. "Affine frequency division multiplexing for next generation wireless communications." IEEE Transactions on Wireless Communications 22.11 (2023): 8214-8229. 29 | 30 | 31 | % Description: Generate delay-Doppler channel matrix, see equation (24) in [R1]. 32 | function [H] = Gen_channel_mtx(N, taps, chan_coef, delay_taps, Doppler_freq, c1) 33 | Pi = [zeros(1,N-1) 1]; 34 | Pi = toeplitz([Pi(1) fliplr(Pi(2:end))], Pi); % equation (25) in [R1] 35 | H = zeros(N,N); 36 | for i = 1:taps 37 | h_i = chan_coef(i); 38 | l_i = delay_taps(i); 39 | f_i = Doppler_freq(i); 40 | D_i = diag(exp(-1i*2*pi*f_i*(0:N-1))); 41 | for n = 0:N-1 42 | if n < l_i 43 | temp(n+1) = exp(-1i*2*pi*c1*(N^2 - 2*N*(l_i-n))); 44 | else 45 | temp(n+1) = 1; 46 | end 47 | end 48 | G_i = diag(temp); % equation (26) in [R1] 49 | H = H + h_i * G_i * D_i * Pi^l_i; 50 | end -------------------------------------------------------------------------------- /main_AFDM_sim.m: -------------------------------------------------------------------------------- 1 | % Copyright (c) 2025, Ruijie Zhang, University of Chinese Academy of Sciences 2 | % All rights reserved. 3 | % 4 | % Redistribution and use in source and binary forms, with or without 5 | % modification, are permitted provided that the following conditions are met: 6 | % 7 | % 1. Redistributions of source code must retain the above copyright notice, this 8 | % list of conditions and the following disclaimer. 9 | % 2. Redistributions in binary form must reproduce the above copyright notice, 10 | % this list of conditions and the following disclaimer in the documentation 11 | % and/or other materials provided with the distribution. 12 | % 3. The reference listed below should be cited if the corresponding codes are used for 13 | % publication. 14 | % 15 | %THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 16 | %ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | %WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | %DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 19 | %ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | %(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | %LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | %ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | %(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | %SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | % 26 | % - Freely distributed for educational and research purposes 27 | 28 | % [R1]. Bemani, Ali, Nassar Ksairi, and Marios Kountouris. "Affine frequency division multiplexing for next generation wireless communications." IEEE Transactions on Wireless Communications 22.11 (2023): 8214-8229. 29 | 30 | 31 | 32 | clear; clc; close all; 33 | rng(1) 34 | 35 | %% System parameters %% 36 | M_mod = 4; % size of QAM constellation 37 | N = 64; % number of symbols(subcarriers) 38 | 39 | car_fre = 4*10^9; % carrier frequency 40 | delta_f = 15*10^3; % symbol spacing 41 | T = 1/delta_f; % symbol duration 42 | 43 | eng_sqrt = (M_mod==2)+(M_mod~=2)*sqrt((M_mod-1)/6*(2^2)); % average power per symbol 44 | SNR_dB = 0:2:16; % set SNR here 45 | SNR = 10.^(SNR_dB/10); 46 | sigma_2 = (abs(eng_sqrt)^2)./SNR; % noise power 47 | 48 | N_frame = 10000; % number of simulation frames 49 | 50 | %% Generate synthetic delay-Doppler channel %% 51 | taps = 9; % number of paths 52 | l_max = 3; % maximum normalized delay index 53 | k_max = 4; % maximum normalized Doppler index 54 | chan_coef = 1/sqrt(2).*(randn(1,taps)+1i.*randn(1,taps)); % follows Rayleigh distribution 55 | delay_taps = randi(l_max, [1,taps]); 56 | delay_taps = sort(delay_taps-min(delay_taps)); % integer delay shifts: random delays in range [0,l_max-1] 57 | Doppler_taps = k_max-2*k_max*rand(1,taps); % fractional Doppler shifts: uniformly distributed Doppler shifts in range [-k_max,k_max] 58 | % Doppler_taps = round(Doppler_taps); % cast to integer Doppler shifts 59 | Doppler_freq = Doppler_taps/(N*T); % f=k/(NT),f:Doppler shifts(Hz),k:normalized Doppler shifts 60 | 61 | %% AFDM parameters %% 62 | max_Doppler = max(Doppler_taps); 63 | max_delay = max(delay_taps); 64 | 65 | CPP_len = max_delay; % CPP_len >= l_max-1 66 | N_data = N-CPP_len; % length of data symbols 67 | 68 | k_v = 1; % guard interval to combat fractional Doppler shifts, see equation (38) in [R1] 69 | if (2*(max_Doppler+k_v)*(max_delay+1)+max_delay)>N_data 70 | error('subcarrier orthogonality is not satisfied'); 71 | end 72 | c1 = (2*(max_Doppler+k_v)+1)/(2*N_data); % equation (48) in [R1] 73 | c2 = 1/(N_data^2); 74 | 75 | %% Generate channel matrix %% 76 | % discrete-time channel 77 | L_set = unique(delay_taps); 78 | gs=zeros(max_delay+1,N); 79 | for q=0:N-1 80 | for i=1:taps 81 | g_i=chan_coef(i); 82 | l_i=delay_taps(i); 83 | f_i=Doppler_freq(i); 84 | gs(l_i+1,q+1)=gs(l_i+1,q+1)+g_i*exp(-1i*2*pi*f_i*q); % equation (23) in [R1] 85 | end 86 | end 87 | 88 | % channel matrix form 89 | H = Gen_channel_mtx(N, taps, chan_coef, delay_taps, Doppler_freq, c1); % equation (24) in [R1] 90 | % Observe the structure of H 91 | % imagesc(abs(H)) 92 | 93 | %% Start main simulation %% 94 | for iesn0 = 1:length(SNR_dB) 95 | for iframe = 1:N_frame 96 | %% Tx data generation %% 97 | x = randi([0, M_mod-1], N_data, 1); % generate random bits 98 | 99 | x_qam = qammod(x, M_mod, 'gray'); % QAM modulation 100 | 101 | s = AFDM_mod(x_qam, c1, c2); % AFDM modulation 102 | 103 | cpp = s(N_data-CPP_len:N_data-1).*exp(-1i*2*pi*c1*(N^2+2*N*(-CPP_len:-1).')); % generate CPP 104 | s_cpp = [cpp; s]; % Insert CPP 105 | 106 | %% Through delay-Doppler channel %% 107 | r=zeros(N,1); 108 | for q=1:N 109 | for l=(L_set+1) 110 | if(q>=l) 111 | r(q)=r(q)+gs(l,q)*s_cpp(q-l+1); %equation (18) in [R1] 112 | end 113 | end 114 | end 115 | w = sqrt(sigma_2(iesn0)/2) * (randn(size(s_cpp)) + 1i*randn(size(s_cpp))); % add Gaussian noise 116 | r=r+w; 117 | % r=H*s_cpp+w; % or simply do this 118 | 119 | %% Rx detection %% 120 | x_est = H'/(H*H'+sigma_2(iesn0)*eye(N))*r; % MMSE equalization, ideal channel estimation 121 | 122 | x_est_no_cpp = x_est(CPP_len+1:end); % discard CPP 123 | 124 | y = AFDM_demod(x_est_no_cpp, c1, c2); % AFDM demodulation 125 | 126 | x_est_bit = qamdemod(y, M_mod, 'gray'); % QAM demodulation 127 | 128 | %% Error count %% 129 | err_count(iframe) = sum(x_est_bit ~= x); % calculate error bits 130 | end 131 | ber(iesn0) = sum(err_count)/length(x)/N_frame; % calculate bit error rate 132 | end 133 | disp(ber) 134 | 135 | %% Plot bit error rate %% 136 | figure(1) 137 | semilogy(SNR_dB, ber, 'b-o') 138 | legend('MMSE equalization') 139 | xlabel('SNR(dB)') 140 | ylabel('BER') 141 | title('BER of AFDM systems') 142 | grid on --------------------------------------------------------------------------------