📄 test_ulloopback.m
字号:
ZoneD.NumSym/ZoneD.Type,AsyncPhyCtrl.UlPermBase,SlotUIUC,...
SubgroupCodeOffset,NMLORangCodes);
SlotVectorData = zeros(NAntenna,ZoneD.Type,ZoneConfig.NFFTUsed-1);
% FPULtype = 'MEX_LIB2' ;
%FPULtype = 'Matlab_LIB2' ;
%FPULtype = 'Matlab_LIB3' ;
FPULtype = 'MEX_LIB3' ;
% START FPUL dump of UIUC,ModType and Parameter .
if TC
SlotVecStart = 1;
Param = [NAntenna AsyncPhyCtrl.FrameNr AsyncPhyCtrl.IDCell ZoneConfig.NFFT (ZoneConfig.NFFTUsed-1) ...
ZoneConfig.MaxSubch (ZoneD.NumSym/ZoneD.Type) AsyncPhyCtrl.UlPermBase SlotVecStart];
FPULDir = sprintf('../vector/in/SlotProcess/TC%03d/',TC);%dumy
if ~exist(FPULDir,'dir')
mkdir(FPULDir);
end
mGenBin(Param,[FPULDir,'In_Param.lod'],'uint32','R');
mGenBin(SlotUIUC.',[FPULDir,'IF1RX_SlotUIUC.lod'],'uint8','R');
mGenBin(SlotModType.',[FPULDir,'IF1RX_SlotModType.lod'],'int8','R');
FPULDir = sprintf('../vector/in/TC%03d/',TC);%Original
mGenBin(Param,[FPULDir,'In_Param.lod'],'uint32','R');
mGenBin(SlotUIUC.',[FPULDir,'IF1RX_SlotUIUC.lod'],'uint8','R');
mGenBin(SlotModType.',[FPULDir,'IF1RX_SlotModType.lod'],'int8','R');
end
% FINISH FPUL dump of UIUC,ModType and Parameter .
for vec=1:ZoneD.NumSym/ZoneD.Type,
SymbolIndex = (vec-1)*ZoneConfig.SymPerSlot;
%call uplink FP Rx chain (once per slot vector)
% [DRx_org, DLoc_org, PRx_org, PLoc_org] = ...
% mFPULRxHarness(ZoneConfig,AsyncPhyCtrl,SymbolIndex,...
% OutTPULRx(:,SymbolIndex+(1:3)),PRBS,'y');
SubChannelLUT = SlotSubChannelLUT(vec,:);
SlotVectorData(NAntenna,:,:) = OutTPULRx(:,SymbolIndex+(1:3)).';
switch FPULtype
case 'Matlab_LIB2'
[Data SlotMeasurement]= mSlotProcess_LIB2(SlotVectorData,vec-1,NAntenna,...
ZoneConfig.MaxSubch,ZoneConfig.NFFTUsed-1,SlotUIUC,SlotModType,...
TileLocationLUT,PNCodeLUT,SubChannelLUT,ChanEst,'y',TC);
case 'MEX_LIB2'
[Data SlotMeasurement]= SlotProcess_LIB2(SlotVectorData,vec-1,NAntenna,...
ZoneConfig.MaxSubch,ZoneConfig.NFFTUsed-1,SlotUIUC,SlotModType,...
TileLocationLUT,PNCodeLUT,SubChannelLUT,ChanEst,'y');
case 'Matlab_LIB3'
[Data SlotMeasurement]= mSlotProcess(SlotVectorData,vec-1,NAntenna,...
ZoneConfig.MaxSubch,ZoneConfig.NFFTUsed-1,SlotUIUC,SlotModType,...
TileLocationLUT,PNCodeLUT,SubChannelLUT,2,'n','y',ChanEst,TC);
case 'MEX_LIB3'
[Data SlotMeasurement]= SlotProcess(SlotVectorData,vec-1,NAntenna,...
ZoneConfig.MaxSubch,ZoneConfig.NFFTUsed-1,SlotUIUC,SlotModType,...
TileLocationLUT,PNCodeLUT,SubChannelLUT,2,'n','y',ChanEst,TC);
otherwise
error('Unknown FPULtype')
end
OutFPULRx=[OutFPULRx ; reshape(Data.',1,size(Data,1)*size(Data,2))];
end
clear SlotVectorData Data
rmpath('../../../CM/Utilities/matlab');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Uplink Rx User Domain Processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%switch to corresponding directory to make the relative paths work
cd ../../../../../SP/UP/UL/SPManager/matlab
%path is relative to the folder given above ( SP/UP/DL/SPManager/matlab )
addpath('../../../CM/Utilities/matlab');
%uplink UP Rx processing for full DL zone
BurstBufOut=[];
for b=1:ZoneD.NumBursts
%slot data & pilot demapping
addpath('../../../UL/SPKernel/DerepSlotDemap/matlab');
[slotdemap_out,dum,SlotX,SlotY] = mSlotDemap(OutFPULRx.',ZoneD,BurstD(b));
addpath('../../../UL/SPKernel/DerepSlotDemap/matlab');
% BufOut =mUPULRXchain(slotdeseg_out,BlkSize,BurstD(b),TC,b-1,DemapScale,'2x');
switch BurstD(b).FECType
case 0 %CC
%UL code block segmentation
addpath('../../../../../Manager/UL/ULCodeBlockSeg/matlab');
[slotdeseg_out,BlkSize] = mULCodeBlockSeg(slotdemap_out,BurstD(b));
rmpath('../../../../../Manager/UL/ULCodeBlockSeg/matlab');
%Info that needed to generate stULBurstCtrl,ULCbAllocCtrl,
EachBurstBlkSize(b,1:size(BlkSize,2))=BlkSize;
%BufOut = mUPULRXchain(slotdeseg_out,ZoneD,BurstD(b),BlkSize,b-1,DemapScale,'2x',AsyncPhyCtrl,TC);
BufOut = mUPULRXchain(slotdeseg_out,ZoneD,BurstD(b),BlkSize,b-1,DemapScale,'2x',AsyncPhyCtrl);
case 1 %CTC
[slotdeseg_out,BlkSize] = mULCodeBlockSeg_CTC(slotdemap_out,BurstD(b));
%Info that needed to generate stULBurstCtrl,ULCbAllocCtrl,
EachBurstBlkSize(b,1:size(BlkSize,2))=BlkSize;
BufOut = UPULRXchainCTC(slotdeseg_out,ZoneD,BurstD(b),BlkSize,b-1,DemapScale,'8x',TC);
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 = %02.4f',b,ErrCnt,ErrCnt/BurstD(b).Size/8*100),'%.']);
else
disp(sprintf('OK: Burst %d, Matlab uplink loopback (UP/FP/TP) succeeded.',b));
end
end %for
cd ../../../../../Manager/UL/CM/matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% test vector generation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%path to utilities
addpath('../../../../SP/UP/CM/Utilities/matlab');
if TC
% FN=11;%Frame number and Zone number is concidered as 0 for time being
ZN=0;%Frame number and Zone number is concidered as 0 for time being
AN=0;%Antenna number is concidered as 0 for time being
FN=AsyncPhyCtrl.FrameNr;
% ZN=ZoneD.ZoneNr;
%Generation of UPDLCCMgr and DLCbAllocCtrl
TCstr=sprintf('TC%03d',TC);
if ~exist(['../vector/ref/',TCstr],'dir')
mkdir(['../vector/ref/',TCstr]);
end
if ~exist(['../../ULCodeBlockSeg/vector/ref/',TCstr],'dir')
mkdir(['../../ULCodeBlockSeg/vector/ref/',TCstr]);
end
if ~exist(['../../DataExtraction/vector/in/',TCstr],'dir')
mkdir(['../../DataExtraction/vector/in/',TCstr]);
end
% [ULBurstCtrl_byte,ULCbAllocCtrl_byte,stULSlotAllocCtrl_byte,stUPULVitPreProcMgrCtrl_byte,stUPULVitMgrCtrl_byte] = ...
% mGenStructUPUL(BurstD,ZoneD,EachBurstBlkSize,SlotX,SlotY);
%
% mGenBin(ULBurstCtrl_byte,sprintf('../../ULCodeBlockSeg/vector/ref/%s/IF1jRX_stULBurstCtrl_%02d_%02d.lod',TCstr,FN,ZN),'uint8','R');
% mGenBin(ULCbAllocCtrl_byte,sprintf('../../ULCodeBlockSeg/vector/ref/%s/IF1jRX_stULCbAllocCtrl_%02d_%02d.lod',TCstr,FN,ZN),'uint8','R');
% mGenBin(stULSlotAllocCtrl_byte,sprintf('../../ULCodeBlockSeg/vector/ref/%s/IF1jRX_stULSlotAllocCtrl_%02d_%02d.lod',TCstr,FN,ZN),'uint8','R');
% mGenBin(stUPULVitPreProcMgrCtrl_byte,sprintf('../../ULCodeBlockSeg/vector/ref/%s/IF1jRX_stUPULVitPreProcMgrCtrl_%02d_%02d.lod',TCstr,FN,ZN),'uint8','R');
% mGenBin(stUPULVitMgrCtrl_byte,sprintf('../../ULCodeBlockSeg/vector/ref/%s/IF1jRX_stUPULVitMgrCtrl_%02d_%02d.lod',TCstr,FN,ZN),'uint8','R');
%
% mGenBin(ULCbAllocCtrl_byte,sprintf('../../DataExtraction/vector/in/%s/IF1iRX_stULCbAllocCtrl_%02d_%02d.lod',TCstr,FN,ZN),'uint8','R');
% %generate test vector directory
% TCstr=sprintf('TC%02d',TC);
% if ~exist(['../vector/ref/',TCstr],'dir')
% mkdir(['../vector/ref/',TCstr]);
% end
% if ~exist(['../vector/in/',TCstr],'dir')
% mkdir(['../vector/in/',TCstr]);
% end
%
% fn=11;%frame number and this should be changed with the support of multiple fram
% zn=0;%zone number and this should be changed with the support of multiple zone
% an=0;%antenna number and this should be changed with the support of multiple antenna
%all OFDMA symbols (IF3Rx)
if ~exist(['../../../../SP/FP/UL/SPManager/vector/in/',TCstr],'dir')
mkdir(['../../../../SP/FP/UL/SPManager/vector/in/',TCstr]);
end
for sym=1:ZoneD.NumSym,
mGenBin(double(OutTPULRx(:,sym)),...
sprintf('../vector/ref/TC%03d/IF3RX_%02d_%02d_%02d_%02d.lod',TC,FN,ZN,sym-1,AN),...
'int16','1R1I');
mGenBin(double(OutTPULRx(:,sym)),...
sprintf('../vector/in/TC%03d/IF3RX_%02d_%02d_%02d_%02d.lod',TC,FN,ZN,sym-1,AN),...
'int16','1R1I');
% START FPUL dump
mGenBin(double(OutTPULRx(:,sym)),...
sprintf('../../../../SP/FP/UL/SPManager/vector/in/SlotProcess/TC%03d/IF3RX_%d_%d_%d_%d.lod',...
TC,FN,ZN,sym-1,AN),'int16','1R1I');
% FINISH FPUL dump
end
%all slot vectors of the zone
[m,slotvecs]=size(OutFPULRx.');
for sv=1:slotvecs,
% mGenBin(double(OutFPULRx(sv,:)),... %dump only fixp test vectors
% sprintf('../vector/ref/%s/IF2RX_%02d_%02d_%02d_%02d.lod',...
% TCstr,FN,ZN,sv-1,AN),'int16','R');
%
% if ~exist(['../../../../SP/UP/UL/SPManager/vector/in/',TCstr],'dir')
% mkdir(['../../../../SP/UP/UL/SPManager/vector/in/',TCstr]);
% end
% % mGenBin(double(OutFPULRx(sv,:)),... %dump only fixp test vectors
% % sprintf('../../../../SP/UP/UL/SPManager/vector/in/%s/IF2RX_%02d_%02d_%02d_%02d.lod',TCstr,FN,ZN,sv-1,AN),...
% % 'int16','R');
% mGenBin(double(OutFPULRx(sv,:)),... %dump only fixp test vectors
% sprintf('../../../../SP/UP/UL/SPManager/vector/in/%s/IF2RX_%02d_%02d_%02d_%02d.lod',TCstr,FN,ZN,sv-1,AN),...
% 'int8','R');
% START FPUL dump
OutFPULSlotVec2DRx = zeros(48*6,ZoneConfig.MaxSubch);
OutFPULSlotVec2DRx(1:48*SlotModType(1),:) = reshape(OutFPULRx(sv,:),48*SlotModType(1),ZoneConfig.MaxSubch);
OutFPULSlotVecRx = double(reshape(OutFPULSlotVec2DRx,1,ZoneConfig.MaxSubch*48*6));
if ~exist(sprintf('../../../../SP/FP/UL/SPManager/vector/ref/SlotProcess/%s/',TCstr),'dir')
mkdir(sprintf('../../../../SP/FP/UL/SPManager/vector/ref/SlotProcess/%s/',TCstr));
end
mGenBin(OutFPULSlotVecRx,... %dump only fixp test vectors
sprintf('../../../../SP/FP/UL/SPManager/vector/ref/SlotProcess/%s/IF2RX_%d_%d_%d.lod',...
TCstr,FN,ZN,sv-1),'int8','R');
% FINISH FPUL dump
mGenBin(OutFPULSlotVecRx,... %dump only fixp test vectors
sprintf('../vector/ref/%s/IF2RX_%02d_%02d_%02d_%02d.lod',...
TCstr,FN,ZN,sv-1,AN),'int8','R');
% if ~exist(['../../../../SP/UP/UL/SPManager/vector/in/',TCstr],'dir')
% mkdir(['../../../../SP/UP/UL/SPManager/vector/in/',TCstr]);
% end
% mGenBin(OutFPULSlotVecRx,... %dump only fixp test vectors
% sprintf('../../../../SP/UP/UL/SPManager/vector/in/%s/IF2RX_%02d_%02d_%02d_%02d.lod',TCstr,FN,ZN,sv-1,AN),...
% 'int8','R');
end
%
% %all bursts in the zone
% for b=1:ZoneD.NumBursts,
% mGenBin(BurstBufOut(b).Data,...
% sprintf('../vector/ref/TC%02d/IF1RX_%02d.lod',TC,b-1),...
% 'uint8','R');
% end
for b=1:ZoneD.NumBursts,
mGenBin(uint8(BurstBufOut(b).Data(1:size(BurstBufOut(b).Data(:,b),1),b)),...
sprintf('../vector/ref/%s/IF1RX_%02d_%02d_%02d.lod',TCstr,FN,ZN,b-1),...
'uint8','R');
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Results
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure
subplot(2,2,1)
plot(OutFPULTx,'x')
axis([-1e4 1e4 -1e4 1e4]);
title('Transmitter - Constellation before TP');
grid
subplot(2,2,3)
plot(real(OutTPULTx),'b--');
hold on
plot(imag(OutTPULTx),'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(OutTPULTx,[],4096));
%psd = 10*log10(periodogram(OutTPULTx((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(OutTPULRx,'x')
mag=100*(ceil(max(max(abs(real(OutTPULRx))))/100)+1);
axis([-mag mag -mag mag]);
clear mag
title('Receiver - Constellation after TP');
grid
%Map figure to foreground
figure(ULMapStruct.H);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -