This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Convolutionally encode binary data with GPU


The GPU ConvolutionalEncoder object encodes a sequence of binary input vectors to produce a sequence of binary output vectors.


To use this object, you must install a Parallel Computing Toolbox™ license and have access to an appropriate GPU. For more about GPUs, see GPU Computing (Parallel Computing Toolbox).

A GPU-based System object™ accepts typical MATLAB® arrays or objects that you create using the gpuArray class as an input. GPU-based System objects support input signals with double- or single-precision data types. The output signal inherits its datatype from the input signal.

  • If the input signal is a MATLAB array, then the output signal is also a MATLAB array. In this case, the System object handles data transfer between the CPU and GPU.

  • If the input signal is a gpuArray, then the output signal is also a gpuArray. In this case, the data remains on the GPU. Therefore, when the object is given a gpuArray, calculations take place entirely on the GPU and no data transfer occurs. Passing gpuArray arguments provides increased performance by reducing simulation time. For more information, see Establish Arrays on a GPU (Parallel Computing Toolbox).

To convolutionally encode a binary signal:

  1. Define and set up your convolutional encoder object. See Construction.

  2. Call step to encode a sequence of binary input vectors to produce a sequence of binary output vectors according to the properties of comm.gpu.ConvolutionalEncoder. The behavior of step is specific to each object in the toolbox.


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.


H = comm.gpu.ConvolutionalEncoder creates a System object, H, that convolutionally encodes binary data.

H = comm.gpu.ConvolutionalEncoder(Name,Value) creates a convolutional encoder 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.gpu.ConvolutionalEncoder(TRELLIS,Name,Value) creates a convolutional encoder object, H. This object has the TrellisStructure property set to TRELLIS, and the other specified properties set to the specified values.



Trellis structure of convolutional code

Specify the trellis as a MATLAB structure that contains the trellis description of the convolutional code. The default is the result of poly2trellis(7, [171 133]). Use the istrellis function to check if a structure is a valid trellis structure.


Termination method of encoded frame

Specify how the encoded frame is terminated as one of Continuous | Truncated | Terminated. The default is Continuous.

When you set this property to Continuous, the object retains the encoder states at the end of each input vector for use with the next input vector.

When you set this property to Truncated, the object treats each input vector independently and resets its states to the all-zeros state.

When you set this property to Terminated, the object treats each input vector independently. For each input vector, the object uses extra bits to set the encoder states to the all-zeros state at the end of the vector. For a rate K/N code, the step method outputs a vector with length N×(L+S)K, where S = constraintLength–1. In the case of multiple constraint lengths, S = sum(constraintLength(i)–1)). L is the length of the input to the step method.


Enable encoder reset input

You cannot reset this encoder object using an input port. The only valid property setting is false.


Delay output reset

You cannot reset this encoder object using an input port. The only valid property setting is false.


You cannot set the initial state of this encoder object. The only valid property setting is false.


You cannot output the final state of this encoder object. The only valid property setting is false.


Source of puncture pattern

Specify the source of the puncture pattern as one of None | Property. The default is None. When you set this property to None the object does not apply puncturing. When you set this property to Property, the object punctures the code. This puncturing is based on the puncture pattern vector that you specify in the PuncturePattern property. This property applies when you set the TerminationMethod property to Continuous or Truncated.


Puncture pattern vector

Specify the puncture pattern that the object uses to puncture the encoded data as a column vector. The default is [1; 1; 0; 1; 0; 1]. The vector contains 1s and 0s, where 0 indicates a punctured, or excluded, bit. This property applies when you set the TerminationMethod property to Continuous or Truncated and the PuncturePatternSource property to Property.


Number of independent frames present in the input and output data vectors.

Specify the number of independent frames contained in a single data input/output vector. The default value of this property is 1. The objects segments the input vector into NumFrames segments and encodes them independently. The output contains NumFrames encoded segments. This property is applicable when you set the TerminationMethod to Terminated or Truncated.


resetReset states of the convolutional encoder object
stepConvolutionally encode binary data
Common to All System Objects

Allow System object property value changes


expand all

Transmit a Convolutionally Encoded, 8-PSK-Modulated Bit Stream Through an AWGN Channel.

Create a GPU-based Convolutional Encoder System object.

hConEnc = comm.gpu.ConvolutionalEncoder;

Create a GPU-based PSK Modulator System object that accepts a bit input signal.

hMod = comm.gpu.PSKModulator('BitInput',true);

Create a GPU-based AWGN Channel System object with a signal-to-noise ratio of seven.

hChan = comm.gpu.AWGNChannel('NoiseMethod', ...
         'Signal to noise ratio (SNR)',...

Create a GPU-based PSK Demodulator System object that outputs a column vector of bit values.

hDemod = comm.gpu.PSKDemodulator('BitOutput',true);

Create a GPU-based Viterbi Decoder System object that accepts an input vector of hard decision values, which are zeros or ones.

hDec = comm.gpu.ViterbiDecoder('InputFormat','Hard');

Create an Error Rate System object that ignores 3 data samples before makings comparisons. The received data lags behind the transmitted data by 34 samples.

hError = comm.ErrorRate('ComputationDelay',3,'ReceiveDelay', 34);

Run the simulation by using the step method to process data.

for counter = 1:20
  data = randi([0 1],30,1);
  encodedData = step(hConEnc, gpuArray(data));
  modSignal = step(hMod, encodedData);
  receivedSignal = step(hChan, modSignal);
  demodSignal = step(hDemod, receivedSignal);
  receivedBits = step(hDec, demodSignal);
  errors = step(hError, data, gather(receivedBits));

Display the errors.



This object implements the algorithm, inputs, and outputs described on the Convolutional Encoder block reference page. The object properties correspond to the block parameters.

Extended Capabilities

Introduced in R2012a