📄 mdemodmapper.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Property of Freescale
% Freescale Confidential Proprietary
% Freescale Copyright (C) 2005 All rights reserved
% ----------------------------------------------------------------------------
% $RCSfile: mDemodMapper.m.rca $
% $Revision: 1.9 $
% $Date: Fri Jan 12 18:20:37 2007 $
% Target: Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Demodulation Mapping of IEEE 802.16-2004 (OFDMA, WiMAX)
%
% [Out, BlkSize] = mDemodMapper(In,BlkSize,mode,d)
%
% In : complex input column vector
% Matrices are processed column by column, one vector per column.
%
% mode : number of coded bits per complex soft symbol
% 2 = QPSK
% 4 = 16QAM
% 6 = 64QAM
% The mode is the same for all code blocks.
%
%
% Out: soft symbol output vector ('int8', values -128 to 127)
%
% BlkSize: row vector, length = number of code blocks
% number of data elements in each code block (or column)
%
% Matlab 7 Release 14 SP2
%-- Matlab files used by this file
%-- End of list
function [Out,BlkSize] = mDemodMapper(In,BlkSize,mode,DemapScale)
% Changed from a define..... %
[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
% Distance is calculated induvidually for each slot
InSlotUnits=reshape(In,48,[]);
switch mode
case 2 %QPSK
d=ones(48,1)*(mean(abs(double(InSlotUnits)))*cos(pi/4));
d=reshape(d,m,n);
case 4 %16QAM
d=ones(48,1)*(mean(abs(double(InSlotUnits)))*cos(pi/4));
d=reshape(d,m,n);
case 6 %64QAM
d=ones(48,1)*(mean(abs(double(InSlotUnits)))*cos(pi/4))/2;
d=reshape(d,m,n);
otherwise
error('Error: Modulation mode %d not supported.',mode);
end
[x,y]=size(d);
if (x*y)==1
d=d*ones(1,n);
end
if any(d<0)
error('Error: Distance must be positive.')
end
switch mode
case 2 %QPSK
maxval = d;
In = reshape(In,1,m,n);
Out = reshape([real(In);imag(In)],m*2,n);
case 4 %16QAM
maxval = 2*d;
d = reshape(d,1,m,n);
In = double(reshape(In,1,m,n));
b3 = real(In);
b1 = imag(In);
Out = reshape([b3;d-abs(b3);b1;d-abs(b1)],m*4,n);
case 6 %64QAM
maxval = 4*d;
d = reshape(d,1,m,n);
In = double(reshape(In,1,m,n));
b5 = real(In);
b4 = 2*d-abs(b5);
b2 = imag(In);
b1 = 2*d-abs(b2);
Out = reshape([b5;b4;d-abs(b4);b2;b1;d-abs(b1)],m*6,n);
otherwise
error('Error: Modulation mode %d not supported.',mode);
end
BlkSize = BlkSize*mode;
if (DemapScale == 'y')
% Normalize to max precision
shift = 7 - floor(log2(maxval+1e-300)); % 1e-300 is to eliminate log of 0
shift = (shift<=0) .* shift; % saturate, avoid values greater than 0
temp=shift.';
for k=1:mode-1
temp=[temp;shift.'];
end
shift=reshape(temp,n,m*mode).';
Out = double(Out) .* (2.^shift);
Out = int8(Out);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -