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

📄 mgenstructmacphy.m

📁 OFDMA 物理层开发的matlab 源码.飞思卡尔提供.对物理层开发的工程师有帮助!
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Property of Freescale
%  Freescale Confidential Proprietary
%  Freescale Copyright (C) 2006 All rights reserved
%  ----------------------------------------------------------------------------
%  $RCSfile: mGenStructMacPhy.m.rca $
%  $Revision: 1.1 $
%  $Date: Tue Nov 14 06:21:06 2006 $
%  Target: Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% For WiMAX 802.16 OFDMA, generate Matlab control structures to target
% control structures for MAC-PHY IF
%
%  [IF1TXDLSysD
%  IF1TXDLCtrl]=mGenStructMacPhy(TPparam,SubframeD,AsyncPhyCtrl,ZoneD,BurstD,BurstStart,ULDL)
%
% input : Matlab control structures
%       ULDL:Indicates UL/DL (UL:1, 0:DL)
%
% output: Concatenated and aligned MAC-PHY control IF for DL
%         (binary file format, big endian)
%
% Matlab 7 R14 SP2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%Caustion in use
%%%%%%%%%%%%%%%%
% IF1TXDLSysD related causions
% ucSubChBitMAPDL is calculed assuming that only one segment is in use
% followings are yet to be done ucRTG, ucTTG, ucWindowingRolloff, and
% ucTxGainFactor 
% Supports when only one segment is in use (ucSubChBitMAPDL)

function [IF1TXDLSysD_byte IF1TXDLCtrl_byte] = mGenStructMacPhy(TPparam,SubframeD,AsyncPhyCtrl,ZoneD,BurstD,BurstStart,ULDL)

%Generating the System descriptor (IF1TXDLSysD)
if ULDL==0
    %Extract preamble
    addpath('../../../../SP/TP/DL/SPKernel/PreambleGen/matlab/');
    Preamble = int16(mPreambleGen(SubframeD));
    [IQInterleavedPreamble]=reshape([real(Preamble) imag(Preamble)].',[],1);
    IQInterleavedPreamble2048=[IQInterleavedPreamble;int16(zeros((2048-size(IQInterleavedPreamble,1)),1))];
    %UL Subcarrier split for sectorization  (NA)
    SubChBitMAPUL=uint8(zeros(9,1));
else
    %Fill preamble with zero (NA)
    IQInterleavedPreamble2048=int16(zeros(2048,1));
    %UL Subcarrier split for sectorization
    SubChBitMAPUL=uint8(zeros(9,1));
    SubChBitMAPUL(1,1)=uint8(max(SubframeD.SegMap));
end

IF1TXDLSysD = [ ...
    struct('Name', 'aucPreambleIQ'       ,'Val', uint16(IQInterleavedPreamble2048)),...
    struct('Name', 'usiFftSize'          ,'Val', uint16(TPparam.SizeFFT)),...
    struct('Name', 'ucStartOfCdmaCodes'  ,'Val', uint8(0)),... %TBD
    struct('Name', 'ucInitRanCodes'      ,'Val', uint8(0)),... %TBD
    struct('Name', 'ucPeriodicRanCodes'  ,'Val', uint8(0)),... %TBD
    struct('Name', 'ucHoCodes'           ,'Val', uint8(0)),... %TBD
    struct('Name', 'ucBWReqCodes'        ,'Val', uint8(0)),... %TBD
    struct('Name', 'ucCellid'            ,'Val', uint8(AsyncPhyCtrl.IDCell)),...
    struct('Name', 'ucSubChBitMAPDL'     ,'Val', uint8(max(SubframeD.SegMap))),...%Asuming only one segment is used
    struct('Name', 'ucSubChBitMAPUL'     ,'Val', SubChBitMAPUL),... %Used only in UL
    struct('Name', 'ucRTG'               ,'Val', uint8(0)),... %TBD
    struct('Name', 'ucTTG'               ,'Val', uint8(0)),... %TBD
    struct('Name', 'ucRatioG'            ,'Val', uint8(TPparam.SizeFFT/TPparam.SizeCP)),... %CP ratio
    struct('Name', 'ucWindowingRolloff'  ,'Val', uint8(0)),... %TBD
    struct('Name', 'ucTxGainFactor'      ,'Val', uint8(0)),... %TBD
    struct('Name', 'ucSegNumber'         ,'Val', uint8(AsyncPhyCtrl.SegmentNr)),... %TBD
    struct('Name', 'ucReserved'          ,'Val', uint8(zeros(8,1)))... %Reserved
    ];
IF1TXDLSysD_byte = ConvertStruct(IF1TXDLSysD);

%Generating IF1TXDLCrtl structure
if ULDL==0  %DL
    NumSym=SubframeD.NumSym+1;%with preamble
    FrameNumber=0;
else %UL
    NumSym=SubframeD.NumSym;%without preamble
    FrameNumber=AsyncPhyCtrl.FrameNr;
end
%Sub-Frame descriptor
SubFrameDes = [...
    struct('Name', 'uliFrameNumber'      ,'Val', uint32(FrameNumber)),...%Used only in UL
    struct('Name', 'ucNumSym'            ,'Val', uint8(NumSym)),...
    struct('Name', 'ucNumZones'  ,'Val', uint8(SubframeD.NumZones)),...
    struct('Name', 'aucReserved'      ,'Val', uint8(zeros(10,1)))... %Reserved
    ];

%Zone descriptor
if ULDL==0  %DL
    NumSym=SubframeD.NumSym+1;%with preamble
    BuDStart=ZoneD.uliBuDStart;
    PermBase=AsyncPhyCtrl.DlPermBase;
else %UL
    NumSym=SubframeD.NumSym;%without preamble
    BuDStart=0;
    PermBase=AsyncPhyCtrl.UlPermBase;
end
ZoneDes = [...
    struct('Name', 'ucZoneType'          ,'Val', uint8(ZoneD.Type)),...
    struct('Name', 'ucZoneOffset'        ,'Val', uint8(ZoneD.SymOff)),...
    struct('Name', 'ucNumSym'            ,'Val', uint8(NumSym)),...
    struct('Name', 'ucZoneBoost'         ,'Val', uint8(ZoneD.ZoneBoost)),...
    struct('Name', 'uliBuDStart'         ,'Val', uint32(BuDStart)),...
    struct('Name', 'usiNumBursts'        ,'Val', uint16(ZoneD.NumBursts)),...
    struct('Name', 'ucUseAllScInd'       ,'Val', uint8(ZoneD.UseAllScInd)),...
    struct('Name', 'ucPermBase'          ,'Val', uint8(PermBase)),...
    struct('Name', 'ucReserved'          ,'Val', uint8(zeros(4,1)))... %Reserved
    ];

%Burst descriptor
BurstDes=[];
for b=1:size(BurstD,2)
    % Before DIUC/UIUC (0..15, 255=FCH, 254=MAP) => (0..15, 17=FCH, 16=MAP)
    if BurstD(b).IUC == 254
        BurstD(b).IUC = 16;
    elseif BurstD(b).IUC == 255
        BurstD(b).IUC = 17;
    end

    %     %stDLPAPRZoneData (TBD, When only DIUC=13)
    %     stDLPAPRZoneData = [...
    %         struct('Name', 'ucOFDMASymOffset'   ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucSubchanOffset'    ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucNumOFDMASym'      ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucNumSubchan'       ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'aucReserved'        ,'Val', uint8(zeros(16,1)))...
    %         ];

    %     %stULPAPRZone (Only in UL)
    %     stULPAPRZone = [...
    %         struct('Name', 'ucOFDMASymOffset'    ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucSubchanOffset'     ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucNumOFDMASym'       ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucNumSubchan'        ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucPAPRSafetySounding','Val', uint8(0)),... %TBD
    %         struct('Name', 'aucReserved'         ,'Val', uint8(zeros(15,1)))...
    %         ];

    %     %stULFastFeed (Only in UL)
    %     stULFastFeed = [...
    %         struct('Name', 'uliFFCtrlDataPtr'    ,'Val', uint32(0)),... %TBD
    %         struct('Name', 'uliFFCtrlDataLen'    ,'Val', uint32(0)),... %TBD
    %         struct('Name', 'ucOFDMASymOffset'    ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucSubchanOffset'     ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucNumOFDMASym'       ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucNumSubchan'        ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'aucReserved'         ,'Val', uint8(zeros(8,1)))...
    %         ];

    %     %stULCDMARange (Only in UL)
    %     stULCDMARange = [...
    %         struct('Name', 'uliControlStart'     ,'Val', uint32(0)),... %TBD
    %         struct('Name', 'uliControlSize'      ,'Val', uint32(0)),... %TBD
    %         struct('Name', 'ucOFDMASymOffset'    ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucSubchanOffset'     ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucNumOFDMASym'       ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucNumSubchan'        ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucRangMethod'        ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'ucDedicatedRangInd'  ,'Val', uint8(0)),... %TBD
    %         struct('Name', 'aucReserved'         ,'Val', uint8(zeros(6,1)))...
    %         ];

    if ULDL==0  %DL

        %StdProfileDL  (DIUC=0 to 12)
        StdProfileDL = [...
            struct('Name', 'uliBurstStart'      ,'Val', uint32(BurstStart(b))),...
            struct('Name', 'uliBurstSize'       ,'Val', uint32(BurstD(b).Size)),...
            struct('Name', 'ucFECType'          ,'Val', uint8(BurstD(b).Type)),...
            struct('Name', 'ucOFDMASymOffset'   ,'Val', uint8(BurstD(b).SymOff)),...
            struct('Name', 'ucSubchanOffset'    ,'Val', uint8(BurstD(b).SubchOff)),...
            struct('Name', 'ucBoosting'         ,'Val', uint8(BurstD(b).Boosting)),...
            struct('Name', 'ucNumOFDMASym'      ,'Val', uint8(BurstD(b).NumSym)),...
            struct('Name', 'ucNumSubchan'       ,'Val', uint8(BurstD(b).NumSubch)),...
            struct('Name', 'ucRepCodingInfo'    ,'Val', uint8(BurstD(b).R)),...
            struct('Name', 'aucReserved'      ,'Val', uint8(zeros(5,1)))...
            ];

        %StContMap (DIUC=16 or 17)
        StContMap = [...
            struct('Name', 'uliBurstStart'      ,'Val', uint32(BurstStart(b))),...
            struct('Name', 'uliBurstSize'       ,'Val', uint32(BurstD(b).Size)),...
            struct('Name', 'ucFECType'          ,'Val', uint8(BurstD(b).Type)),...
            struct('Name', 'ucNumOFDMASlots'    ,'Val', uint8(BurstD(b).Slots*BurstD(b).R)),... %Including repetition
            struct('Name', 'ucBoosting'         ,'Val', uint8(BurstD(b).Boosting)),...
            struct('Name', 'ucRepCodingInfo'    ,'Val', uint8(BurstD(b).R)),...
            struct('Name', 'aucReserved'        ,'Val', uint8(zeros(8,1)))...
            ];

        if BurstD(b).IUC <= 12
            temp=StdProfileDL;
        elseif BurstD(b).IUC == 16 || BurstD(b).IUC == 17
            temp=StContMap;
        else
            disp(sprintf('BurstD(%d).IUC is not supported yet',b));
        end

    else %UL
        %StdProfileUL 
        StdProfileUL = [...
            struct('Name', 'usiCID'           ,'Val', uint16(BurstD(b).CID)),...
            struct('Name', 'usiDuration'      ,'Val', uint16(BurstD(b).Duration)),...
            struct('Name', 'ucFECType'        ,'Val', uint8(BurstD(b).Type)),...
            struct('Name', 'ucRepCodingInfo'  ,'Val', uint8(BurstD(b).R)),...
            struct('Name', 'usiSlotOffset'    ,'Val', uint16(0)),... %TBD
            struct('Name', 'aucReserved'     ,'Val', uint8(zeros(12,1))),...
            ];

        if BurstD(b).IUC > 0 && BurstD(b).IUC <= 10
            temp=StdProfileUL;
        elseif BurstD(b).IUC == 13
            disp(sprintf('BurstD(%d).IUC is not supported yet: PAPR',b));
        elseif BurstD(b).IUC == 12
            disp(sprintf('BurstD(%d).IUC is not supported yet: Fastfeedback',b));
        elseif BurstD(b).IUC == 0
            disp(sprintf('BurstD(%d).IUC is not supported yet: Ranging',b));
        else
            disp(sprintf('BurstD(%d).IUC is not supported yet',b));
        end
    end

    BurstDes = [BurstDes , ...
        struct('Name', 'ucIUC'               ,'Val', uint8(BurstD(b).IUC)),...
        struct('Name', 'ucExtendedIUC'       ,'Val', uint8(BurstD(b).ExtendedIUC)),...
        struct('Name', 'ucReserved'          ,'Val', uint8(zeros(2,1))),... %Reserved
        temp...
        ];
end

IF1TXDLCrtl = [ ...
    SubFrameDes,...
    ZoneDes,...
    BurstDes...
    ];
IF1TXDLCtrl_byte = ConvertStruct(IF1TXDLCrtl);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [Out] = ConvertStruct(In)
% concatenate all structure elements in big-endian format

Out=[];
for k=1:length(In),
  switch class(In(k).Val)
    case 'uint8'
         val  = In(k).Val;
    case 'int8'
         base = 256;
         val  = uint8(mod(double(In(k).Val)+base,base));  %make unsigned
    case 'uint16'
         val  = In(k).Val;
         val  = uint8(bitand([bitshift(val,-8);val],255));
    case 'int16'
         base = 65536;
         val  = uint16(mod(double(In(k).Val)+base,base)); %make unsigned
         val  = uint8(bitand([bitshift(val,-8);val],255));
    case 'uint32'
         val  = In(k).Val;
         val  = uint8(bitand([bitshift(val,-24);bitshift(val,-16);...
                             bitshift(val,-8) ;val],255)); 
    case 'int32'
         base = 4294967296;
         val  = uint32(mod(double(In(k).Val)+base,base)); %make unsigned
         val  = uint8(bitand([bitshift(val,-24);bitshift(val,-16);...
                             bitshift(val,-8) ;val],255)); 
    otherwise
         error('Error: Class not supported.');
  end %switch

  Out = [Out;val];

end %for

⌨️ 快捷键说明

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