⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_ulloopback.m

📁 OFDMA 物理层开发的matlab 源码.飞思卡尔提供.对物理层开发的工程师有帮助!
💻 M
📖 第 1 页 / 共 2 页
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Property of Freescale
%  Freescale Confidential Proprietary
%  Freescale Copyright (C) 2005 All rights reserved
%  ----------------------------------------------------------------------------
%  $RCSfile: test_ULloopback.m.rca $
%  $Revision: 1.35 $
%  $Date: Fri Feb  2 14:28:58 2007 $
%  Target: Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear BurstBufIn

% set random seed, to generate all the time the same vectors
% (debugging purpose)
randSeed = 0 ;
rand('state',randSeed)
randn('state',randSeed) %used in awgn

%check path
cd '../../../../SP/CM/matlab'
%setPaths4test_BER('on'); %disable this for speed considerations
cd '../../../Manager/UL/CM/matlab'

%select test case
% TC=input('Which test case number do you want to run? ');
TC = 502 ;
if (~isnumeric(TC) | (TC<0))
    disp('Error: Not a valid test case number!')
    return;
end
TCstr=sprintf('../vector/in/TC%03d/ULparam',TC);
if exist([TCstr,'.m'],'file');
    run(TCstr);
else
    disp(sprintf('Error: Test case parameter file %s.m is not available.',TCstr));
    return;
end

%Ether payload is extracted from MAC side or param file
% MacTV=input('Do want to import data from MAC test vectors [y/n]? ','s');
MacTV='y';

BurstStart=zeros(size(BurstD,2),1);
%Extracting payload from MAC
if MacTV =='y'
    disp(sprintf('Importing data from TC%03d/Burst.lod ...',TC));
    TCstr=sprintf('../vector/in/TC%03d/Burst.lod',TC);
    if exist(TCstr,'file');
        addpath('../../../../SP/UP/CM/Utilities/matlab');
        In=mGetBin(TCstr,'uint8','R');
        rmpath('../../../../SP/UP/CM/Utilities/matlab');

        %generate stimuli
        BufLength=0;
        BurstBufIn=[];
        for b=1:ZoneD.NumBursts
            BurstBufIn = [BurstBufIn , struct('Data',In(BufLength+1:BufLength+BurstD(b).Size,1))];
            BurstStart(b)=BufLength;
            BufLength=BufLength+(ceil(BurstD(b).Size/8)*8);
        end
    else
        disp(sprintf('Error: Test case data file %s is not available.',TCstr));
        return;
    end
else
    %     %generate stimuli
    %     BurstBufIn=[];
    %     for b=1:ZoneD.NumBursts,
    %         BurstBufIn = [BurstBufIn , struct('Data',uint8(mod(1:BurstD(b).Size,256))')];
    %     end
end


%GenTV=input('Do want to generate test vectors [y/n]? ','s');
GenTV='y';

disp(sprintf('Running test case number %03d ...',TC));
if GenTV~='y'
    TC=0;  %switch off test case generation
end

%Generate MAC-PHY control inteface (IF1TXDLCtrl and IF1TXDLSysD)
if TC
    %at SBX\Manager\DL\CM\vector\ref
    if ~exist(sprintf('../../ULCodeBlockSeg/vector/in/TC%03d',TC),'dir')
        mkdir(sprintf('../../ULCodeBlockSeg/vector/in/TC%03d',TC));
    end

    addpath('../../../CM/Utilities/matlab');
    addpath('../../../../SP/UP/CM/Utilities/matlab');
    RandFlag=[0 1 2].';
    ModulationMode=0;
    ULDL=1;%Indicates UL (0:DL)
    [IF1TXDLSysD IF1TXDLCtrl]=mGenStructMacPhy(TPparam,SubframeD,AsyncPhyCtrl,ZoneD,BurstD,BurstStart,ULDL);
    mGenBin(IF1TXDLSysD,sprintf('../../ULCodeBlockSeg/vector/in/TC%03d/IF1TXULSysD.lod',TC),'uint8','R');
    mGenBin(IF1TXDLCtrl,sprintf('../../ULCodeBlockSeg/vector/in/TC%03d/IF1TXULCtrl.lod',TC),'uint8','R');
    rmpath('../../../../SP/UP/CM/Utilities/matlab');
    rmpath('../../../CM/Utilities/matlab');
end



clear TCstr GenTV


% ChanMod=input('With ITU channel model?','s');
% ChanEst=input('With channel estimation and equalization [y/n]? ','s');
ChanMod='n';
ChanEst='y';
% DemapScale=input('With scaling to 8 bit for Viterbi decoder [y/n]? ','s');
DemapScale='y';


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Uplink Tx 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/UL/SPManager/matlab )
addpath('../../../CM/Utilities/matlab');

%allocate output/zone buffer (slot vectors)
OutUPULTx = zeros(ZoneD.NumSubch*48,ZoneD.NumSym/ZoneD.Type,'int16');

%create UL-MAP figure (empty)
[ULMapStruct]=CreateZoneMap(ZoneD,'UL-PUSC zone (NFFT=512)');

%generate stimuli
if ~exist('BurstBufIn','var');
    BurstBufIn=[];
    for b=1:ZoneD.NumBursts
        BurstBufIn = [BurstBufIn , struct('Data',uint8(mod(1:BurstD(b).Size,256))')];
    end
end

%uplink UP Tx processing for full UL zone
for b=1:ZoneD.NumBursts,
    %place burst into UL-MAP
    BurstH(b)=AddULburst(ULMapStruct,ZoneD,BurstD(b),b,BurstD(b).Name);
    %call floating point uplink UP Tx chain
    switch  BurstD(b).FECType  
        case 0 %CC
            OutUPULTx = mUPULTXchain(BurstBufIn(b).Data,OutUPULTx,ZoneD,BurstD(b));
        case 1 %CTC
            OutUPULTx = mUPULTXchainCTC(BurstBufIn(b).Data,OutUPULTx,ZoneD,BurstD(b));
                
    end
end

rmpath('../../../CM/Utilities/matlab');


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Uplink Tx Frequency Domain Processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%switch to corresponding directory to make the relative paths work
cd ../../../../../SP/FP/UL/SPManager/matlab

%OFDMA symbol Matrix (one column per symbol, NFFT complex elements each)
OutFPULTx=[];

%generate constant LUTs used within zone
PRBS = mFPULRxZoneInit(ZoneConfig, AsyncPhyCtrl);

%process all slot vectors in zone (two OFDMA symbols per time slot)
OutFPULTx = [];
for vec=1:ZoneD.NumSym/ZoneD.Type,
    SymbolIndex = (vec-1)*ZoneConfig.SymPerSlot;
    %call uplink FP Tx chain (once per slot vector)
    OutFPULTx = [OutFPULTx ,...
        mFPULTxHarness(ZoneConfig,AsyncPhyCtrl,SymbolIndex,...
        OutUPULTx(:,vec),PRBS,'y')...
        ];
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Uplink Tx Time Domain Processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%switch to corresponding directory to make the relative paths work
cd ../../../../../SP/TP/UL/SPManager/matlab

%add one empty OFDM symbol for filter delay
[m,n]=size(OutFPULTx);
OutFPULTx =[ OutFPULTx, zeros(m,1)];
clear m n

%call TP UL Tx chain
%(since function is called only once history handling is not required)
if TC
    %fixed point model is called with test vector generation
    OutTPULTx = ULTx_Time_Domain(ZoneConfig,TPparam,OutFPULTx,TC); 
else
    OutTPULTx = mULTx_Time_Domain(ZoneConfig,TPparam,OutFPULTx); 
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ITU channel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cd ../../../UL/SPKernel/ChannelModel/matlab
if ChanMod=='y'
    %please check the following parameters
    AntennaInput = itu_channel(OutTPULTx,2.5e+9,8*TPparam.Fofdm,'vehicularB');
    %AntennaInput = itu_channel(OutTPULTx,2.5e+9,TPparam.Fofdm,'SUI-1');
else
    AntennaInput=OutTPULTx;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% AWGN channel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if SNR==Inf
    %noise off
    %    AntennaInput = OutTPULTx;
else
    %noise on
    dBW=10*log10(mean(AntennaInput.*conj(AntennaInput)));
    AntennaInput = awgn(AntennaInput,SNR,dBW);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Uplink Rx Time Domain Processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%switch to corresponding directory to make the relative paths work
cd ../../../../UL/SPManager/matlab

%call TP UL Rx chain
%(since function is called only once history handling is not required)
if TC
    %fixed point model is called with test vector generation
    OutTPULRx = Rx_Time_Domain(ZoneConfig,TPparam,AntennaInput,AsyncPhyCtrl,ZoneD,TC);
else
    %floating point model is called with test vector generation
    OutTPULRx = mRx_Time_Domain(ZoneConfig,TPparam,AntennaInput); 
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Uplink Rx Frequency Domain Processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%switch to corresponding directory to make the relative paths work
cd ../../../../../SP/FP/UL/SPManager/matlab

%path is relative to the folder given above ( SP/FP/DL/SPManager/matlab )
addpath('../../../CM/Utilities/matlab');

%OFDMA symbol Matrix (one column per symbol, NFFT complex elements each)
OutFPULRx=[];
% HACKS %%%%%%
NAntenna =1;

% SlotUIUC generation
% SlotUIUC = ones(ZoneD.NumSym/ZoneD.Type,ZoneConfig.MaxSubch);
% HACK for TC 13
% SlotUIUC= [[255*ones(1,6) ones(1,5) 255*ones(1,6)]' ...
%     [255*ones(1,6) ones(1,4) 255*ones(1,7)]' ...
%     [255*ones(1,6) ones(1,4) 255*ones(1,7)]' ...
%     [255*ones(1,5) ones(1,5) 255*ones(1,7)]' ...
%     [255*ones(1,5) ones(1,5) 255*ones(1,7)]' ...
%     [255*ones(1,5) ones(1,5) 255*ones(1,7)]' ...
%     [255*ones(1,5) ones(1,5) 255*ones(1,7)]']';

% TC500 UIUC
% SlotUIUC = [ones(1,6) 255*ones(1,11);ones(1,6) 255*ones(1,11);ones(1,5) 255*ones(1,12)];
% SlotModType= 2*ones(ZoneD.NumSym/ZoneD.Type,ZoneConfig.MaxSubch);

%Generation of SlotUIUC and SlotModType
SlotUIUC=ones(ZoneD.NumSym/ZoneD.Type,ZoneConfig.MaxSubch)*255;
SlotModType= zeros(ZoneD.NumSym/ZoneD.Type,ZoneConfig.MaxSubch);
for b=1:ZoneD.NumBursts,
    NumSubchVecters=ceil((BurstD(b).SymOff+BurstD(b).Duration*ZoneD.Type)/ZoneD.NumSym);

    for vec=1:NumSubchVecters
        if vec==1
            SlotUIUC(BurstD(b).SymOff/ZoneD.Type+1:ZoneD.NumSym/ZoneD.Type,BurstD(b).SubchOff+vec)=1;
            SlotModType(BurstD(b).SymOff/ZoneD.Type+1:ZoneD.NumSym/ZoneD.Type,BurstD(b).SubchOff+vec)=BurstD(b).ModMode;
            FirstVecSlots=size(BurstD(b).SymOff/ZoneD.Type+1:ZoneD.NumSym/ZoneD.Type,2);
        elseif vec==NumSubchVecters
            rem=BurstD(b).Duration-FirstVecSlots-(ZoneD.NumSym/ZoneD.Type)*(NumSubchVecters-2);
            SlotUIUC(1:rem,BurstD(b).SubchOff+vec)=1;
            SlotModType(1:rem,BurstD(b).SubchOff+vec)=BurstD(b).ModMode;
        else
            SlotUIUC(1:(ZoneD.NumSym/ZoneD.Type),BurstD(b).SubchOff+vec)=1;
            SlotModType(1:(ZoneD.NumSym/ZoneD.Type),BurstD(b).SubchOff+vec)=BurstD(b).ModMode;
        end
    end
end

SubgroupCodeOffset = 1;
NMLORangCodes= 1;

%%%%%%%%%%%%% End HACKs
%  Neeed to call per zone in the future %
[PNCodeLUT,TileLocationLUT,PilotPhyLoc,DataPhyLoc,RangingCode,SlotSubChannelLUT]= ...
    mZoneStart(AsyncPhyCtrl.IDCell,AsyncPhyCtrl.FrameNr,...
    ZoneConfig.NFFT,ZoneConfig.NFFTUsed-1,ZoneConfig.MaxSubch,...

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -