Documentation |
Package: comm
Decode data using Reed-Solomon decoder
The RSDecoder object recovers a message vector from a Reed-Solomon codeword vector. For proper decoding, the property values for this object should match those in the corresponding RS Encoder object.
To decode data using a Reed-Solomon decoding scheme:
Define and set up your Reed-Solomon decoder object. See Construction.
Call step to decode data according to the properties of comm.RSDecoder. The behavior of step is specific to each object in the toolbox.
H = comm.RSDecoder creates a block decoder System object™, H. This object performs Reed-Solomon (RS) decoding.
H = comm.RSDecoder(Name,Value) creates an RS decoder object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).
H = comm.RSDecoder(N,K,Name,Value) creates an RS decoder object, H. This object has the CodewordLength property set to N, the MessageLength property set to N, and the other specified properties set to the specified values.
BitInput |
Assume input is bits Specify whether the input comprises bits or integers. The default is false. When you set this property to false, the step method input data value must be a numeric, column vector of integers. The length of this vector must equal an integer multiple of (CodewordLength – number of punctures). You specify the number of punctures with the PuncturePatternSource and PuncturePattern properties. The CodewordLength property stores the codeword length value. The decoded data output result is a column vector of integers. The length of this vector equals an integer multiple of the message length you specify in the MessageLength property. Each symbol that forms the input codewords and output message is an integer between 0 and 2^{M}–1. These integers correspond to an element of the finite Galois field GF(2^{M}). M is the degree of the primitive polynomial that you specify with the PrimitivePolynomialSource and PrimitivePolynomial properties. When you set this property to true, the input encoded data value must be a numeric column vector of bits. The length equal to an integer multiple of (CodewordLength – number of punctures)$$\times $$M. You specify the number of punctures with PuncturePatternSource and PuncturePattern properties. The decoded data output result is a column vector of bits. The length equals an integer multiple of MessageLength$$\times $$M. A group of M bits represents an integer between 0 and 2^{M}–1 that belongs to the finite Galois field GF(2^{M}). M is the degree of the primitive polynomial that you specify with the PrimitivePolynomialSource and PrimitivePolynomial properties. When you set BitInput to false and ErasuresInputPort to true, the erasures input, ERASURES, must be set to a length equal to the encoded data input vector. Values of 1 in the ERASURES vector correspond to erased symbols in the same position as the input codewords, and values of 0 correspond to nonerased symbols. When you set this property to true and ErasuresInputPort to true, ERASURES, requires a length of 1/M times the length of the input encoded data vector. M corresponds to the degree of the primitive polynomial. Values of 1 in the ERASURES vector correspond to erased symbols and values of 0 correspond to nonerased symbols. In this case, a symbol corresponds to M bits. |
CodewordLength |
Codeword length Specify the codeword length of the RS code as a double-precision, positive, integer scalar value. The default is 7. If you set the PrimitivePolynomialSource property to Auto, CodewordLength must be in the range 7$$<$$< CodewordLength $$\le $$2^{16}–1. If you set the PrimitivePolynomialSource property to Property, CodewordLength must be in the range 7$$\le $$ CodewordLength $$\le $$2^{M}–1. M is the degree of the primitive polynomial that you specify with the PrimitivePolynomialSource and PrimitivePolynomial properties. M must be in the range 3$$\le $$M $$\le $$16. For a full-length RS code the value of the CodewordLength property requires the form 2^{M}–1. If this property is less than 2^{M}–1, the object assumes a shortened RS code. |
MessageLength |
Message length Specify the message length as a double-precision, positive, integer scalar value. The default is 3. |
PrimitivePolynomialSource |
Source of primitive polynomial Specify the source of the primitive polynomial as Auto | Property. The default is Auto. When you set this property to Auto, the object uses a primitive polynomial of degree M = ceil(log2(CodewordLength+1)), which is the result of fliplr(de2bi(primpoly(M))). When you set this property to Property you specify a polynomial using the PrimitivePolynomial property. |
PrimitivePolynomial |
Primitive polynomial Specify the primitive polynomial that defines the finite field GF(2^{M}) corresponding to the integers that form messages and codewords. The default is the result of fliplr(de2bi(primpoly(3))), which is [1 0 1 1] or the polynomial $${x}^{3}+x+1$$. You must set this property to a double-precision, binary, row vector that represents a primitive polynomial over GF(2) of degree M in descending order of powers. If CodewordLength is less than 2^{M}–1, the object uses a shortened RS code. This property applies when you set the PrimitivePolynomialSource property to Property. |
GeneratorPolynomialSource |
Source of generator polynomial Specify the source of the generator polynomial as Auto | Property. The default is Auto. When you set this property to Auto, the object automatically chooses the generator polynomial. The object calculates the generator polynomial based on the value of the PrimitivePolynomialSource property. When you set the PrimitivePolynomialSource property to Auto the object calculates the generator polynomial as rsgenpoly(CodewordLength+SL,MessageLength+SL). When you set the PrimitivePolynomialSource property to Property, the object calculates generator polynomial as rsgenpoly(CodewordLength+SL,MessageLength+SL, PrimitivePolynomial). In both cases, SL = (2^{M}–1) –CodewordLength is the shortened length, and M is the degree of the primitive polynomial that you specify with the PrimitivePolynomialSource and PrimitivePolynomial properties. When you set this property to Property, you can specify a generator polynomial using this property. |
GeneratorPolynomial |
Generator polynomial Specify the generator polynomial for the RS code as a double-precision, integer row vector or as a Galois field row vector whose entries are in the range from 0 to 2^{M}-1 and represent a generator polynomial in descending order of powers. The length of the generator polynomial must be CodewordLength-MessageLength+1. This property applies when you set the GeneratorPolynomialSource property to Property. The default is the result of rsgenpoly(7,3,[],[],'double'), which corresponds to [1 3 1 2 3]. When you use this object to generate code, you must set the generator polynomial to a double-precision, integer row vector. |
CheckGeneratorPolynomial |
Enable generator polynomial checking Set this property to true to perform a generator polynomial check. The default is true. This check verifies that $$\times $$^{CodewordLength} + 1 is divisible by the generator polynomial you specify in the GeneratorPolynomial property. For larger codes, disabling the check accelerates processing time. You should perform the check at least once before setting this property to false. This property applies when you set the GeneratorPolynomialSource property to Property. |
PuncturePatternSource |
Source of puncture pattern Specify the source of the puncture pattern as None | Property. The default is None. If you set this property to None then the object does not apply puncturing to the code. If you set this property to Property then the object punctures the code based on a puncture pattern vector specified in the PuncturePattern property. |
PuncturePattern |
Puncture pattern vector Specify the pattern used to puncture the encoded data as a double-precision, binary column vector of length (CodewordLength-MessageLength). The default is [ones(2,1); zeros(2,1)]. Zeros in the puncture pattern vector indicate the position of the parity symbols that are punctured or excluded from each codeword. This property applies when you set the PuncturePatternSource property to Property. |
ErasuresInputPort |
Enable erasures input Set this property to true to specify a vector of erasures as an input to the step method. The default is false. The erasures input must be a double-precision or logical binary column vector that indicates which symbols of the input codewords to erase. When you set BitInput to true, the erasures vector length must equal 1/M times the length of the input encoded data vector, where M corresponds to the degree of the primitive polynomial. Values of 1 in the erasures vector correspond to erased symbols in the same position of the bit-packed input codewords. Values of 0 correspond to nonerased symbols. When you set BitInput to false, the erasures vector length must equal the input encoded data vector. Values of 1 in the erasures vector correspond to erased symbols in the same position of the input codewords. Values of 0 correspond to nonerased symbols. When this property is set to false the object assumes no erasures. |
NumCorrectedErrorsOutputPort |
Enable number of corrected errors output Set this property to true to obtain the number of corrected errors as an output to the step method. The default is true. A nonnegative value in the i-th element of the error output vector, denotes the number of corrected errors in the i-th input codeword. A value of -1 in the i-th element of the error output vector indicates that a decoding error occurred for that codeword. A decoding error occurs when an input codeword has more errors than the error correction capability of the RS code. |
OutputDataType |
Data type of output Specify the output data type as Same as input | double | logical. The default is Same as input. This property applies when you set the BitInput property to true. |
clone | Create RS decoder object with same property values |
getNumInputs | Number of expected inputs to step method |
getNumOutputs | Number of outputs from step method |
isLocked | Locked status for input attributes and nontunable properties |
release | Allow property value and input characteristics changes |
step | Decode data using a Reed-Solomon decoder |
Transmit an RS-encoded, 8-DPSK-modulated symbol stream through an AWGN channel. Then, demodulate, decode, and count errors.
hEnc = comm.RSEncoder; hMod = comm.DPSKModulator('BitInput',false); hChan = comm.AWGNChannel(... 'NoiseMethod','Signal to noise ratio (SNR)','SNR',10); hDemod = comm.DPSKDemodulator('BitOutput',false); hDec = comm.RSDecoder; hError = comm.ErrorRate('ComputationDelay',3); for counter = 1:20 data = randi([0 7], 30, 1); encodedData = step(hEnc, data); modSignal = step(hMod, encodedData); receivedSignal = step(hChan, modSignal); demodSignal = step(hDemod, receivedSignal); receivedSymbols = step(hDec, demodSignal); errorStats = step(hError, data, receivedSymbols); end fprintf('Error rate = %f\nNumber of errors = %d\n', ... errorStats(1), errorStats(2))
This object implements the algorithm, inputs, and outputs described on the Binary-Output RS Decoder and Integer-Output RS Decoder block reference pages. The object properties correspond to the block parameters, except:
The BitInput property allows you to select between the Binary-Output RS Decoder and Integer-Output RS Decoder algorithms. |