%% Decode HARQ
% Decode the HARQ bits given PHICH symbols. Two HARQ bits are encoded into PHICH symbols using an hiset matrix, where each row is used to define an individual PHICH. The generated PHICH symbols are then decoded with the same parameters used to define the PHICHs in the encoder.
% Using lteRMCDL to create a cell-wide settings configuration structure with RMC R.1, initializes relevant parameters for this example.

rc = 'R.1';
enb = lteRMCDL(rc);

%
% Define the hiset input and generate PHICH symbols. First PHICH: [nGroup=1 nSeq=1 hi=1], second PHICH: [nGroup=1 nSeq=2 hi=0].

hiset = [ 1 1 1; 1 2 0 ];
phichSym = ltePHICH(enb,hiset);

%
% Define the hires input. PHICH resources: same as the encoder, first PHICH: [nGroup=1 nSeq=1], second PHICH: [nGroup=1 nSeq=2].

hires = [ 1 1; 1 2];

%
% Decode the PHICH.

hi = ltePHICHDecode(enb,hires,phichSym);

%
% Check decoded hi bits are the same as encoded bits.

isequal(hi,hiset(:,3))

% Copyright 2012 The MathWorks, Inc.