Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

step

System object: comm.HDLRSEncoder
Package: comm

Perform Reed-Solomon encoding

Syntax

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

Description

Note

Starting in R2016b, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.

[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, one symbol at a time.

The wordlength of each symbol must be ceil(log2(CodewordLength+1)). It can be an integer type (uint8, uint16, uint32) or fixed-point (fi). Input data of double type is supported 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.

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

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.

Note: This object syntax runs only in R2016b or later. If you are using an earlier release, replace each call of an object with the equivalent step syntax. For example, replace myObject(x) with step(myObject,x).

for ii = 1:1024
  [encOut(ii),startOut(ii),endOut(ii),validOut(ii)] = ...
      hHDLEnc(dataIn(ii),ii==1,ii==188,ii<=188);
  [decOut(ii),decStartOut(ii),decEndOut(ii),decValidOut(ii),decErrOut(ii)] = ...
      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?