|
| pilot_f (pilot_f==0) |
|
| fwrite (fileID, pilot_f, 'float') |
|
| fclose (fileID) |
|
| fwrite (fileID, pilot_t, 'float') |
|
| fwrite (fileID_data, tx_data, 'int') |
|
| fclose (fileID_data) |
|
mod_fcn_16qam, tx_data | arrayfun () |
|
otherwise | fprintf ('Invalid MOD_ORDER(%d)! Must be in[2, 4, 16]\n', MOD_ORDER) |
|
end IFFT Reshape the symbol vector into two different spatial streams | length (tx_syms)/NUM_UE |
|
Reshape the symbol vector to a matrix with one column per OFDM symbol | length (SC_IND_DATA) |
|
| ifft_in_mat_A (SC_IND_PILOTS, :) |
|
Add CP Insert the cyclic prefix | if (CP_LEN > 0) tx_cp |
|
2 | sqrt () |
|
N_SC, NUM_UE, NUM_UE | zeros () |
|
| rx_vec_float (1:2:end) |
|
| rx_vec_float (2:2:end) |
|
| fwrite (fileID, rx_vec_float, 'float') |
|
end | fprintf ("CSI_estimation error: %d/%d\n", sum(sum(abs(squeeze(CSI_est(2,:,:)).'-H)>1e-3)), length(H(:))) |
|
id | size: (H_est pinv) |
|
| switch (MOD_ORDER) case 2 % BPSK rx_data |
|
Reshape to a vector | numel (tx_payload_mat)) |
|
pilot_t.', 1, NUM_UE | tx_payload_vec () |
|
|
Parameters | MOD_ORDER = 16 |
|
| N_SC = 1024 |
|
| SC_IND_DATA = 1:1024 |
|
| NUM_BS_ANT = 96 |
|
| NUM_UE = 4 |
|
| N_OFDM_SYMS = 36*NUM_UE |
|
| NUM_SUBFRAME = 10 |
|
| N_DATA_SYMS = N_OFDM_SYMS * length(SC_IND_DATA) |
|
| GENERATE_PILOT = 0 |
|
| GENERATE_DATA = 0 |
|
| CP_LEN = 0 |
|
| frmLen = 100 |
|
frame length Generate pilot if GENERATE_PILOT | pilot_f = randi(3,length(SC_IND_DATA),1)-2 |
|
| pilot_t = ifft(pilot_f, 1024) |
|
| fileID = fopen('pilot_f.bin','w') |
|
end Generate data if GENERATE_DATA | tx_data = randi(MOD_ORDER, 1, N_DATA_SYMS) - 1 |
|
| fileID_data = fopen('orig_data.bin','w') |
|
end Modulate data | modvec_bpsk = (1/sqrt(2)) .* [-1 1] |
|
| modvec_16qam = (1/sqrt(10)) .* [-3 -1 +3 +1] |
|
| mod_fcn_bpsk = @(x) complex(modvec_bpsk(1+x),0) |
|
| mod_fcn_qpsk = @(x) complex(modvec_bpsk(1+bitshift(x, -1)), modvec_bpsk(1+mod(x, 2))) |
|
| mod_fcn_16qam = @(x) complex(modvec_16qam(1+bitshift(x, -2)), modvec_16qam(1+mod(x,4))) |
|
switch MOD_ORDER case BPSK | tx_syms = arrayfun(mod_fcn_bpsk, tx_data) |
|
| return |
|
end IFFT Reshape the symbol vector into two different spatial streams | size |
|
| tx_data_orig = reshape(tx_data, length(SC_IND_DATA), N_OFDM_SYMS/NUM_UE, NUM_UE) |
|
Construct the IFFT input matrix | ifft_in_mat = zeros(NUM_BS_ANT, N_SC, N_OFDM_SYMS/NUM_BS_ANT) |
|
Insert the data and pilot | values |
|
Perform the IFFT | tx_payload_mat = ifft(ifft_in_mat, N_SC, 1) |
|
for | i |
|
end | pilot_all_ue = reshape(pilot_all_ue, N_SC,1,NUM_UE) |
|
| tx_mat_all = cat(2,pilot_all_ue,tx_payload_mat) |
|
| tx_mat = reshape(tx_mat_all,size(tx_mat_all,1)*size(tx_mat_all,2),size(tx_mat_all,3)) |
|
Rx data | rx_mat = tx_mat*H |
|
| rx_mat_all = reshape(rx_mat,size(tx_mat_all,1),size(tx_mat_all,2),NUM_BS_ANT) |
|
| rx_vec = reshape(rx_mat_all, 1, numel(rx_mat_all)) |
|
if GENERATE_DATA | rx_vec_float = zeros(1,size(rx_vec,2)*2) |
|
end CSI estimation | CSI_est = zeros(N_SC,NUM_BS_ANT,NUM_UE) |
|
| H_est = squeeze(CSI_est(1,:,:)) |
|
| rx_mat_data = rx_mat_all(:,:,NUM_UE+1:end) |
|
size | __pad0__ |
|
size | rx_data_fft = fft(rx_mat_data,N_SC,2) |
|
| rx_syms = precoder * rx_data_fft |
|
| rx_syms_mat = reshape(rx_syms, NUM_UE,N_SC,N_OFDM_SYMS/NUM_UE) |
|
| demod_fcn_bpsk = @(x) double(real(x)>0) |
|
| demod_fcn_qpsk = @(x) double(2*(real(x)>0) + 1*(imag(x)>0)) |
|
| demod_fcn_16qam = @(x) (8*(real(x)>0)) + (4*(abs(real(x))<0.6325)) + (2*(imag(x)>0)) + (1*(abs(imag(x))<0.6325)) |
|
case QPSK | rx_data = arrayfun(demod_fcn_qpsk, rx_syms) |
|