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

📄 slotprocess.m

📁 OFDMA 物理层开发的matlab 源码.飞思卡尔提供.对物理层开发的工程师有帮助!
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Property of Freescale
%  Freescale Confidential Proprietary
%  Freescale Copyright (C) 2005 All rights reserved
%  ----------------------------------------------------------------------------
%  $RCSfile: SlotProcess.m.rca $
%  $Revision: 1.7 $
%  $Date: Wed Jan 24 16:15:31 2007 $
%  Target: Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
% Slot Process of IEEE 802.16-2005 (WiMAX, OFDMA only)
%
%
% [Data SlotMeasurement] = mSlotProcess(SymbolSlot,SlotVecIndex,NAntenna,...
%     NSubCh,NFFTUsed,SlotUIUC,SlotModType,TileLocationLUT,...
%     PNCodeLUT,SubChannelLUT,DemodMapGap,DataRotationEnable,DemapScale,CE,TC)
%
%---------------------
%| INPUT parameters: |
%---------------------
%   SymbolSlot          :   data to process
%   SlotVecIndex        :   index
%   NAntenna            :   number of antennas (only NAntenna=1 has been tested )
%   NSubCh              :   number of SubChannels
%   NFFTUsed            :   FFT size
%   SlotUIUC            :   SlotUIUC
%   SlotModType         :   Slot Modulation Type
%   TileLocationLUT     :   TileLocationLUT
%   PNCodeLUT           :   PNCodeLUT
%   SubChannelLUT       :   SubChannelLUT
%   DemodMapGap         :   (optional) DemodMapGap, default is max(SlotModType)
%   DataRotationEnable  :   (optional) DataRotation, default is 1
%   DemapScale          :   (optional) Scaling at the end of DemodMapperMinDist
%                               - for full floating point BER simu, set it to 'n'
%                               - for fixed points simu, set it to 'y'
%                               - for vectors generation, set it to 'y'
%                               Default value is 'y'.
%   CE                  :   (optional) Channel Estimation, default is 'y'
%                               Set it to 'n' only for AWGN BER simulations
%   TC                  :   (optional) TestCase (test vectors generation), default is 0
%                               Set it to 1 if you want to generate test vectors
%
%---------------------
%| OUPUT parameters: |
%---------------------
%   Data                :   output data
%   SlotMeasurement     :   Slot Measurements : [RSSI;CINR;FreqOff;TimeOff;BitShift;Pad];
%                           RSSI     : Burst based Received Signal Strength Indicator
%                           CINR     : Carrier to Interference and Noise Ratio based on pilot carriers.
%                           FreqOff  : Burst based Frequency offset measurement based on pilot carriers
%                           TimeOff  : Burst based Time offset measurement based on pilot carriers
%                           BitShift : Bitshift for DemodMapperMinDist (scaling to int8)
%                           Pad      : tbd
%
% Matlab 7 Release 14 SP2
%
%-------------------
%| Change history  |
%-------------------
%
% v1.19     :   - merged mSlotProcess version 1.18 and mSlotProcess_LIB3_v2
%               - added Test Vectors generation possibility
%               - updated header/help of this file
%


%-- Matlab files used by this file
% mSlotExtraction
% mCEIntraTile
% mEqZF
% mSlotMeasurement
% mMRC
% mMRC2D
% mDemodMapperMinDist
%-- End of list


function [Data SlotMeasurement] = SlotProcess(SymbolSlot,SlotVecIndex,NAntenna,...
    NSubCh,NFFTUsed,SlotUIUC,SlotModType,TileLocationLUT,...
    PNCodeLUT,SubChannelLUT,DemodMapGap,DataRotationEnable,DemapScale,CE,TC)

%-- General Settings
FPULNTILE = 6;
FPULNDATACARRIER = 48;
FPULNPILOTCARRIER = 24;
% by default TC is off, no test vectors generation
if (exist('TC','var') == 0)
    TC = 0;
end
% by default CE is on
if (exist('CE','var') == 0)
    CE = 'y';
end
% by default scaling is performed in mDemodMapperMinDist, output is int8.
% if DemapScale = 'n', output is double
if (exist('DemapScale','var') == 0)
    DemapScale = 'y';
end
% by default apply rotation
if (exist('DataRotationEnable','var') == 0)
    DataRotationEnable = 'y';
end
% default FPULDEMODMAPGAP is max(max(SlotModType))
if (exist('DemodMapGap','var') == 0)
    FPULDEMODMAPGAP = max(max(SlotModType));
else
    FPULDEMODMAPGAP = DemodMapGap;
end

%-- Data PreAllocation
Data = zeros(NSubCh,FPULNDATACARRIER*FPULDEMODMAPGAP);
RSSI = zeros(1,NSubCh);
CINR = zeros(1,NSubCh);
FreqOff = zeros(1,NSubCh);
TimeOff = zeros(1,NSubCh);
BitShift = zeros(1,NSubCh);
Pad = zeros(1,NSubCh);
if TC
    %Full length of data and pilots for TV generation
    FullData=zeros(NSubCh*FPULNDATACARRIER,NAntenna);
    FullPilot=zeros(NSubCh*FPULNDATACARRIER/2,NAntenna);
    IF2dRXCtrl=zeros(NSubCh*4,NAntenna);
    IF2cRXCtrl=zeros(NSubCh*FPULNDATACARRIER,NAntenna);
    FullDataMRC=zeros(NSubCh*FPULNDATACARRIER,1);
    IF2aRXCtrl=zeros(NSubCh*4,1);
    FullDataRotation=zeros(NSubCh*FPULNDATACARRIER,1);
end

%-- Start Processing
for SubChPhy = 1:NSubCh
    SubCh = SubChannelLUT(SubChPhy) + 1;
    SlotSubChUIUC = SlotUIUC((SlotVecIndex+1),SubCh);
    SlotSubChModType = SlotModType((SlotVecIndex+1),SubCh);
    % Check for ranging (UIUC=12,13) or unused SubChannel (UIUC=0xff,0xfe)
    if ((SlotSubChUIUC ~= 12)&&(SlotSubChUIUC ~= 13)&&(SlotSubChUIUC ~= 254)&&(SlotSubChUIUC ~= 255))
        for ant=1:NAntenna
            SubChTileLocationLUT = TileLocationLUT((SlotVecIndex+1),SubCh,:);
            SymbolSlotAnt(:,:) = SymbolSlot(ant,:,:);
            [DataAntSubCh,PilotSubCh]= SlotExtraction(NFFTUsed,...
                SlotVecIndex,SymbolSlotAnt,SubChTileLocationLUT,PNCodeLUT);
            % Process for UL ACK UIUC
            if (SlotSubChUIUC == 16)
                Data1Ant(ant,:) = [DataAntSubCh(1:2) DataAntSubCh(5:6) DataAntSubCh(9:10) ...
                    DataAntSubCh(13:16) DataAntSubCh(21:24) DataAntSubCh(29:32) ...
                    DataAntSubCh(37:38) DataAntSubCh(41:42) DataAntSubCh(45:46)];
                Data2Ant(ant,:) = [DataAntSubCh(3:4) DataAntSubCh(7:8) DataAntSubCh(11:12) ...
                    DataAntSubCh(17:20) DataAntSubCh(25:28) DataAntSubCh(33:36) ...
                    DataAntSubCh(39:40) DataAntSubCh(43:44) DataAntSubCh(47:48)];
                Pilot11Ant(1:FPULNPILOTCARRIER/4) = [PilotSubCh(1,1:2) PilotSubCh(1,5:6) PilotSubCh(1,9:10)];
                Pilot13Ant(1:FPULNPILOTCARRIER/4) = [PilotSubCh(2,1:2) PilotSubCh(2,5:6) PilotSubCh(2,9:10)];
                Pilot21Ant(1:FPULNPILOTCARRIER/4) = [PilotSubCh(1,3:4) PilotSubCh(1,7:8) PilotSubCh(1,11:12)];
                Pilot23Ant(1:FPULNPILOTCARRIER/4) = [PilotSubCh(2,3:4) PilotSubCh(2,7:8) PilotSubCh(2,11:12)];
                ChanEst1(ant,:) = CEIntraTile(FPULNTILE/2,Pilot11Ant,Pilot13Ant);
                ChanEst2(ant,:) = CEIntraTile(FPULNTILE/2,Pilot21Ant,Pilot23Ant);
            else
                DataAnt(ant,:) = DataAntSubCh;
                Pilot1Ant(1:FPULNPILOTCARRIER/2) = PilotSubCh(1,1:FPULNPILOTCARRIER/2);
                Pilot3Ant(1:FPULNPILOTCARRIER/2) = PilotSubCh(2,1:FPULNPILOTCARRIER/2);
                PilotAnt = [Pilot1Ant Pilot3Ant];

                if (SlotSubChUIUC ~= 0)
                    [RSSIAnt(ant) CINRAnt(ant) FreqOffAnt(ant) TimeOffAnt(ant) BitShiftAnt(ant)] = ...
                        mSlotMeasurement(PilotAnt);
                end
                if isreal(Pilot1Ant)
                    imag_factor = 0.01;
                    Pilot1Ant = Pilot1Ant + imag_factor*i*ones(size(Pilot1Ant,1),size(Pilot1Ant,2));
                end

                if isreal(Pilot3Ant)
                    imag_factor = 0.01;
                    Pilot3Ant = Pilot3Ant + imag_factor*i*ones(size(Pilot3Ant,1),size(Pilot3Ant,2));
                end
                ChanEst(ant,:) = CEIntraTile(FPULNTILE,Pilot1Ant,Pilot3Ant);
            end % (SlotSubChUIUC == 16)

            if ((SlotSubChUIUC == 0) || (SlotSubChUIUC == 16))
                RSSIAnt(ant) = 2^14;
                CINRAnt(ant) = 0;
                FreqOffAnt(ant) = 0;
                TimeOffAnt(ant) = 0;
                BitShiftAnt(ant) = 0;
            end
        end % ant=1:NAntenna

        if (SlotSubChUIUC == 16)
            if CE == 'y'
                Data1Ant = EqZF(Data1Ant,ChanEst1);
                Data2Ant = EqZF(Data2Ant,ChanEst2);
            end
            DataAnt = [Data1Ant Data2Ant];
        end
        if (SlotSubChUIUC == 0)
            if CE == 'y'
                DataAnt = EqZF(DataAnt,ChanEst);
            end
        end

        if (NAntenna > 1)
            % Process for UL ACK UIUC
            if (SlotSubChUIUC == 16)
                [Data1SubCh,RSSI(SubCh),CINR(SubCh),FreqOff(SubCh),TimeOff(SubCh),BitShift(SubCh)] = ...
                    mMRC(NAntenna,(FPULNDATACARRIER/2),Data1Ant,RSSIAnt,CINRAnt,FreqOffAnt,TimeOffAnt,BitShiftAnt);
                [Data2SubCh,RSSI(SubCh),CINR(SubCh),FreqOff(SubCh),TimeOff(SubCh),BitShift(SubCh)] = ...
                    mMRC(NAntenna,(FPULNDATACARRIER/2),Data2Ant,RSSIAnt,CINRAnt,FreqOffAnt,TimeOffAnt,BitShiftAnt);
                DataSubCh = [Data1SubCh Data2SubCh];
            elseif (SlotSubChUIUC == 0)
                [DataSubCh,RSSI(SubCh),CINR(SubCh),FreqOff(SubCh),TimeOff(SubCh),BitShift(SubCh)] = ...
                    mMRC(NAntenna,FPULNDATACARRIER,DataAnt,RSSIAnt,CINRAnt,FreqOffAnt,TimeOffAnt,BitShiftAnt);
            else
                [DataSubCh,ChanEstSubCh,RSSI(SubCh),CINR(SubCh),FreqOff(SubCh),TimeOff(SubCh),BitShift(SubCh)] = ...
                    mMRC2D(NAntenna,FPULNDATACARRIER,DataAnt,ChanEst,...
                    RSSIAnt,CINRAnt,FreqOffAnt,TimeOffAnt,BitShiftAnt);
            end
        else
            DataSubCh = DataAnt;
            if ((SlotSubChUIUC ~= 0) && (SlotSubChUIUC ~= 16))
                ChanEstSubCh = ChanEst;
                RSSI(SubCh) = RSSIAnt(1);
                CINR(SubCh) = CINRAnt(1);
                FreqOff(SubCh) = FreqOffAnt(1);
                TimeOff(SubCh) = TimeOffAnt(1);
                BitShift(SubCh) = 0;
            end
        end

        if ((SlotSubChUIUC ~= 0) && (SlotSubChUIUC ~= 16))
            if DataRotationEnable == 'y'
                DataSubChOrg = DataSubCh;
                ChanEstSubChOrg = ChanEstSubCh;
                for SubChIndex = 1:FPULNDATACARRIER
                    RotationIndex = mod(((SubChIndex-1)+(SubChPhy-1)*13),FPULNDATACARRIER)+1;
                    DataSubCh(SubChIndex) = DataSubChOrg(RotationIndex);
                    ChanEstSubCh(SubChIndex) = ChanEstSubChOrg(RotationIndex);
                end
            end

            if TC
                %To be used in TV generation
                FullDataMRC(((SubChPhy-1)*FPULNDATACARRIER+1):SubChPhy*FPULNDATACARRIER)=DataSubCh.';
                IF2aRXCtrl(((SubChPhy-1)*4+1):SubChPhy*4,ant)=[RSSI(SubCh);CINR(SubCh);FreqOff(SubCh);TimeOff(SubCh)];
                FullDataRotation(((SubChPhy-1)*FPULNDATACARRIER+1):SubChPhy*FPULNDATACARRIER)=DataSubCh.';
            end

            if (SlotSubChModType == 2) % QPSK
                BitShift(SubCh) = 17;
            elseif (SlotSubChModType == 4) % QAM16
                BitShift(SubCh) = 15;
            elseif (SlotSubChModType == 6) % QAM64
                BitShift(SubCh) = 15 - 2 ; %need to investigate
            else
                disp('ERROR : Not correct ModType')
            end

            % Demodulation mapper
            if DemapScale == 'y'
                
                if isreal(ChanEstSubCh)
                    imag_factor = 0.01;
                    ChanEstSubCh = ChanEstSubCh+ imag_factor*i*ones(size(ChanEstSubCh,1),size(ChanEstSubCh,2));
                end
                
                %the following will be removed after INT3e, only regulate algo will be kept
                global scalingDebug
                %global scalingDebug %debug purpose / to be deleted
                if all(size(scalingDebug)==[1,1])
                    if scalingDebug == 1 %debug mode
                       
                        global bitshift %get Bitshift value to use
                    end
                    %disp(['Custom bitshift : ' int2str(bitshift) ]);
                    [DataOut BlkSize] = DemodMapperMinDist(DataSubCh,ChanEstSubCh,...
                    length(DataSubCh),SlotSubChModType,bitshift);
                    
                else %regular algo, stay with the proposed BitShift
                    %disp(['Regular bitshift: ' int2str(BitShift(SubCh))]);
                    [DataOut BlkSize] = DemodMapperMinDist(DataSubCh,ChanEstSubCh,...
                    length(DataSubCh),SlotSubChModType,BitShift(SubCh));
                end
                
%                 [DataOut BlkSize] = DemodMapperMinDist(DataSubCh,ChanEstSubCh,...
%                     length(DataSubCh),SlotSubChModType,BitShift(SubCh));
                
                    
                     DataOut=DataOut';
            else
                [DataOut BlkSize] = mDemodMapperMinDist(DataSubCh,ChanEstSubCh,...
                    length(DataSubCh),SlotSubChModType);
            end
            Data(SubCh,1:BlkSize) = DataOut.';
        else
            if TC
                error('Trying to generate vectors for SlotSubChUIUC == 16 or 10')
            end
            Data(SubCh,1:FPULNDATACARRIER) = DataSubCh;

        end % SlotSubChUIUC != 0,16
    end % SlotSubChUIUC != 12,13,254,255
end % loop SubChPhy

SlotMeasurement = [RSSI;CINR;FreqOff;TimeOff;BitShift;Pad];


⌨️ 快捷键说明

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