📄 mvitdecoder_2x.m
字号:
function [Out,BlkSize] = mVitDecoder(In,BlkSize,mode,pmode,DemapScale)
% Viterbi Decoder for the FEC Decoder of IEEE 802.16-2004
% (WiMAX, OFDMA only)
%
% [Out,BlkSize] = mVitDecoder(In,BlkSize,mode,pmode,DemapScale)
%
% In : soft symbol input vector or matrix (values -128 to 127)
% one column per code block.
% BlkSize: row vector, length = number of code blocks
% number of data bits for each code block
% mode : specifies the decoding mode
% 0 = CC (tail-biting)
% 3 = ZT-CC (zero-tailing)
% pmode : specifies the puncturing mode (0,1,2)
% This parameter is only required for the tail-biting Viterbi which
% is implemented using a temporary workaround.
% DemapScale: specifies the DemapScale mode ('y','n')
% 'y': use of 'soft'8
% 'n': use of 'unquant'
%
% Out : binary output vector or matrix (values 0 or 1)
% one column per code block.
%
% Note: Internally the input is rounded before decoding.
%
% Matlab Release 14SP2
% The communication toolbox is required.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Property of Freescale
% Freescale Confidential Proprietary
% Freescale Copyright (C) 2005 All rights reserved
% ----------------------------------------------------------------------------
% $RCSfile: mVitDecoder_2x.m.rca $
% $Revision: 1.3 $
% $Date: Tue Dec 19 17:00:30 2006 $
% Target: Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[m,n]=size(In);
%check dimensions
[x,y]=size(BlkSize);
if ((x~=1)|(y~=n))
error('Error: BlkSize must be row vector with the same number of columns as In.');
end
if (DemapScale == 'y')
% %round
% Ins=In;
% In=int8(In);
% % check input range
% if (max(max(In))>127)|(min(min(In))<-128)
% error('Error: Viterbi decoder input is out of range.');
% end
% %convert data to unsigned numbers
% In = rescale(-Ins,'uint8','max',0.7); %option4=0.7 seems not too bad
In = -In + 127 ;
end
%define constant
t = poly2trellis(7,[171 133]);
switch mode,
case 0 %tail-biting
Out = logical(zeros(m/2,n));
for b=1:n,
temp = double([In(1:BlkSize(b),b);In(1:BlkSize(b),b)]);
if (DemapScale == 'y')
temp = vitdec(temp,t,BlkSize(b),'trunc','soft',8);
else
temp = vitdec(temp,t,BlkSize(b),'trunc','unquant');
end
Out(1:BlkSize(b)/2,b) = [temp(BlkSize(b)/2+1:BlkSize(b)/4+BlkSize(b)/2) ; temp(BlkSize(b)/4+1:BlkSize(b)/2)];
end %for
BlkSize=BlkSize/2;
case 3 %zero-tailing
Out = logical(zeros(m/2,n));
for b=1:n,
Out(1:BlkSize(b)/2,b) = vitdec(double(In(1:BlkSize(b),b)),t,3,'term','soft',8);
end
BlkSize=BlkSize/2-8;
otherwise
error('Error: Viterbi decoder mode unknown.');
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -