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

📄 mcodeblkseg.m

📁 OFDMA 物理层开发的matlab 源码.飞思卡尔提供.对物理层开发的工程师有帮助!
💻 M
字号:
function [Out,BlkSize,DataSize,NumSlots] = mCodeBlkSeg(In,ZoneD,BurstD)
% Downlink code block segmentation for OFDMA of IEEE 802.16 (WiMAX) 
%
%     [Out,BlkSize,DataSize,NumSlots] = mCodeBlkSeg(In,ZoneD,BurstD)
%
% This module performes the segmentation of the payload data of one burst
% into code blocks dependent on the defined burst dimension and FEC coding
% and modulation type. Furthermore, the input data is appended with padding
% bytes (0xff) if the provided input data is not sufficient to fill the
% burst.
%
% In      : burst input vector (bytes, values 0 to 255)
% ZoneD   : zone descriptor
% BurstD  : burst descriptor
%
% Out     : output matrix (bytes, values 0 to 255)
%           One column per code block, the number of elements in each column
%           is the maximum code block size for the specified FEC code and
%           modulation type.
% BlkSize : row vector, length = number of code blocks
%           number of padded payload data bytes for each code block
% DataSize: row vector, length = number of code blocks
%           number of unpadded payload data bytes for each code block
% NumSlots: row vector, length = number of code blocks
%           number of slots in each code block
%
% Matlab 7 Release 14 SP2

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Property of Freescale
%  Freescale Confidential Proprietary
%  Freescale Copyright (C) 2005 All rights reserved
%  ----------------------------------------------------------------------------
%  $RCSfile: mCodeBlkSeg.m.rca $
%  $Revision: 1.1 $
%  $Date: Thu Sep 28 04:02:14 2006 $
%  Target: Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if (BurstD.IUC==254) %distinguish between MAP and "normal" bursts
   %allocated slots
   Ns = BurstD.Duration;
   %check MAP burst dimension
   if (Ns>(ZoneD.NumSym*ZoneD.NumSubch-BurstD.SymOff)/ZoneD.Type-BurstD.SubchOff)
      error('Error: MAP burst does not fit into zone.');
   end
else  
   %allocated slots
   Ns = BurstD.NumSym*BurstD.NumSubch/ZoneD.Type;
   %check burst dimension
   if mod(BurstD.NumSym,ZoneD.Type)
      error('Error: Number of OFDMA symbols does not match zone type.');
   end
   if ((BurstD.NumSym+BurstD.SymOff)>ZoneD.NumSym)
      error('Error: OFDMA symbol dimension exceeds zone limit.');
   end
   if ((BurstD.NumSubch+BurstD.SubchOff)>ZoneD.NumSubch)
      error('Error: Subchannel dimension exceeds zone limit.');
   end
end

if mod(Ns,BurstD.R)
   error('Error: Number of allocated slots is not a multiple of the repetition factor.');
end

%payload
K = BurstD.Slots;
MaxLen = K*BurstD.B;
InLen = length(In);

%check input length
if InLen>MaxLen
    error('Error: Too much payload data for burst profile.');
end

%number of code blocks (matlab version, including division)
%CodeBlks = ceil(K/BurstD.J);
%number of code blocks (efficient C version)
Aux = [32767,16383,10922,8191, 0, 5461];
CodeBlks = bitshift(K*Aux(BurstD.J),-15)+1;

%number of slots in each code block
if CodeBlks==1
   NumSlots=K;
elseif CodeBlks==2
   temp=bitshift(K,-1);
   NumSlots=[K-temp,temp];
elseif CodeBlks>2
   partial=K-(CodeBlks-2)*BurstD.J;
   temp=bitshift(partial,-1);
   NumSlots=[BurstD.J*ones(1,CodeBlks-2),partial-temp,temp];
end
BlkSize=NumSlots*BurstD.B;

%generate output
Out=zeros(BurstD.J*BurstD.B,CodeBlks,class(In));
DataSize=zeros(1,CodeBlks);
offset=0;
for k=1:CodeBlks,
  if InLen>=BlkSize(k)
    Out(1:BlkSize(k),k)=In(offset+1:offset+BlkSize(k));
    InLen=InLen-BlkSize(k);
    offset=offset+BlkSize(k);
    DataSize(k)=BlkSize(k);
  else
    Out(1:InLen,k)=In(offset+1:offset+InLen);
    Out(InLen+1:BlkSize(k),k)=255; %0xff padding
    DataSize(k)=InLen;
    InLen=0;
  end
end

⌨️ 快捷键说明

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