www.gusucode.com > LTE_TX_PDSCH > LTE_common_gen_Reference_Signal.m
%% Reference signal generation and mapping. function [RefSym, RefMapping, no_refsym_per_slot, NoData_indices] = LTE_common_gen_Reference_Signal(Nrb, Nsub, nTX, NIDcell, subframe) AtPort_vec = 0:nTX-1; RefSym = zeros(2*Nrb,4,nTX); RefMapping = false(12*Nrb, Nsub, nTX); NoData_indices = 0; NmaxRB = 110; % Number of resource elements occupied by reference symbols per slot switch nTX case 1 no_refsym_per_slot = 4; case 2 no_refsym_per_slot = 8; case 4 no_refsym_per_slot = 12; otherwise error('wrong nTX.') end % Generation NumBit = NmaxRB*4; % Pseudo-random sequence sec:7.2 pn_gen_x1 = commsrc.pn('GenPoly', [1 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 1 0 0 1], ... 'InitialStates', [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 1], ... 'Shift', 0, ... 'NumBitsOut', NumBit); pn_seq1 = generate(pn_gen_x1); for aa = 1:nTX AtPort = AtPort_vec(aa); clear RefSym_temp RefMapping_temp; % initial sequence for x2, TS36.211 V8.2.0 6.10.1.1 switch AtPort case {0,1} SyminSub_i = [1, Nsub/2-2, Nsub/2+1, Nsub-2]; case {2,3} SyminSub_i = [2, Nsub/2+2]; otherwise error('Reference signal for this antenna port is not implemented.'); end c_ini = de2bi(2^13*SyminSub_i+2^9*(subframe-1)+NIDcell,31); pn_seq2 = nan(NumBit,length(SyminSub_i)); pn_seq = nan(NumBit,length(SyminSub_i)); for ii=1:size(c_ini,1) pn_gen_x2 = commsrc.pn('GenPoly', [1 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 1 1 1 1], ... 'InitialStates', c_ini(ii,:), ... 'Shift', 0, ... 'NumBitsOut', NumBit); pn_seq2(:,ii) = generate(pn_gen_x2); pn_seq(:,ii) = mod((pn_seq1+pn_seq2(:,ii)),2); end r = 1/sqrt(2)*(1-2*pn_seq(1:2:end,:))+1i*1/sqrt(2)*(1-2*pn_seq(2:2:end,:)); RefSym_temp = r((1:Nrb*2)+NmaxRB-Nrb,:); RefSym(1:size(RefSym_temp,1),1:size(RefSym_temp,2),aa) = RefSym_temp; % Mapping RefMapping_temp = false(12*Nrb, Nsub); v_shift = mod(NIDcell,6); k = zeros(Nrb*2,length(SyminSub_i)); switch AtPort case 0 k(:,[1 3]) = repmat(6*(0:Nrb*2-1)+1 + v_shift,[2 1])'; k(:,[2 4]) = repmat(6*(0:Nrb*2-1)+1 + mod((3+v_shift),6),[2 1])'; case 1 k(:,[1 3]) = repmat(6*(0:Nrb*2-1)+1 + mod((3+v_shift),6),[2 1])'; k(:,[2 4]) = repmat(6*(0:Nrb*2-1)+1 + v_shift,[2 1])'; case 2 k(:,1) = 6*(0:Nrb*2-1)+1 + v_shift; k(:,2) = 6*(0:Nrb*2-1)+1 + mod((3+v_shift),6); case 3 k(:,1) = 6*(0:Nrb*2-1)+1 + mod((3+v_shift),6); k(:,2) = 6*(0:Nrb*2-1)+1 + v_shift; otherwise error('Mapping for this Antenna Port is not implemented.'); end l = SyminSub_i; for ii=1:length(l) RefMapping_temp(k(:,ii),l(ii))=1; end RefMapping(:,:,aa) = RefMapping_temp; NoData_indices = RefMapping(:,:,aa)|NoData_indices; end