Commit 8d5bf5ce authored by Ben Wojtowicz's avatar Ben Wojtowicz

adding lte functions

parent eadc9918
%
% Copyright 2011 Ben Wojtowicz
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% Function: lte_bch_channel_decode
% Description: Channel decodes the broadcast channel
% Inputs: bch_bits - Broadcast channel encoded
% bits
% Outputs: mib - Master information block bits
% N_ant - Number of antenna ports used
% Spec: 3GPP TS 36.212 section 5.3.1 v10.1.0
% Notes: None
% Rev History: Ben Wojtowicz 11/12/2011 Created
%
function [mib, N_ant] = lte_bch_channel_decode(bch_bits)
% Rate match to get the d_bits
d_bits = lte_rate_unmatch(bch_bits);
d_bits = reshape(d_bits, 1, []);
% Convert from soft NRZ to hard bits for viterbi decoder
for(n=1:length(d_bits))
if(d_bits(n) > 0)
d_bits(n) = 0;
else
d_bits(n) = 1;
endif
endfor
% Viterbi decode the d_bits to get the c_bits
c_bits = cmn_viterbi_decode(d_bits, 7, 3, [133, 171, 165]);
% Recover a_bits and p_bits
a_bits = c_bits(1:24);
p_bits = c_bits(25:40);
% Calculate p_bits
calc_p_bits = lte_calc_crc(a_bits, 16);
% Try all p_bit masks
ant_mask_1 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
ant_mask_2 = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
ant_mask_4 = [0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1];
check_1 = 0;
check_2 = 0;
check_4 = 0;
for(n=0:length(calc_p_bits)-1)
bit = mod(calc_p_bits(n+1) + ant_mask_1(n+1), 2);
check_1 = check_1 + abs(bit-p_bits(n+1));
bit = mod(calc_p_bits(n+1) + ant_mask_2(n+1), 2);
check_2 = check_2 + abs(bit-p_bits(n+1));
bit = mod(calc_p_bits(n+1) + ant_mask_4(n+1), 2);
check_4 = check_4 + abs(bit-p_bits(n+1));
endfor
if(check_1 == 0)
N_ant = 1;
mib = a_bits;
elseif(check_2 == 0)
N_ant = 2;
mib = a_bits;
elseif(check_4 == 0)
N_ant = 4;
mib = a_bits;
else
N_ant = 0;
mib = 0;
endif
endfunction
function [d_bits] = lte_rate_unmatch(e_bits)
% In order to undo bit collection, selection and transmission, a dummy block must be
% sub-block interleaved to determine where NULL bits are to be inserted
% Sub block interleaving
% Step 1: Assign C_cc_sb to 32
C_cc_sb = 32;
% Step 2: Determine the number of rows
R_cc_sb = 0;
d_bits_len = 40; % FIXME This is specific for BCH
while(d_bits_len > (C_cc_sb*R_cc_sb))
R_cc_sb = R_cc_sb + 1;
endwhile
% Inter-column permutation values
ic_perm = [1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31, 0, 16, 8, 24, 4, 20, 12, 28, 2, 18, 10, 26, 6, 22, 14, 30] + 1;
% Steps 3, 4, and 5
for(x=0:3-1)
% Step 3: Pack data into matrix and pad with dummy (NULL==10000 for this routine)
if(d_bits_len < (C_cc_sb*R_cc_sb))
N_dummy = C_cc_sb*R_cc_sb - d_bits_len;
else
N_dummy = 0;
endif
tmp = [10000*ones(1, N_dummy), zeros(1,d_bits_len)];
idx = 0;
for(n=0:R_cc_sb-1)
for(m=0:C_cc_sb-1)
sb_mat(n+1,m+1) = tmp(idx+1);
idx = idx + 1;
endfor
endfor
% Step 4: Inter-column permutation
for(n=0:R_cc_sb-1)
for(m=0:C_cc_sb-1)
sb_perm_mat(n+1,m+1) = sb_mat(n+1,ic_perm(m+1));
endfor
endfor
% Step 5: Read out the bits
idx = 0;
for(m=0:C_cc_sb-1)
for(n=0:R_cc_sb-1)
v(x+1,idx+1) = sb_perm_mat(n+1,m+1);
idx = idx + 1;
endfor
endfor
endfor
% Undo bit collection, selection, and transmission by recreating the circular buffer
K_pi = R_cc_sb*C_cc_sb;
K_w = 3*K_pi;
w_dum = [v(1,:), v(2,:), v(3,:)];
w = 10000*ones(1,K_w);
E = 1920;
k_idx = 0;
j_idx = 0;
while(k_idx < E)
if(w_dum(mod(j_idx, K_w)+1) != 10000)
% FIXME: soft combine the inputs
if(w(mod(j_idx, K_w)+1) == 10000)
w(mod(j_idx, K_w)+1) = e_bits(k_idx+1);
% elseif(e_bits(k_idx+1) != 10000)
% w(mod(j_idx, K_w)+1) = w(mod(j_idx, K_w)+1) + e_bits(k_idx+1);
endif
k_idx = k_idx + 1;
endif
j_idx = j_idx + 1;
endwhile
% Recreate sub-block interleaver output
v(1,:) = w(1:K_pi);
v(2,:) = w(K_pi+1:2*K_pi);
v(3,:) = w(2*K_pi+1:end);
% Sub block deinterleaving
% Steps 5, 4, and 3
for(x=0:3-1)
% Step 5: Load the permuted matrix
idx = 0;
for(m=0:C_cc_sb-1)
for(n=0:R_cc_sb-1)
sb_perm_mat(n+1,m+1) = v(x+1,idx+1);
idx = idx + 1;
endfor
endfor
% Step 4: Undo permutation
for(n=0:R_cc_sb-1)
for(m=0:C_cc_sb-1)
sb_mat(n+1,ic_perm(m+1)) = sb_perm_mat(n+1,m+1);
endfor
endfor
% Step 3: Unpack the data and remove dummy
if(d_bits_len < (C_cc_sb*R_cc_sb))
N_dummy = C_cc_sb*R_cc_sb - d_bits_len;
else
N_dummy = 0;
endif
idx = 0;
for(n=0:R_cc_sb-1)
for(m=0:C_cc_sb-1)
tmp(idx+1) = sb_mat(n+1,m+1);
idx = idx + 1;
endfor
endfor
d_bits(x+1,:) = tmp(N_dummy+1:end);
endfor
endfunction
%
% Copyright 2011 Ben Wojtowicz
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% Function: lte_bch_channel_encode
% Description: Channel encodes the broadcast channel
% Inputs: mib - Master information block bits
% N_ant - Number of antenna ports to use
% Outputs: bch_bits - Broadcast channel encoded
% bits
% Spec: 3GPP TS 36.212 section 5.3.1 v10.1.0
% Notes: None
% Rev History: Ben Wojtowicz 10/30/2011 Created
%
function [bch_bits] = lte_bch_channel_encode(mib, N_ant)
% Check mib
if(length(mib) ~= 24)
printf("ERROR: Invalid mib (length is %u, should be 24)\n", length(mib));
bch_bits = 0;
return;
endif
% Check N_ant
if(N_ant == 1)
ant_mask = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
elseif(N_ant == 2)
ant_mask = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
elseif(N_ant == 4)
ant_mask = [0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1];
else
printf("ERROR: Invalid N_ant (%u)\n", N_ant);
bch_bits = 0;
return;
endif
% Define a_bits
a_bits = mib;
% Calculate p_bits
p_bits = lte_calc_crc(a_bits, 16);
% Mask p_bits
for(n=0:length(p_bits)-1)
p_bits(n+1) = mod(p_bits(n+1) + ant_mask(n+1), 2);
endfor
% Construct c_bits
c_bits = [a_bits, p_bits];
% Determine d_bits
d_bits = cmn_conv_encode(c_bits, 7, 3, [133, 171, 165], 1);
d_bits = reshape(d_bits, 3, []);
% Determine e_bits
e_bits = lte_rate_match(d_bits);
% Return the e_bits
bch_bits = e_bits;
endfunction
function [e_bits] = lte_rate_match(d_bits)
[this_is_three, d_bits_len] = size(d_bits);
% Sub block interleaving
% Step 1: Assign C_cc_sb to 32
C_cc_sb = 32;
% Step 2: Determine the number of rows
R_cc_sb = 0;
while(d_bits_len > (C_cc_sb*R_cc_sb))
R_cc_sb = R_cc_sb + 1;
endwhile
% Inter-column permutation values
ic_perm = [1, 17, 9, 25, 5, 21, 13, 29, 3, 19, 11, 27, 7, 23, 15, 31, 0, 16, 8, 24, 4, 20, 12, 28, 2, 18, 10, 26, 6, 22, 14, 30] + 1;
% Steps 3, 4, and 5
for(x=0:this_is_three-1)
% Step 3: Pack data into matrix and pad with dummy (NULL==10000 for this routine)
if(d_bits_len < (C_cc_sb*R_cc_sb))
N_dummy = C_cc_sb*R_cc_sb - d_bits_len;
else
N_dummy = 0;
endif
tmp = [10000*ones(1, N_dummy), d_bits(x+1,:)];
idx = 0;
for(n=0:R_cc_sb-1)
for(m=0:C_cc_sb-1)
sb_mat(n+1,m+1) = tmp(idx+1);
idx = idx + 1;
endfor
endfor
% Step 4: Inter-column permutation
for(n=0:R_cc_sb-1)
for(m=0:C_cc_sb-1)
sb_perm_mat(n+1,m+1) = sb_mat(n+1,ic_perm(m+1));
endfor
endfor
% Step 5: Read out the bits
idx = 0;
for(m=0:C_cc_sb-1)
for(n=0:R_cc_sb-1)
v(x+1,idx+1) = sb_perm_mat(n+1,m+1);
idx = idx + 1;
endfor
endfor
endfor
K_pi = R_cc_sb*C_cc_sb;
% Bit collection, selection and transmission
% Create circular buffer and define E, the number of output bits
w = [v(1,:), v(2,:), v(3,:)];
K_w = 3*K_pi;
E = 1920;
% Create output
k_idx = 0;
j_idx = 0;
while(k_idx < E)
if(w(mod(j_idx, K_w)+1) ~= 10000)
e_bits(k_idx+1) = w(mod(j_idx, K_w)+1);
k_idx = k_idx + 1;
endif
j_idx = j_idx + 1;
endwhile
endfunction
\ No newline at end of file
%
% Copyright 2011 Ben Wojtowicz
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% Function: lte_calc_crc
% Description: Calculates one of the LTE CRCs.
% Inputs: in_bits - Input bits
% crc_type - Which CRC to compute (8, 16,
% 24A, or 24B)
% Outputs: crc_bits - CRC bits
% Spec: 3GPP TS 36.212 section 5.1.1 v10.1.0
% Notes: None
% Rev History: Ben Wojtowicz 11/18/2011 Created
%
function [crc_bits] = lte_calc_crc(in_bits, crc_type)
% Check crc_type
if(crc_type == 8)
crc_poly = [1,1,0,0,1,1,0,1,1];
crc_len = 8;
elseif(crc_type == 16)
crc_poly = [1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1];
crc_len = 16;
elseif(crc_type == "24A")
crc_poly = [1,1,0,0,0,0,1,1,0,0,1,0,0,1,1,0,0,1,1,1,1,1,0,1,1];
crc_len = 24;
elseif(crc_type == "24B")
crc_poly = [1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1];
crc_len = 24;
else
printf("ERROR: Invalid crc_type (%s)\n", crc_type);
crc_bits = 0;
return;
endif
% Define local variables
crc_rem = zeros(1,crc_len+1);
tmp_array = [in_bits, zeros(1,crc_len)];
% Loop to calculate CRC bits
for(n=1:length(in_bits)+crc_len)
for(m=1:crc_len)
crc_rem(m) = crc_rem(m+1);
endfor
crc_rem(crc_len+1) = tmp_array(n);
if(crc_rem(1) ~= 0)
for(m=1:crc_len+1)
crc_rem(m) = mod(crc_rem(m)+crc_poly(m), 2);
endfor
endif
endfor
for(n=1:crc_len)
crc_bits(n) = crc_rem(n+1);
endfor
endfunction
%
% Copyright 2011 Ben Wojtowicz
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% Function: lte_cfi_channel_decode
% Description: Channel decodes the control format
% indicator channel
% Inputs: cfi_bits - Control format indicator
% channel encoded bits
% Outputs: cfi - Control format indicator
% Spec: 3GPP TS 36.212 section 5.3.4 v10.1.0
% Notes: None
% Rev History: Ben Wojtowicz 12/26/2011 Created
%
function [cfi] = lte_cfi_channel_decode(cfi_bits)
% Calculate the number of bit errors for each CFI
cfi_bits_1 = [0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1];
cfi_bits_2 = [1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0];
cfi_bits_3 = [1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1];
cfi_bits_4 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
bit_errs = zeros(1,4);
for(n=1:32)
if(cfi_bits_1(n) != cfi_bits(n))
bit_errs(1) = bit_errs(1) + 1;
endif
if(cfi_bits_2(n) != cfi_bits(n))
bit_errs(2) = bit_errs(2) + 1;
endif
if(cfi_bits_3(n) != cfi_bits(n))
bit_errs(3) = bit_errs(3) + 1;
endif
if(cfi_bits_4(n) != cfi_bits(n))
bit_errs(4) = bit_errs(4) + 1;
endif
endfor
% Find the CFI with the least bit errors
min_val = 32;
min_idx = 0;
for(n=1:4)
if(bit_errs(n) < min_val)
min_val = bit_errs(n);
min_idx = n;
endif
endfor
% Threshold is set at 25% BER (8 errors)
if(min_val < 8)
cfi = min_idx;
else
cfi = 0;
endif
endfunction
%
% Copyright 2011 Ben Wojtowicz
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% Function: lte_cfi_channel_encode
% Description: Channel encodes the control format
% indicator channel
% Inputs: cfi - Control format indicator
% Outputs: cfi_bits - Control format indicator
% channel encoded bits
% Spec: 3GPP TS 36.212 section 5.3.4 v10.1.0
% Notes: None
% Rev History: Ben Wojtowicz 12/26/2011 Created
%
function [cfi_bits] = lte_cfi_channel_encode(cfi)
% Check cfi
if(cfi == 1)
cfi_bits = [0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1];
elseif(cfi == 2)
cfi_bits = [1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0];
elseif(cfi == 3)
cfi_bits = [1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1];
elseif(cfi == 4)
cfi_bits = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
else
printf("ERROR: Invalid cfi %u\n", cfi);
cfi_bits = 0;
endif
endfunction
This diff is collapsed.
This diff is collapsed.
%
% Copyright 2011 Ben Wojtowicz
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% Function: lte_generate_crs
% Description: Generates LTE cell specific reference signals
% Inputs: N_s - Slot number withing a radio frame
% L - OFDM symbol number within the slot
% N_id_cell - Physical layer cell identity
% Outputs: r - Reference signal for this cell
% Spec: 3GPP TS 36.211 section 6.10.1.1 v10.1.0
% Notes: Currently only handles normal CP
% Rev History: Ben Wojtowicz 10/28/2011 Created
%
function [r] = lte_generate_crs(N_s, L, N_id_cell)
% Validate N_s
if(~(N_s >= 0 && N_s <= 19))
printf("ERROR: Invalid N_s (%u)\n", N_s);
r = 0;
return;
endif
% Validate L
if(~(L >= 0 && L <= 6))
printf("ERROR: Invalid L (%u)\n", L);
r = 0;
return;
endif
% Validate N_id_cell
if(~(N_id_cell >= 0 && N_id_cell <= 503))
printf("ERROR: Invalid N_id_cell (%u)\n", N_id_cell);
r = 0;
return;
endif
% Calculate c_init and sequence length
N_cp = 1;
N_rb_dl_max = 110;
c_init = 1024 * (7 * (N_s+1) + L + 1) * (2 * N_id_cell + 1) + 2*N_id_cell + N_cp;
len = 2*N_rb_dl_max;
% Generate the psuedo random sequence c
c = lte_generate_prs_c(c_init, 2*(len-1)+1+1);
% Construct r
r = zeros(1,len);
for(m=0:len-1)
r(m+1) = (1/sqrt(2))*(1 - 2*c(2*m+1)) + j*(1/sqrt(2))*(1 - 2*c(2*m+1+1));
endfor
endfunction
%
% Copyright 2011 Ben Wojtowicz
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% Function: lte_generate_prs_c
% Description: Generates the psuedo random sequence c
% Inputs: c_init - Initialization value for the
% sequence
% seq_len - Length of the output sequence
% Outputs: c - Psuedo random sequence
% Spec: 3GPP TS 36.211 section 7.2 v10.1.0
% Notes: None
% Rev History: Ben Wojtowicz 10/28/2011 Created
%
function [c] = lte_generate_prs_c(c_init, seq_len)
% Initialize the m-sequences
x1 = zeros(1,1600+seq_len);
x2 = zeros(1,1600+seq_len);
tmp = c_init;
for(n=0:30)
x2(30-n+1) = floor(tmp/(2^(30-n)));
tmp = tmp - (floor(tmp/(2^(30-n)))*2^(30-n));
endfor
x1(0+1) = 1;
% Advance m-sequences
for(n=0:1600+seq_len)
x1(n+31+1) = mod(x1(n+3+1) + x1(n+1), 2);
x2(n+31+1) = mod(x2(n+3+1) + x2(n+2+1) + x2(n+1+1) + x2(n+1), 2);
endfor
% Generate c
for(n=0:seq_len-1)
c(n+1) = mod(x1(n+1600+1) + x2(n+1600+1), 2);
endfor
endfunction
%
% Copyright 2011 Ben Wojtowicz
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% Function: lte_generate_pss
% Description: Generates an LTE primary synchronization signal
% Inputs: N_id_2 - Physical layer identity
% Outputs: pss_d_u - The sequence d(n) used for the primary
% synchronization signal, generated from
% a frequency domain Zadoff-Chu sequence.
% Spec: 3GPP TS 36.211 section 6.11.1.1 v10.1.0
% Notes: None
% Rev History: Ben Wojtowicz 10/28/2011 Created
%
function [pss_d_u] = lte_generate_pss(N_id_2)
% Validate N_id_2 and get the root index
if(N_id_2 == 0)
root_idx = 25;
elseif(N_id_2 == 1)
root_idx = 29;
elseif(N_id_2 == 2)
root_idx = 34;
else
printf("ERROR: Invalid N_id_2 (%u)\n", N_id_2);
pss_d_u = 0;
return;
endif
% Generate PSS for n=0,1,...,30
for(n=0:30)
pss_d_u(n+1) = cos(-pi*root_idx*n*(n+1)/63) + j*sin(-pi*root_idx*n*(n+1)/63);
endfor
% Generate PSS for n=31,32,...,61
for(n=31:61)
pss_d_u(n+1) = cos(-pi*root_idx*(n+1)*(n+2)/63) + j*sin(-pi*root_idx*(n+1)*(n+2)/63);
endfor
endfunction
%
% Copyright 2011 Ben Wojtowicz
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
% Function: lte_generate_sss
% Description: Generates LTE secondary synchronization signals
% Inputs: N_id_1 - Physical layer cell identity group
% N_id_2 - Physical layer identity
% Outputs: sss_d_u_0 - The sequence d(n) used for the secondary
% synchronization signal, an interleaved
% concatenation of two length-31 binary
% sequences for subframe 0
% Outputs: sss_d_u_5 - The sequence d(n) used for the secondary
% synchronization signal, an interleaved
% concatenation of two length-31 binary