gusucode.com > wlan工具箱matlab源码程序 > wlan/wlan/+wlan/+internal/wlanLDPCDecode.m
function [y,numIterations,parityCheck] = wlanLDPCDecode(x,cfg,varargin) %wlanLDPCDecode Low-Density-Parity-Check (LDPC) decoder % % Note: This is an internal undocumented function and its API and/or % functionality may change in subsequent releases. % % Y = wlanLDPCDecode(X, CFG) decodes the input X using a WLAN LDPC code % at the specified rate. Output Y is a hard decision decoded output of % the information bits. % % CFG should be a structure including the fields: % VecPayloadBits - Number of payload bits within a codeword % Rate - Coding rate % NumCBPS - Number of coded bits per OFDM symbol % NumCW - Number of LDPC codewords % LengthLDPC - LDPC codeword length % VecShortenBits - Vector of shortening bits in each codeword % VecPunctureBits - Vector of puncture bits in each codeword % VecRepeatBits - Number of coded bits to be repeated % NumSymbol - Number of OFDM symbols in an LDPC encoded waveform % % Y = wlanLDPCDecode(..., MAXIMUMLDPCITERATIONCOUNT) decodes the input % data X using a WLAN LDPC code with the specified number of iterations. % The MAXIMUMLDPCITERATIONCOUNT is an integer scalar indicating the % maximum number of decoding iteration. The default value of this % property is 12. % % Y = wlanLDPCDecode(...,EARLYTERMINATION) decodes the input data X by % selecting an EARLYTERMINATION option. Set this property to true to % enable early termination of LDPC decoding if all parity-checks are % satisfied. If set to false, the decoding process will iterate for a % fixed number of iterations specified by MaximumLDPCIterationCount. This % property applies when ChannelCoding property is set to 'LDPC'. The % default is false. % % [Y, NUMITERATIONS] = wlanLDPCDecode(...) decodes the LDPC encoded data. % The function returns the actual number of LDPC decoding iterations, one % per codeword. The NUMITERATIONS is NUMCW-by-1 vector, where NUMCW is % the number of codewords. % % [Y, NUMITERATIONS, PARITYCHECK] = wlanLDPCDecode(...) decodes the LDPC % encoded data and returns the parity check per codeword. The PARITYCHECK % is NUMINP-by-NUMCW matrix, where NUMINP is the number of information % bits within a codeword and NUMCW is the number of codewords. % % See also wlanLDPCEncode, getLDPCparameters. % Copyright 2016 The MathWorks, Inc. %#codegen narginchk(2,4); nargoutchk(0,3); if nargin == 4 maximumLDPCIterationCount = varargin{1}; iterationTerminationCondition = varargin{2}; elseif nargin == 3 maximumLDPCIterationCount = varargin{1}; iterationTerminationCondition = false; else maximumLDPCIterationCount = 12; iterationTerminationCondition = false; end numCW = cfg.NumCW; lengthLDPC = cfg.LengthLDPC; vecShortenBits = cfg.VecShortenBits; vecPunctureBits = cfg.VecPunctureBits; vecRepeatBits = cfg.VecRepeatBits; vecPayloadBits = cfg.VecPayloadBits; rate = cfg.Rate; % Initialize output y = coder.nullcopy(zeros(sum(vecPayloadBits),1,'int8')); offset = 0; depuncturedCW = coder.nullcopy(zeros(lengthLDPC,numCW)); for idxCW = 1:numCW % Retrieve information bits inpBits = x(offset + (1:vecPayloadBits(idxCW)), 1); % Size of the parity bits after puncturing pBlkSize = round(lengthLDPC*(1-rate)) - vecPunctureBits(idxCW); % Get parity bits parityBits = double(x(offset + vecPayloadBits(idxCW) + (1:pBlkSize), 1)); % Convert into LLRs shortenBits = realmax * ones(vecShortenBits(idxCW), 1); % Extra bits to compensate for puncturing extraBits = zeros(vecPunctureBits(idxCW), 1); % Depunctured codeword depuncturedCW(:,idxCW) = [inpBits;shortenBits;parityBits;extraBits]; offset = offset + vecPayloadBits(idxCW) + pBlkSize + vecRepeatBits(idxCW); end if iterationTerminationCondition [out, numIterations, parityCheck] = wlan.internal.ldpcDecodeCore( ... depuncturedCW, rate, maximumLDPCIterationCount, 'early exit'); else [out, numIterations, parityCheck] = wlan.internal.ldpcDecodeCore( ... depuncturedCW, rate, maximumLDPCIterationCount); end idx = 0; for idxCW = 1:numCW y(idx + (1:vecPayloadBits(idxCW))) = out(1:vecPayloadBits(idxCW),idxCW); idx = vecPayloadBits(idxCW) + idx; end % [EOF]