Documentation

## Model HARQ Indicator and PHICH

This example shows how to implement the HARQ Indicator (HI) and physical HI channel (PHICH). You create the processing chain of coding hybrid indicator values, create the PHICH, and map it to a resource grid.

Set up the cell-wide settings. Create a structure and specify the cell-wide settings as its fields.

```enb.NDLRB = 9; enb.CyclicPrefix = 'Normal'; enb.PHICHDuration = 'Normal'; enb.Ng = 'Sixth'; enb.CellRefP = 4; enb.NCellID = 1; enb.NSubframe = 0; enb.DuplexMode = 'FDD';```

Many of the functions used in this example require a subset of the preceding settings specified.

Use `ltePHICHInfo` to generate PHICH resource information.

`phichInfo = ltePHICHInfo(enb);`

The function returns `phichInfo`, a structure containing the relevant data required to define PHICH sets. The elements and values of the structure are:

`$\begin{array}{|llc|}\hline Structure\phantom{\rule{0.5em}{0ex}}Element& \begin{array}{l}Description\end{array}& Value\\ NREG& \begin{array}{l}Number\phantom{\rule{0.5em}{0ex}}of\phantom{\rule{0.5em}{0ex}}resource\phantom{\rule{0.5em}{0ex}}element\phantom{\rule{0.5em}{0ex}}groups\phantom{\rule{0.5em}{0ex}}used\phantom{\rule{0.5em}{0ex}}to\phantom{\rule{0.5em}{0ex}}map\phantom{\rule{0.5em}{0ex}}the\phantom{\rule{0.5em}{0ex}}PHICHs.\end{array}& 3\\ NRE& \begin{array}{l}Number\phantom{\rule{0.5em}{0ex}}of\phantom{\rule{0.5em}{0ex}}resource\phantom{\rule{0.5em}{0ex}}elements\phantom{\rule{0.5em}{0ex}}used\phantom{\rule{0.5em}{0ex}}to\phantom{\rule{0.5em}{0ex}}map\phantom{\rule{0.5em}{0ex}}the\phantom{\rule{0.5em}{0ex}}PHICHs.\end{array}& 12\\ NPHICH& \begin{array}{l}Maximum\phantom{\rule{0.5em}{0ex}}number\phantom{\rule{0.5em}{0ex}}of\phantom{\rule{0.5em}{0ex}}PHICH\phantom{\rule{0.5em}{0ex}}that\phantom{\rule{0.5em}{0ex}}can\phantom{\rule{0.5em}{0ex}}be\phantom{\rule{0.5em}{0ex}}used.\end{array}& 8\\ NGroups& \begin{array}{l}Maximum\phantom{\rule{0.5em}{0ex}}number\phantom{\rule{0.5em}{0ex}}of\phantom{\rule{0.5em}{0ex}}PHICH\phantom{\rule{0.5em}{0ex}}groups\phantom{\rule{0.5em}{0ex}}that\phantom{\rule{0.5em}{0ex}}can\phantom{\rule{0.5em}{0ex}}be\phantom{\rule{0.5em}{0ex}}used.\end{array}& 1\\ NMappingUnits& \begin{array}{l}Number\phantom{\rule{0.5em}{0ex}}of\phantom{\rule{0.5em}{0ex}}PHICH\phantom{\rule{0.5em}{0ex}}mapping\phantom{\rule{0.5em}{0ex}}units\phantom{\rule{0.5em}{0ex}}used\phantom{\rule{0.5em}{0ex}}to\phantom{\rule{0.5em}{0ex}}map\phantom{\rule{0.5em}{0ex}}the\\ maximum\phantom{\rule{0.5em}{0ex}}number\phantom{\rule{0.5em}{0ex}}of\phantom{\rule{0.5em}{0ex}}PHICH\phantom{\rule{0.5em}{0ex}}groups.\end{array}& 1\\ NSequences& \begin{array}{l}Maximum\phantom{\rule{0.5em}{0ex}}number\phantom{\rule{0.5em}{0ex}}of\phantom{\rule{0.5em}{0ex}}orthogonal\phantom{\rule{0.5em}{0ex}}sequences\phantom{\rule{0.5em}{0ex}}that\phantom{\rule{0.5em}{0ex}}can\\ be\phantom{\rule{0.5em}{0ex}}used\phantom{\rule{0.5em}{0ex}}within\phantom{\rule{0.5em}{0ex}}each\phantom{\rule{0.5em}{0ex}}group.\end{array}& 8\\ PHICHDuration& \begin{array}{l}Number\phantom{\rule{0.5em}{0ex}}of\phantom{\rule{0.5em}{0ex}}OFDM\phantom{\rule{0.5em}{0ex}}symbols\phantom{\rule{0.5em}{0ex}}used\phantom{\rule{0.5em}{0ex}}to\phantom{\rule{0.5em}{0ex}}map\phantom{\rule{0.5em}{0ex}}the\phantom{\rule{0.5em}{0ex}}PHICH.\end{array}& 1\\ \hline\end{array}$`

Generate the HARQ indicator (HI) set. An HI set consists of a HARQ indicator value, 1 for ACK and 0 for NACK, and a PHICH index pair that contains the PHICH group index, $\left({n}_{PHICH}^{group}\right)$, and the orthogonal sequence index, $\left({n}_{PHICH}^{seq}\right)$, for the PHICH containing HI. The values of $\left({n}_{PHICH}^{group}\right)$ and $\left({n}_{PHICH}^{seq}\right)$ can be determined using the PHICH resource dimension information returned by `ltePHICHInfo`. The number of groups determines acceptable values of the PHICH group index and the number of sequences determines acceptable values of sequence indexes.

`HISet = [ [0 0 1]; [0 1 0]; [0 4 0]; [0 7 1]; ];`

In this example, you create one PHICH group containing four PHICHs with the indices:

`$\begin{array}{|ccl|}\hline PHICH\phantom{\rule{0.5em}{0ex}}Group\phantom{\rule{0.5em}{0ex}}Index& PHICH\phantom{\rule{0.5em}{0ex}}Sequence\phantom{\rule{0.5em}{0ex}}Index& HARQ\phantom{\rule{0.5em}{0ex}}Indicator\phantom{\rule{0.5em}{0ex}}Value\\ 0& 0& 1\phantom{\rule{0.5em}{0ex}}-\phantom{\rule{0.5em}{0ex}}ACK\\ 0& 1& 0\phantom{\rule{0.5em}{0ex}}-\phantom{\rule{0.5em}{0ex}}NACK\\ 0& 4& 0\phantom{\rule{0.5em}{0ex}}-\phantom{\rule{0.5em}{0ex}}NACK\\ 0& 7& 1\phantom{\rule{0.5em}{0ex}}-\phantom{\rule{0.5em}{0ex}}ACK\\ \hline\end{array}$`

In the LTE Toolbox™, a HI set matrix is used to define the HI and PHICH index pair for each HI within the subframe. The HI set matrix defines a single PHICH in terms of $\left({n}_{PHICH}^{group}\phantom{\rule{0.5em}{0ex}}{n}_{PHICH}^{group}\phantom{\rule{0.5em}{0ex}}HARQIndicator\right)$.

Generate the PHICH complex symbols. You generate them from the eNodeB configuration and HARQ indicator matrix. Call the function `ltePHICH` to perform the channel coding, modulation, scrambling, layer mapping, precoding, and combining of the PHICH groups.

```phichSymbols = ltePHICH(enb,HISet); size(phichSymbols)```
```ans = 1×2 12 4 ```

The resulting vector, `phichSymbols`, has 12 rows and 4 columns. Each column contains the complex symbols to be mapped to the resource grids for each of the four antenna ports.

Use `ltePHICHIndices` to generate the PHICH mapping indices. These mapping indices are required to map the complex PHICH symbols to the subframe resource grid.

`phichIndices = ltePHICHIndices(enb)`
```phichIndices = 12x4 uint32 matrix 13 1525 3037 4549 15 1527 3039 4551 16 1528 3040 4552 18 1530 3042 4554 43 1555 3067 4579 45 1557 3069 4581 46 1558 3070 4582 48 1560 3072 4584 79 1591 3103 4615 81 1593 3105 4617 ⋮ ```
`size(phichIndices)`
```ans = 1×2 12 4 ```

This function returns a matrix with 4 columns, one column for each antenna port. The rows contain the indices in linear form for mapping the PHICH symbols to the subframe resource grid.

Use `lteDLResourceGrid` to generate a subframe resource grid. This function creates an empty resource grid for one subframe.

```subframe = lteDLResourceGrid(enb); size(subframe)```
```ans = 1×3 108 14 4 ```

Map the complex PHICH symbols to the resource grid by assigning `phichSymbols` to the `phichIndices` locations in `subframe`.

`subframe(phichIndices) = phichSymbols;`