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

📄 mgenstructupul.m

📁 OFDMA 物理层开发的matlab 源码.飞思卡尔提供.对物理层开发的工程师有帮助!
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Property of Freescale
%  Freescale Confidential Proprietary
%  Freescale Copyright (C) 2006 All rights reserved
%  ----------------------------------------------------------------------------
%  $RCSfile: mGenStructUPUL.m.rca $
%  $Revision: 1.1 $
%  $Date: Fri Nov 17 10:33:35 2006 $
%  Target: Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% For WiMAX 802.16 OFDMA, generate Matlab control structures to target
% control structures for UP DL CC Manager
%
%  [UPDLCCMgr_byte] =
%  [ULBurstCtrl_byte,ULCbAllocCtrl_byte,stULSlotAllocCtrl_byte,stUPULVitPre
%  ProcMgrCtrl_byte,stUPULVitMgrCtrl_byte] = mGenStructUPUL(BurstD,ZoneD,EachBurstBlkSize,SlotX,SlotY)
%
% input : Matlab control structures
% BufIn : input burst buffers
%
% output: Target control structures
%         (binary file format, big endian)
% BufOut: Concatenated and aligned input burst buffers
%
% Matlab 7 R14 SP2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [ULBurstCtrl_byte,ULCbAllocCtrl_byte,stULSlotAllocCtrl_byte,stUPULVitPreProcMgrCtrl_byte,stUPULVitMgrCtrl_byte] = mGenStructUPUL(BurstD,ZoneD,EachBurstBlkSize,SlotX,SlotY)

EachBurstPadedBlkSize=EachBurstBlkSize/(48*BurstD.ModMode);%
EachBurstPaddedSize=EachBurstBlkSize/(8*BurstD.ModMode);%Number of bytes of padded payload of each code block of each burst

ULCbAllocCtrl=[];
ULCbAllocCtrlOffset=0;
ULBurstCtrl=[];
stULSlotAllocCtrl=[];
stUPULVitPreProcMgrCtrl=[];
stUPULVitMgrCtrl=[];
for b=1:size(BurstD,2)

    % UL Burst Ctrl structure
%     LastSlotVec=mod(((BurstD(b).SymOff/ZoneD.Type)+BurstD(b).Duration),(ZoneD.NumSym/ZoneD.Type));
    temp = [ ... % structure contains 11 bytes
        struct('Name', 'uliBurstSize'               ,'Val', uint32(sum(EachBurstPaddedSize(b,:)))),...
        struct('Name', 'usiNumBlocks'               ,'Val', uint16(size(EachBurstBlkSize(b,:),2))),...
        struct('Name', 'usiULCbAllocCtrlOffset'     ,'Val', uint16(ULCbAllocCtrlOffset)),...
        struct('Name', 'ucCID'                      ,'Val', int8(BurstD(b).CID)),...
        struct('Name', 'ucLastSlotVec'              ,'Val', int8(SlotX(end))),...
        struct('Name', 'ucReserved'                 ,'Val', int8(zeros(6,1)))];
    ULBurstCtrl = [ULBurstCtrl ,temp];

    %stULSlotAllocCtrl descriptor
    for slt=1:sum(EachBurstPadedBlkSize(b,:))
        temp = [ ... % structure contains 4 bytes
            struct('Name', 'usiSlotVecOffset'       ,'Val', uint16(SlotX(slt))),...
            struct('Name', 'usiSubChanOffset'       ,'Val', uint16(SlotY(slt)))...
            ];
        stULSlotAllocCtrl = [stULSlotAllocCtrl ,temp];
    end

    for bl=1:size(EachBurstBlkSize(b,:),2)

        %stULCbAllocCtrl descriptor
        temp = [ ... % structure contains 8 bytes
            struct('Name', 'usiULSlotAllocCtrlOffset' ,'Val', uint16(ULCbAllocCtrlOffset)),...
            struct('Name', 'usiNumSlots'              ,'Val', uint16(EachBurstPadedBlkSize(b,bl))),...
            struct('Name', 'ucRepCodingInfo'          ,'Val', uint8(BurstD(b).R)),...
            struct('Name', 'ucSlotVecEnd'             ,'Val', uint8(SlotX(sum(EachBurstPadedBlkSize(b,1:bl))))),...
            struct('Name', 'usiCodeBlockOffset'       ,'Val', uint16(sum(EachBurstPaddedSize(b,1:bl-1),2)))...
            ];
        ULCbAllocCtrl = [ULCbAllocCtrl ,temp];
        ULCbAllocCtrlOffset=ULCbAllocCtrlOffset+EachBurstPadedBlkSize(b,bl);


        %stUPULVitPreProcMgrCtrl descriptor
        temp = [ ... % structure contains 8 bytes
            struct('Name', 'eModMode'   ,'Val', uint8(BurstD(b).ModMode)),...
            struct('Name', 'usiInLen'   ,'Val', uint16(EachBurstBlkSize(b,bl)))];
        stUPULVitPreProcMgrCtrl = [stUPULVitPreProcMgrCtrl ,temp];

        %stUPULVitMgrCtrl descriptor
        temp = [ ... % structure contains 8 bytes
            struct('Name', 'ePunctRate'   ,'Val', uint8(BurstD(b).PunctMode)),...
            struct('Name', 'usiInLen'   ,'Val', uint16(EachBurstBlkSize(b,bl))),...
            struct('Name', 'aucReserved'                 ,'Val', int8(zeros(2,1)))];
        stUPULVitMgrCtrl = [stUPULVitMgrCtrl ,temp];

    end
end

% UPDLCCMgr_byte = ConvertStruct(UPDLCCMgr);
ULCbAllocCtrl_byte = ConvertStruct(ULCbAllocCtrl);
ULBurstCtrl_byte = ConvertStruct(ULBurstCtrl);
stULSlotAllocCtrl_byte = ConvertStruct(stULSlotAllocCtrl);
stUPULVitPreProcMgrCtrl_byte = ConvertStruct(stUPULVitPreProcMgrCtrl);
stUPULVitMgrCtrl_byte= ConvertStruct(stUPULVitMgrCtrl);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 + -