📄 test_dlloopback.m
字号:
MappedSymbols=reshape(MappedSymbols,[],(size(OutUPDL,2)));
%FUSC
elseif (ZoneConfig.ZoneType==1)
MappedSymbols=OutUPDL;
end
if TC
% xlswrite(sprintf('../../SPKernel/Rand/vector/in/%s/ParameterFile.csv',TCstr),XSLArguments);
% % xlswrite(sprintf('../../SPKernel/ConvEnc/vector/in/%s/ParameterFile.csv',TCstr),test);
[m,slotvecs]=size(MappedSymbols);
if ~exist(['../../../../FP/DL/SPManager/vector/ref/',TCstr],'dir')
mkdir(['../../../../FP/DL/SPManager/vector/ref/',TCstr]);
end
if ~exist(['../../../../FP/DL/SPKernel/SlotMapper/vector/ref/',TCstr],'dir')
mkdir(['../../../../FP/DL/SPKernel/SlotMapper/vector/ref/',TCstr]);
end
if ~exist(['../../../../FP/DL/SPKernel/StcEncoder/vector/in/',TCstr],'dir')
mkdir(['../../../../FP/DL/SPKernel/StcEncoder/vector/in/',TCstr]);
end
%Temporary (untill stc is ready)
if ~exist(['../../../../FP/DL/SPKernel/SbcPermutation/vector/in/',TCstr],'dir')
mkdir(['../../../../FP/DL/SPKernel/SbcPermutation/vector/in/',TCstr]);
end
%Temporary (untill stc is ready)
if ~exist(['../../../../FP/DL/SPKernel/StcEncoder/vector/ref/',TCstr],'dir')
mkdir(['../../../../FP/DL/SPKernel/StcEncoder/vector/ref/',TCstr]);
end
%%
for sv=1:slotvecs,
mGenBin(double(MappedSymbols(:,sv)),...
sprintf('../../../../FP/DL/SPManager/vector/ref/%s/IF2aTX_%02d_%02d_%02d_%02d.lod',TCstr,FN,ZN,sv-1,AN),...
'int16','1R1I');
mGenBin(double(MappedSymbols(:,sv)),...
sprintf('../../../../FP/DL/SPKernel/SlotMapper/vector/ref/%s/IF2aTX_%02d_%02d_%02d_%02d.lod',TCstr,FN,ZN,sv-1,AN),...
'int16','1R1I');
mGenBin(double(MappedSymbols(:,sv)),...
sprintf('../../../../FP/DL/SPKernel/StcEncoder/vector/in/%s/IF2aTX_%02d_%02d_%02d_%02d.lod',TCstr,FN,ZN,sv-1,AN),...
'int16','1R1I');
end
end
rmpath('../../../CM/Utilities/matlab');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Downlink Tx Frequency Domain Processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%switch to corresponding directory to make the relative paths work
cd ../../../../../SP/FP/DL/SPManager/matlab
%path is relative to the folder given above ( SP/FP/DL/SPManager/matlab )
addpath('../../../../CM/matlab');
addpath('../../../DL/SPKernel/PreambleGen/matlab/');
%OFDMA symbol Matrix (one column per symbol, NFFT complex elements each)
OutFPDLTx=[];
[DlCarrierMap,PRBS] = mFPDLTxZoneStart(ZoneConfig, AsyncPhyCtrl,TC);
%downlink FP Tx processing for full DL zone
if (ZoneD.Type==1 && ZoneConfig.STC==1)%STC FUSC (calls two symbols in once)
for ts=0:ZoneD.NumSym/2-1,
SymbolIndex = ts*2;
%call downlink FP Tx chain (two symbols in once)
OutFPDLTx =[ OutFPDLTx, ...
FPDLTxHarness(ZoneConfig,AsyncPhyCtrl,DlCarrierMap,PRBS,MappedSymbols(:,SymbolIndex+1:SymbolIndex+2),SymbolIndex,TC)...
];
end
else%PUSC and FUSC without STC
ZoneConfig.STC=0 ;
for ts=0:ZoneD.NumSym/ZoneD.Type-1,
SymbolIndex = ts*ZoneD.Type;
%call downlink FP Tx chain (once per slot vector)
OutFPDLTx =[ OutFPDLTx, ...
FPDLTxHarness(ZoneConfig,AsyncPhyCtrl,DlCarrierMap,PRBS,MappedSymbols(:,ts+1),SymbolIndex,TC)...
];
end
end
rmpath('../../../../CM/matlab');
rmpath('../../../DL/SPKernel/PreambleGen/matlab/');
if ZoneConfig.STC==1
disp('Terminated after FPDL as the other parts does not support STC');
break;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Downlink Tx Time Domain Processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%switch to corresponding directory to make the relative paths work
cd ../../../../../SP/TP/DL/SPManager/matlab
%call TP DL Tx chain
OutTPDLTx = DLTx_Time_Domain(SubframeD,ZoneConfig,TPparam,OutFPDLTx,TC); %TC=0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% AWGN channel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if SNR==Inf
%noise off
AntennaInput = OutTPDLTx;
else
%noise on
dBW=10*log10(mean(OutTPDLTx.*conj(OutTPDLTx)));
AntennaInput = awgn(OutTPDLTx,SNR,dBW);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Downlink Rx Time Domain Processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%switch to corresponding directory to make the relative paths work
cd ../../../UL/SPManager/matlab
addpath('../../../UL/SPKernel/RemoveCP/matlab');
addpath('../../../UL/SPKernel/GuardRemoveAndWrap/matlab');
%call TP DL Rx chain
OutTPDLRx = Rx_Time_Domain(ZoneConfig,TPparam,AntennaInput); %TC=0
rmpath('../../../UL/SPKernel/RemoveCP/matlab');
rmpath('../../../UL/SPKernel/GuardRemoveAndWrap/matlab');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Downlink Rx Frequency Domain Processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%switch to corresponding directory to make the relative paths work
cd ../../../../../SP/FP/DL/SPManager/matlab
%path is relative to the folder given above ( SP/FP/DL/SPManager/matlab )
%addpath('../../../../CM/matlab');
%OFDMA symbol Matrix (one column per symbol, NFFT complex elements each)
OutFPDLRx=[];
%downlink FP Rx processing for full DL zone
for ts=0:ZoneD.NumSym/ZoneD.Type-1,
SymbolIndex = ts*ZoneD.Type;
%call downlink FP Rx chain (once per slot vector, ignore preamble)
OutFPDLRx =[ OutFPDLRx, ...
mFPDLRxHarness(ZoneConfig,DlCarrierMap,PRBS,OutTPDLRx(:,SymbolIndex+1+(1:ZoneD.Type)),SymbolIndex)...
];
end
%addpath('../../../../CM/matlab');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Downlink Rx User Domain Processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%switch to corresponding directory to make the relative paths work
cd ../../../../../SP/UP/DL/SPManager/matlab
%path is relative to the folder given above ( SP/UP/DL/SPManager/matlab )
%addpath('../../../CM/Utilities/matlab');
%downlink UP Rx processing for full DL zone
BurstBufOut=[];
for b=1:ZoneD.NumBursts,
%set distance manually for the time being
QPSKdist=516;
switch BurstD(b).ModMode
case 2 %QPSK
BurstD(b).Distance = QPSKdist;
case 4 %16QAM
BurstD(b).Distance = QPSKdist*1702/3805;
case 6 %64QAM
BurstD(b).Distance = QPSKdist*830/3805;
otherwise
error('Error: Modulation Mode not supoorted.');
end
%decode burst
if BurstD(b).FECType == 0 % CC mode
BufOut = mUPDLRXchain(OutFPDLRx,ZoneD,BurstD(b));
elseif BurstD(b).FECType == 1 % CTC mode
BufOut = mUPDLRXchainCTC(OutFPDLRx,ZoneD,BurstD(b));
else
error('BurstD(b).Type should be either 0 or 1.')
end
BurstBufOut = [BurstBufOut , struct('Data', BufOut)];
%verify result (ignore padded bytes)
ErrCnt=biterr(double(BurstBufOut(b).Data(1:BurstD(b).Size)),double(BurstBufIn(b).Data),8);
if ErrCnt
disp([sprintf('Error: Burst %d failed. Bit errors = %d = %2.4f',b,ErrCnt,ErrCnt/BurstD(b).Size/8*100),'%.']);
else
disp(sprintf('OK: Burst %d, Matlab downlink loopback (UP/FP/TP) succeeded.',b));
end
end %for
cd ../../../../../Manager/DL/CM/matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% test vector generation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%path to utilities
%addpath('../../../../SP/UP/CM/Utilities/matlab');
if TC
%generate test vector directory
TCstr=sprintf('TC%03d',TC);
if ~exist(['../vector/ref/',TCstr],'dir')
mkdir(['../vector/ref/',TCstr]);
end
if ~exist(['../vector/in/',TCstr],'dir')
mkdir(['../vector/in/',TCstr]);
end
%IF1TX : done before
%IF2TX
%all slot vectors of the zone
[m,slotvecs]=size(OutUPDL);
if ~exist(['../vector/ref/',TCstr],'dir')
mkdir(['../vector/ref/',TCstr]);
end
if ~exist(['../../../../SP/UP/DL/SPManager/vector/ref/',TCstr],'dir')
mkdir(['../../../../SP/UP/DL/SPManager/vector/ref/',TCstr]);
end
if ~exist(['../../DataWriteback/vector/ref/',TCstr],'dir')
mkdir(['../../DataWriteback/vector/ref/',TCstr]);
end
if ~exist(['../../../../SP/FP/DL/SPKernel/SlotMapper/vector/in/',TCstr],'dir')
mkdir(['../../../../SP/FP/DL/SPKernel/SlotMapper/vector/in/',TCstr]);
end
for sv=1:slotvecs,
%at SBX\Manager\DL\CM\vector\ref
mGenBin(double(OutUPDL(:,sv)),... %dump only fixp test vectors
sprintf('../vector/ref/%s/IF2TX_%02d_%02d_%02d_%02d.lod',TCstr,FN,ZN,sv-1,AN),...
'int16','1R1I');
%at SBX\Manager\DL\DataWriteback\vector\ref
mGenBin(double(OutUPDL(:,sv)),... %dump only fixp test vectors
sprintf('../../DataWriteback/vector/ref/%s/IF2TX_%02d_%02d_%02d_%02d.lod',TCstr,FN,ZN,sv-1,AN),...
'int16','1R1I');
%at SBX/SP/UP/DL/SPManager/vector/ref
mGenBin(double(OutUPDL(:,sv)),... %dump only fixp test vectors
sprintf('../../../../SP/UP/DL/SPManager/vector/ref/%s/IF2TX_%02d_%02d_%02d_%02d.lod',TCstr,FN,ZN,sv-1,AN),...
'int16','1R1I');
%at SBX\SP\FP\DL\SPKernel\SlotMapper\vector\in
mGenBin(double(OutUPDL(:,sv)),... %dump only fixp test vectors
sprintf('../../../../SP/FP/DL/SPKernel/SlotMapper/vector/in/%s/IF2TX_%02d_%02d_%02d_%02d.lod',TCstr,FN,ZN,sv-1,AN),...
'int16','1R1I');
end
%IF3TX
%preamble
% mGenBin(double(OutFPDLTx(:,1)),...
% sprintf('../vector/ref/TC%03d/IF3TX_preamble.lod',TC),...
% 'int16','1R1I');
if ~exist(['../../../../SP/FP/DL/SPManager/vector/ref/',TCstr],'dir')
mkdir(['../../../../SP/FP/DL/SPManager/vector/ref/',TCstr]);
end
%all OFDMA symbols
%test vector IF3TX is saved by slot vector basis. (one OFDMA symbol follwoing by the other)
[m,n]=size(OutFPDLTx);
temp=reshape(OutFPDLTx,m*ZoneConfig.ZoneType,n/ZoneConfig.ZoneType);
for sym=1:ZoneD.NumSym/ZoneConfig.ZoneType,
%at SBX\Manager\DL\CM\vector\ref
mGenBin(double(temp(:,sym)),...
sprintf('../vector/ref/%s/IF3TX_%02d_%02d_%02d_%02d.lod',TCstr,FN,ZN,sym-1,AN),...
'int16','1R1I');
%at SBX/SP/FP/DL/SPManager/vector/ref
mGenBin(double(temp(:,sym)),...
sprintf('../../../../SP/FP/DL/SPManager/vector/ref/%s/IF3TX_%02d_%02d_%02d_%02d.lod',TCstr,FN,ZN,sym-1,AN),...
'int16','1R1I');
end
%IF4TX done inside DLTX_Time_Domain
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Results
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure
subplot(2,2,1)
plot(OutFPDLTx,'x')
axis([-2e4 2e4 -2e4 2e4]);
title('Transmitter - Constellation before TP');
grid
subplot(2,2,3)
plot(real(OutTPDLTx),'b--');
hold on
plot(imag(OutTPDLTx),'r-.');
title('Time Domain - Re/Im amplitude');
grid
subplot(2,2,4)
freq = (0:4095)'*8*TPparam.Fofdm/4096; %freq axis
%spectral mask
xmask=[-10 -7.375 -4.875 -2.725 -2.375 2.375 2.725 4.875 7.375 10 ]*1e6;
ymask=[-50 -50 -32 -25 0 0 -25 -32 -50 -50 ];
psd = 10*log10(periodogram(OutTPDLTx,[],4096));
%psd = 10*log10(periodogram(OutTPDLTx((29+64)*8+3+4608*1+(1:512*8))));
plot(freq,psd-max(psd));
hold on
plot(xmask+TPparam.Fofdm*2,ymask,'r-');
axis([0,freq(4096), -80,5])
title('Time Domain - Power Spectral Density');
clear xmask ymask psd freq
grid
subplot(2,2,2)
plot(OutTPDLRx,'x')
mag=100*(ceil(max(max(abs(real(OutTPDLRx))))/100)+1);
axis([-mag mag -mag mag]);
clear mag
title('Receiver - Constellation after TP');
grid
%Map figure to foreground
figure(DLMapStruct.H);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -