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

📄 mcodeblkseg_ctc.m

📁 OFDMA 物理层开发的matlab 源码.飞思卡尔提供.对物理层开发的工程师有帮助!
💻 M
字号:
% CTC code block seg

function [Out,BlkSize,DataSize,NumSlots] = mCodeBlkSeg_CTC(In,ZoneD,BurstD)

In=In(:);
%BurstD.Type=3;%debugging
%[numRow,numCol] = size(In);

%-- Parameters Definition
% j : parameter dependent on modulation and FEC rate 
% n : number of allocated slots
% k : floor(n/j)
% m : mod(n,j)

switch BurstD.Type
    case 0 % QPSK rate 1/2
        j = 10;
        numBytePerSlot = 6;
    case 1 % QPSK rate 3/4
        j = 6;
        numBytePerSlot = 9;
    case 2 % 16QAM rate 1/2
        j = 5;
        numBytePerSlot = 12;
    case {3,4} % 16QAM rate 3/4 and 64QAM rate 1/2
        j = 3;
        numBytePerSlot = 18;
    case 5 % 64QAM rate 2/3
        j = 2;
        numBytePerSlot = 24;
    case 6 % 64QAM rate 3/4
        j = 2;
        numBytePerSlot = 27;
    otherwise
        error('Unknown FEC Type')
end
n = BurstD.Slots;
k = floor(n/j);
m = mod(n,j);

%padding if needed
Npadding = numBytePerSlot*n - size(In,1) ; 
In = [In ; ones(Npadding,1)*255 ];
[numRow,numCol] = size(In);

if n<=j & n~=7
    %1 block of n slots

    Out = (In(:));
    BlkSize  = [n*numBytePerSlot];
    NumSlots = [n];
    
elseif n==7
    %1 block of 4 slots
    %1 block of 3 slots

    Out  = zeros(4*numBytePerSlot , 2);
    inter = 4*numBytePerSlot ; 
    Out1 = In(1,1:inter) ; 
    Out2 = In(1,inter+1:end) ;
    Out(1:4*numBytePerSlot   , 1) = Out1' ;
    Out(1:3*numBytePerSlot   , 2) = Out1' ;
    BlkSize  = [4*numBytePerSlot 3*numBytePerSlot];
    NumSlots = [4 3];
    
elseif n>j

    Lb1 = ceil((m+j)/2);
    Lb2 = floor((m+j)/2);

    if (Lb1==7) | (Lb2==7)
        Lb1=Lb1 + 1;
        Lb2=Lb2 - 1;
    end

    if mod(n,j)==0
        %k blocks of j slots
               
        Out = reshape(In,j*numBytePerSlot,k);
        BlkSize  = [ones(1,k)*j*numBytePerSlot];
        
        NumSlots = [ones(1,k)*j];

    else
        %k-1 blocks of j slots
        %1 blocks of Lb1 slots
        %1 blocks of Lb2 slots

        inter1 = (k-1)*j*numBytePerSlot ;
        inter2 = inter1 + 1*Lb1*numBytePerSlot ;
        inter3 = inter2 + 1*Lb2*numBytePerSlot ; %= "end"
        %check that intermediate3 == numCol
        if inter3 ~= numRow
            error('Wrong inters in mCodeBlkSegULTX_CTC.')
            
        end
        
        Out1 = reshape(In(1:inter1),j*numBytePerSlot,k-1);
        Out2 = reshape(In(inter1+1:inter2),Lb1*numBytePerSlot,1);
        Out3 = reshape(In(inter2+1:inter3),Lb2*numBytePerSlot,1);

        if k-1==0
            Out = 255*ones(max(Lb1,Lb2)*numBytePerSlot , k-1 + 1 + 1 );
            Out(1:Lb1*numBytePerSlot , k:k    ) = Out2 ;
            Out(1:Lb2*numBytePerSlot , k+1:k+1) = Out3 ;
        else
            Out = 255*ones(j*numBytePerSlot , k-1 + 1 + 1 );
            Out(1:j*numBytePerSlot   , 1:k-1  ) = Out1 ;
            Out(1:Lb1*numBytePerSlot , k:k    ) = Out2 ;
            Out(1:Lb2*numBytePerSlot , k+1:k+1) = Out3 ;
        end

        
        BlkSize  = [ones(1,k-1)*j*numBytePerSlot Lb1*numBytePerSlot Lb2*numBytePerSlot];
        NumSlots = [ones(1,k-1)*j Lb1 Lb2];
        
    end
end

if Npadding >= 1 %padding
    DataSize = BlkSize;
    DataSize(end) = BlkSize(end) - Npadding;
else %no padding, full slots
    DataSize = BlkSize;
end









⌨️ 快捷键说明

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