Documentation

nrCRCEncode

Calculate and append cyclic redundancy check (CRC)

Description

example

blkcrc= nrCRCEncode(blk,poly)calculates the CRC defined by the polynomialpolyfor the input datablk. The function returns the CRC encoded data, which is a copy of the input data with the CRC parity bits appended. For details on the associated polynomials, see TS 38.212 Section 5.1[1].

example

blkcrc= nrCRCEncode(blk,poly,mask)applies a logical difference (XOR) mask on the appended CRC bits with the integral value ofmask. The appended CRC bits inblkcrcare XOR-masked with the most significant bit (MSB) first to the least significant bit (LSB) last. The masked CRC is of the form (p0xorm0), (p1xorm1),…, (pL-1xormL-1), whereLis the number of parity bits, andp0andm0are the MSBs in the binary representation of CRC andmask, respectively. If the mask value is greater than 2L- 1, theLLSBs are considered for the mask.

Examples

collapse all

Calculate and append CRC parity bits to an all-zeros matrix of two data blocks. The result is an all-zeros matrix of size 124-by-2.

blkcrc = nrCRCEncode(zeros(100,2),'24C'); any(blkcrc(:,1:2));

Calculate and append masked CRC parity bits to an all-zeros matrix of two data blocks. The appended CRC bits are XOR-masked with the specifiedmask, from the MSB first to the LSB last. The result is an all-zeros matrix apart from the elements in the last position.

mask = 1; blkcrc = nrCRCEncode(zeros(100,2),'24C',mask); blkcrc(end-5:end,1:2);
ans = 0 0 0 0 0 0 0 0 0 0 1 1

Input Arguments

collapse all

输入数据,指定为一个马trix of real numbers. Each column of the matrix is treated as a separate 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 encoded data, returned as a matrix of real numbers.blkcrcis a copy of the inputblkwith the CRC parity bits appended. Each column corresponds to a separate CRC encoded code block.blkcrcinherits its data type from the inputblk.

Data Types:double|int8|logical

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™.

Introduced in R2018b