Calculate and append cyclic redundancy check (CRC)
applies a logical difference (XOR) mask on the appended CRC bits with the integral value of
blkcrc = nrCRCEncode(
mask. The appended CRC bits in
XOR-masked with the most significant bit (MSB) first to the least significant bit (LSB)
last. The masked CRC is of the form (
L is the number of parity bits, and
m0 are the MSBs in the binary
representation of CRC and
mask, respectively. If the mask value is
greater than 2
L - 1, the
L LSBs are considered for the mask.
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 specified
mask, 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
blk— Input data
Input data, specified as a matrix of real numbers. Each column of the matrix is treated as a separate data block.
poly— CRC polynomial
CRC polynomial, specified as
'24C'. For details on the associated polynomials, see TS 38.212
mask— XOR mask
0(default) | nonnegative integer
XOR mask, specified as a nonnegative integer. The mask is typically a radio network temporary identifier (RNTI).
blkcrc— CRC encoded data
CRC encoded data, returned as a matrix of real numbers.
is a copy of the input
blk with the CRC parity bits appended. Each
column corresponds to a separate CRC encoded code block.
inherits its data type from the input
 3GPP TS 38.212. “NR; Multiplexing and channel coding.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.