Main Content

nrCRCDecode

Decode and remove cyclic redundancy check (CRC)

Description

example

[blk,err] = nrCRCDecode(blkcrc,poly) checks the input data blkcrc for a CRC error. The function assumes that the input data comprises the CRC parity bits associated with the polynomial poly. The function returns blk, which is the data part of the input blkcrc. The function also returns err, which is the logical difference (XOR) between the CRC comprised in the input and the CRC recalculated across the data part of the input. If err is not equal to 0, either an error has occurred or the input CRC has been masked. For details on the associated polynomials, see TS 38.212 Section 5.1 [1].

example

[blk,err] = nrCRCDecode(blkcrc,poly,mask) XOR-masks the CRC difference with mask before returning it in err. The mask value is applied to the CRC difference with the most significant bit (MSB) first to the least significant bit (LSB) last.

Examples

collapse all

Check the effect of CRC decoding with and without a mask.

Define a mask corresponding to the radio network temporary identifier (RNTI) equal to 12. Append RNTI-masked CRC parity bits to an all-ones matrix of one data block.

rnti = 12;
blkCrc = nrCRCEncode(ones(100,1),'24C',rnti);

When you perform CRC decoding without a mask, err1 is equal to the RNTI because the CRC was masked during coding. The logical difference between the original CRC and the recalculated CRC is the CRC mask.

[blk,err1] = nrCRCDecode(blkCrc,'24C');
err1
err1 = uint32
    12

When you perform CRC decoding using the RNTI value as a mask, err is equal to 0.

[blk,err2] = nrCRCDecode(blkCrc,'24C',err1);
err2
err2 = uint32
    0

Input Arguments

collapse all

CRC encoded data, specified as a matrix of real numbers. Each column of the matrix is considered as a separate CRC encoded data block.

Data Types: double | int8 | logical

CRC polynomial, specified as '6', '11', '16', '24A', '24B', or '24C'. For details on the associated polynomials, see TS 38.212 Section 5.1.

Data Types: char | string

XOR mask, specified as a nonnegative integer. The mask is typically a radio network temporary identifier (RNTI).

Data Types: double

Output Arguments

collapse all

CRC decoded data, returned as a matrix of real numbers. blk is the data-only part of the input blkcrc.

Data Types: double | int8 | logical

Logical CRC difference, returned as an integer. err is the logical difference between the CRC comprised in the input blkcrc and the CRC recalculated across the data part of the input. If a mask is specified, the function XOR-masks err with mask before returning it.

Data Types: uint32

References

[1] 3GPP TS 38.212. “NR; Multiplexing and channel coding.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2018b