

HARQ ACK CodebookThis is one of the complicated topics (at least to me) in 5G/NR Physical Layer Process (38.213) and what is described here would remain messy without clear big picture for a while until I myself get clear understanding on this process. Before we go into the details, I think the description from TR 38.912  8.2.2.2 HARQ would help you to get some big picture.
ParametersCodebook determination algorithm itself is defined in 38.213, but there are many parameters that controls the algorithm. Since they use a little bit different name for the same parameters between 38.213 and 38.331, I thought it would be helpful to make a mapping table for these parameters.
Determining the number of bits for HARQ ACK/NACKIn LTE, the number of HARQ bits is determined by relatively simple factors like the number of transport block(number of Codeword) and number of carriers. In general, UE assigns 1 bits per one transport block. For example, for 4x4 MIMO or higher, a cell use two transport blocks (two code words). In case of carrier aggregation assuming that each carrier is using 4x4 MIMO or higher, the total number of HARQ bits is 2 x number of CCs(The only exception is the case of PUCCH format1b, but I wouldn't go too much for LTE case here). In NR, this kind of simple method is used for a specific settings, but there are various other cases as summarized below. LTE HARQ Bit length determination is same as Case 2 below. This summary is based on 38.213  9.1. Condition : PDSCH is received without corresponding PDCCH or PDCCH indcating a SPS PDSCH release
Number of HARQ Bit : 1 bit
Condition : PDSCHCodeblockGroupTransmission = Not Configured AND PDSCH with DCI 1_1
Number of HARQ Bit : 1 bit per TB (Transport Block)
Condition : PDSCH with DCI 1_0 or SPS PDSCH or SPS PDSCH release
Number of HARQ Bits : HARQ Ack only for the PDSCH or only for the SPS
Condition : PDSCHCodeblockGroupTransmission = Configured
Number of HARQ Bits : 1 bit per CBG(Codeblock Group). In this case, Usually 1 TB carries multiple CBG, so multiple bits are allocated for one TB.
Condition : HARQACKcodebook=semistatic
Number of HARQ Bits : Determined by Type 1 HARQACK codebook determination algorithm
Condition : HARQACKcodebook=dynamic
Number of HARQ Bits : Determined by Type 2 HARQACK codebook determination algorithm Codebook Determination Type / AlgorithmThere two different types of Codebook determination algorithm called Type 1 and Type 2. Each of these types are again divided into two cases depending on whether the HARQ ACK is reported in PUCCH or PUSCH. Which types of algorithm to use is determined by a couple of RRC parameters. The Codebook determination algorithm type and the RRC parameters determining the type can be summarized as follows :
Reference[1]

