Main Content

lteCRCEncode

Cyclic redundancy check calculation and appending

Description

blkcrc = lteCRCEncode(blk,poly) calculates a cyclic redundancy check (CRC) for the input data vector and returns a copy of the vector with the CRC attached. To support the correct processing of filler bits, negative input bit values are interpreted as logical 0 for the purposes of the CRC calculation. A value of –1 is used to represent filler bits. lteCRCEncode calculates the CRC defined by poly for the input bit vector blk and returns a copy of the input with the CRC appended in vector blkcrc. Valid options for the CRC polynomial are '8', '16', '24A', or '24B'. See TS 36.212 [1], Section 5.1.1 for the associated polynomials.

example

blkcrc = lteCRCEncode(blk,poly,mask) XOR masks the appended CRC bits with the integral value of mask. The mask value is applied to the CRC bits with the most significant bit (MSB) first and the least significant bit (LSB) last.

example

Examples

collapse all

Calculate and append the CRC associated with an all zero vector, which is also zero.

crc1 = lteCRCEncode(zeros(100,1),'24A');
crc1(1:10)
ans = 10x1 int8 column vector

   0
   0
   0
   0
   0
   0
   0
   0
   0
   0

The result is an all-zeros vector of length 124.

Mask the CRC bits in an MSB-first order.

Set the XOR mask to 1 to make the appended CRC bits XOR masked from the most significant to least significant bit.

mask = 1;
crc2 = lteCRCEncode(zeros(100,1),'24A',mask);
crc2(end-10:end)
ans = 11x1 int8 column vector

   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
      ⋮

The result is all zeros, except for a single one in last element position.

Input Arguments

collapse all

Data bit vector, specified as a numeric column vector.

CRC polynomial, specified as '8', '16', '24A', or '24B'. See TS 36.212 [1], Section 5.1.1 for the associated polynomials.

XOR mask, specified as an integer. The appended CRC bits are XOR masked from the most significant to least significant bit.

Output Arguments

collapse all

Bit vector with CRC, returned as a column vector.

Data Types: int8

References

[1] 3GPP TS 36.212. “Evolved Universal Terrestrial Radio Access (E-UTRA); Multiplexing and channel coding.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network. URL: http://www.3gpp.org.

Version History

Introduced in R2014a