Documentation

step

System object: comm.HDLRSEncoder
Package: comm

Perform Reed-Solomon encoding

Syntax

[Y,startOut,endOut,validOut] = step(H,X,startIn,EndIn,validIn)

Description

[Y,startOut,endOut,validOut] = step(H,X,startIn,EndIn,validIn) decodes the input data, X, and returns the encoded data, Y, of HDLRSEncoder System object™, H.

The step method for this object accepts fixed-point (fi) inputs for X.

    Note:   Calling step on an object puts that object into a locked state. When locked, you cannot change nontunable properties or any input characteristics (size, data type and complexity) without reinitializing (unlocking and relocking) the object.

Input Arguments

H

Instance of HDLRSEncoder System object

X

Message data

Must be an integer (uint8, uint16, uint32) or fi(). Doubles are allowed for simulation but not for HDL code generation.

startIn

Indicates the start of a frame of data. Boolean value.

endIn

Indicates the end of a frame of data. Boolean value.

validIn

Indicates that input data is valid. Boolean value.

Output Arguments

Y

Message data followed by parity words

The data type is the same as the input data port. Will be an integer (uint8, uint16, uint32) or fi(). Doubles are allowed for simulation but not for HDL code generation.

startOut

Indicates the start of a frame of data. Boolean value.

endOut

Indicates the end of a frame of data, including checksum. Boolean value.

validOut

Indicates that output data is valid. Boolean value.

Examples

expand all

Encode and Decode a DVD-II Packet

This example shows Reed-Solomon encoding and decoding of a standard DVD-II packet of random data.

Create System objects to encode and decode the data. The first two constructor arguments set the CodewordLength and MessageLength properties. The remaining arguments use Name,Value notation to set the starting power, B, of the roots of the primitive polynomial, to 0.

hHDLEnc = comm.HDLRSEncoder(204,188,'BSource','Property','B',0);
hHDLDec = comm.HDLRSDecoder(204,188,'BSource','Property','B',0);

Create a random data packet. Pad the data with zeros to account for the decoding latency. Also, preallocate the output vectors.

dataIn = [randi([0,255],188,1,'uint8') ; zeros(1024-188,1)];
[encOut,decOut] = deal(zeros(1024,1));
[startOut,endOut,validOut] = deal(false(1024,1));
[decStartOut,decEndOut,decValidOut,decErrOut] = deal(false(1024,1));

Stream the packet, one sample at a time, through the encoder and decoder objects. The step arguments include control signals that indicate the start and end of the data packet.

for ii = 1:1024
  [encOut(ii),startOut(ii),endOut(ii),validOut(ii)] = ...
      step(hHDLEnc,dataIn(ii),ii==1,ii==188,ii<=188);
  [decOut(ii),decStartOut(ii),decEndOut(ii),decValidOut(ii),decErrOut(ii)] = ...
      step(hHDLDec,encOut(ii),startOut(ii),endOut(ii),validOut(ii));
end

Check that the message was decoded correctly.

assert(all(dataIn(1:188) == decOut(decValidOut)))
Was this topic helpful?