Main Content


Decode NB-IoT DL-SCH codeword


[trblkout,blkcrc,stateout] = lteNDLSCHDecode(trblklen,cwin) returns the information bits, trblkout, decoded from the input soft LLR codeword data, cwin. The NB-IoT downlink shared channel (DL-SCH) decoder includes rate recovery, Viterbi decoding, and CRC calculations. The function also returns the type-24A transport block CRC decoding result in blkcrc and the HARQ process decoding state in stateout.


[trblkout,blkcrc,stateout] = lteNDLSCHDecode(trblklen,cwin,statein)specifies the initial HARQ process state in the statein structure. The initial transmission and the re-transmission are both bundles containing multiple subframes, defined in Section of [1].


collapse all

This example shows how to transmit a bundle carrying the same transport block twice. The LLR soft bits from repeated subframes in a bundle are combined in structure dstate, the LLR soft bits from two bundles are combined in structure state. Note that dstate is reset before the re-transmission of the bundle.

Specify the cell-wide settings and channel transmission configuration in parameter structures enb and chs.

enb.NNCellID = 0;
enb.NBRefP = 1;
enb.NFrame = 1;
chs.NSF = 3;
chs.NRep = 4;
chs.RNTI = 0;
chs.NPDSCHDataType = 'NotBCCH';

Set the transport block length to 208 and the output codeword length to 960. Initialize the decoder states for the first HARQ transmission. Generate transport block data.

trblklen = 208;
outlen = 960;
estate = []; 
dstate = []; 
state = [];
trblkin = randi([0 1],trblklen,1);

Generate the 960 NB-Iot DL-SCH codeword bits.

cw = lteNDLSCH(outlen,trblkin);

Perform the initial transmission of a bundle containing the transport block. Verify if there are errors in the transmission.

for subframeIdx = 0:(chs.NSF*chs.NRep-1)
    enb.NSubframe = subframeIdx;
    [sym,estate] = lteNPDSCH(enb,chs,cw,estate);
    [rxcw, dstate] = lteNPDSCHDecode(enb,chs,sym,dstate);
[trblkout1,blkerr1,state] = lteNDLSCHDecode(trblklen,rxcw,state);
blkerr1 = logical

Perform the re-transmission of the bundle containing the same transport block. The information obtained from the initial bundle transmission is saved in state and used as an input to lteNDLSCHDecode. Verify if there are errors in the re-transmission.

for subframeIdx = chs.NSF*chs.NRep:(2*chs.NSF*chs.NRep-1)
    enb.NSubframe = subframeIdx;
    [sym,estate] = lteNPDSCH(enb,chs,cw,estate);
    [rxcw,dstate] = lteNPDSCHDecode(enb,chs,sym,dstate);
[trblkout2,blkerr2,state] = lteNDLSCHDecode(trblklen,rxcw,state);
blkerr2 = logical

Input Arguments

collapse all

Transport block length, specified as a nonnegative integer. trblklen defines the transport block lengths to which the input code blocks should be rate-recovered and decoded.

Data Types: double

Soft LLR codeword data, specified as a numeric vector. cwin contains the floating-point soft LLR data of the codeword to be decoded.

Data Types: double

Initial HARQ process state, specified as a structure. The structure can be empty or contain this field:

NameValuesDescriptionData Types

Cell array of vectors

LLR soft buffer state associated with a single transport block. The buffer is positioned at the input to the Viterbi decoder after explicit rate recovery.cell

The updated buffer states after decoding are returned in the CBSBuffers field of the stateout output. The statein array is normally generated and recycled from the stateout of previous calls to lteNDLSCHDecode as part of a sequence of HARQ transmissions.

Data Types: struct

Output Arguments

collapse all

Decoded information bits, returned as a numeric vector.

Data Types: int8

Type-24A transport block CRC decoding result, returned as a numeric or logical 1 (true) or 0 (false).

Data Types: logical

HARQ process decoding state, returned as a structure containing the internal state of a transport block in these fields:

Parameter FieldValuesDescriptionData types

Cell array of vectors

LLR soft buffer states for the set of code blocks associated with a single transport block. The buffers are positioned at the input to the Viterbi decoder after explicit rate recovery. cell

true or 1, false or 0

Type-24A transport block CRC decoding errorlogical

Data Types: struct


[1] 3GPP TS 36.321. “Evolved Universal Terrestrial Radio Access (E-UTRA); Medium Access Control (MAC) protocol Specification.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network. URL:

Version History

Introduced in R2018a