Products & Services Solutions Academia Support User Community Company

Learn more about Communications Blockset   

Computing Delays

Section Overview

Some models require you to know how long it takes for data in one portion of a model to influence a signal in another portion of a model. For example, when configuring an error rate calculator, you must indicate the delay between the transmitter and the receiver. If you miscalculate the delay, the error rate calculator processes mismatched pairs of data and consequently returns a meaningless result.

This section illustrates the computation of delays in multirate models and in models where the total delay in a sequence of blocks comprises multiple delays from individual blocks. This section also indicates how to use the Find Delay and Align Signals blocks to help deal with delays in a model.

Other References for Delays

Other parts of this documentation set also discuss delays. For information about dealing with delays or about delays in specific types of blocks, see

For discussions of delays in simpler examples than the ones in this section, see

Sources of Delays

While some blocks can determine their current output value using only the current input value, other blocks need input values from multiple time steps to compute the current output value. In the latter situation, the block incurs a delay. An example of this case is when the Derepeat block must average five samples from a scalar signal. The block must delay computing the average until it has received all five samples.

In general, delays in your model might come from various sources:

The following discussions include some of these sources of delay.

ADSL Demo Model

This section examines the asymmetric digital subscriber line (ADSL) demonstration model and aims to compute the correct Receive delay parameter value in one of the Error Rate Calculation blocks in the model. The model includes delays from convolutional interleaving and an explicit delay block. To open the ADSL demo model, enter commadsl in the MATLAB Command Window.

In the ADSL demo, data follows one of two parallel paths, one with a nonzero delay and the other with a delay of zero. One path includes a convolutional interleaver and deinterleaver, while the other does not. Near the end of each path is an Error Rate Calculation block, whose Receive delay parameter must reflect the delay of the given path. The rest of the discussion makes an observation about frame periods in the model and then considers the path for interleaved data.

Frame Periods in the Model

Before searching for individual delays, first observe that most signal lines throughout the model share the same frame period. To see this, enable the Sample Time Display submenu from the model window's Format menu. This option colors blocks and signals according to their frame periods (or sample periods, in the case of sample-based signals). All signal lines at the top level of the model are the same color, which means that they share the same frame period. As a consequence, frames are a convenient unit for measuring delays in the blocks that process these signals. In the computation of the cumulative delay along a path, the weighted average (of numbers of frames, weighted by each frame's period) reduces to a sum.

Path for Interleaved Data

In the transmitter portion of the model, the interleaved path is the lower branch, shown in yellow below. Similarly, the interleaved path in the receiver portion of the model is the lower branch. Near the end of the interleaved path is an Error Rate Calculation block that computes the value labeled Interleaved BER.

The following table summarizes the delays in the path for noninterleaved data. Subsequent paragraphs explain the delays in more detail and explain why the total delay relative to the Error Rate Calculation block is one frame, or 776 samples.

BlockDelay, in Output Samples from Individual BlockDelay, in FramesDelay, in Input Samples to Error Rate Calculation Block
Convolutional Interleaver and Convolutional Deinterleaver pair 40 1 (combined) 776 (combined)
Delay 800
TotalN/A 1 776

Interleaving.   Unlike the noninterleaved path, the interleaved path contains a Convolutional Interleaver block in the transmitter and a Convolutional Deinterleaver block in the receiver. The delay of the interleaver/deinterleaver pair is the product of the Rows of shift registers parameter, the Register length step parameter, and one less than the Rows of shift registers parameter. In this case, the delay of the interleaver/deinterleaver pair turns out to be 5*2*4 = 40 samples.

Delay Block.   The receiver portion of the interleaved path also contains a Delay block, whose purpose is explained in Aligning Words of a Block Code. This block explicitly causes a delay of 800 samples having the same sample time as the 40 samples of delay from the interleaver/deinterleaver pair. Therefore, the total delay from interleaving, deinterleaving, and the explicit delay is 840 samples. These 840 samples make up one frame of data leaving the Delay block.

Summing the Delays.   No other blocks in the interleaved path of the demo cause any delays. Adding the delays from the interleaver/deinterleaver pair and the Delay block indicates that the total delay in the interleaved path is one frame.

Total Delay Relative to Error Rate Calculation Block.   The Error Rate Calculation block that computes the value labeled Interleaved BER requires a Receive delay parameter value that is equivalent to one frame. The Receive delay parameter is measured in samples and each input frame to the Error Rate Calculation block contains 776 samples. Also, the frame rate at the outports of all delay-causing blocks in the interleaved path equals the frame rate at the input of the Error Rate Calculation block. Therefore, the correct value for the Receive delay parameter is 776 samples.

Punctured Coding Model

This section discusses a punctured coding model that includes delays from decoding, downsampling, and filtering. Two Error Rate Calculation blocks in the model work correctly if and only if their Receive delay parameters accurately reflect the delays in the model. To open the model, enter punctdoc in the MATLAB Command Window.

Frame Periods in the Model

Before searching for individual delays, first enable the Sample Time Display submenu from the model window's Format menu. Only the rightmost portion of the model differs in color from the rest of the model. This means that all signals and blocks in the model except those in the rightmost edge share the same frame period. Consequently, frames at this predominant frame rate are a convenient unit for measuring delays in the blocks that process these signals. In the computation of the cumulative delay along a path, the weighted average (of numbers of frames, weighted by each frame's period) reduces to a sum.

The yellow blocks represent multirate systems, while the AWGN Channel block and the Rx Filter block run at a higher frame rate than most other blocks in the model.

Inner Error Rate Block

The block labeled Inner Error Rate, located near the center of the model, is a copy of the Error Rate Calculation block from the Sinks library. It computes the bit error rate for the portion of the model that excludes the punctured convolutional code. In the portion of the model between this block's two input signals, delays come from the Tx Filter, Rx Filter, and Downsample blocks, as summarized in the following table. This section explains why the Inner Error Rate block's Receive delay parameter is the total delay value of 16.

BlockDelay, in Samples at Individual BlockDelay, in Frames at Predominant Frame RateDelay, in Input Samples to Inner Error Rate Block
Tx Filter3 3/2 6
Rx Filter3 (relative to input of Tx Filter block) 3/2 6
Downsample2 1 4
TotalN/A 4 16

Tx Filter Block.   The block labeled Tx Filter is a copy of the FIR Interpolation block in Signal Processing Blockset™ software. It upsamples the input signal by a factor of 8 and applies a square-root raised cosine filter. The value of the block's FIR filter coefficients parameter is

rcosine(1, 8, 'sqrt', 0.5, 3)

where the ratio 3/1 indicates that the delay caused by the filter is 3 times the sample period (not frame period) of the signal before upsampling. Because the input signal is not upsampled and is a two-sample frame at the model's predominant frame rate, the delay is equivalent to 3/2 frames at the predominant frame rate.

Rx Filter Block.   The block labeled Rx Filter is another copy of the FIR Interpolation block, but it differs from the Tx Filter block in that its Interpolation factor parameter is 1 instead of 8. The values of that parameter differ in the two filter blocks because the Tx Filter block needs to upsample the signal to prepare for transmission along the channel, while the Rx Filter processes a signal that is already upsampled and needs no further upsampling. Thus the Rx Filter block merely applies a square-root raised cosine filter without upsampling its input data. As in the case of the Tx Filter block, the delay caused by the Rx Filter block is three times the sample period (not frame period) of the signal without upsampling. The frame rate without upsampling is just the model's predominant frame rate, so the delay of the Rx Filter block is the same as that of the Tx Filter block. That is, the delay is equivalent to 3/2 frames at the predominant frame rate.

Downsample Block.   The Downsample block reduces the frame rate of the filtered received data. Its delay is one output frame, as stated on the reference page for the Downsample block. Because the frame rate at the outport equals the model's predominant frame rate, the delay of the Downsample block is one frame at the predominant frame rate.

Summing the Delays.   No other blocks in the portion of the model between the Inner Error Rate block's two input signals cause any delays. Adding the two 3/2-frame delays from the two filter blocks with the one-frame delay from the Downsample block indicates that the total delay in this portion of the model is four frames.

Total Delay Relative to Inner Error Rate Block.   The Inner Error Rate block requires a Receive delay parameter value that is equivalent to four frames. The Receive delay parameter is measured in samples and each input frame to the Inner Error Rate block contains four samples. Therefore, the correct value for the Receive delay parameter is 16 samples.

Outer Error Rate Block

The block labeled Outer Error Rate, located at the left of the model, is a copy of the Error Rate Calculation block from the Sinks library. It computes the bit error rate for the entire model, including the punctured convolutional code. Delays come from the Tx Filter, Rx Filter, Downsample, and Viterbi Decoder blocks, as summarized in the table below. This section explains why the Outer Error Rate block's Receive delay parameter is the total delay value of 108.

BlockDelay, in Samples at Individual BlockDelay, in Frames at Predominant Frame RateDelay, in Input Samples to Outer Error Rate Block
Tx Filter3 3/2 9/2
Rx Filter3 (relative to input of Tx Filter block) 3/2 9/2
Downsample2 1 3
Viterbi Decoder 96 32 96
TotalN/A 36 108

Filter and Downsample Blocks.   The Tx Filter, Rx Filter, and Downsample blocks have a combined delay of four frames at the model's predominant frame rate. For details, see Inner Error Rate Block.

Viterbi Decoder Block.   The Viterbi Decoder block decodes the convolutional code, and the algorithm's use of a traceback path causes a delay. The block processes a frame-based signal and has Operation mode set to Continuous. Therefore, the delay, measured in output samples, is equal to the Traceback depth parameter value of 96. (The delay amount is stated on the reference page for the Viterbi Decoder block.) Because the output of the Viterbi Decoder block is precisely one of the inputs to the Outer Error Rate block, it is easier to consider the delay to be 96 samples rather than to convert it to an equivalent number of frames.

Total Delay Relative to Outer Error Rate Block.   The Outer Error Rate block requires a Receive delay parameter value that is equivalent to four frames plus 96 samples. The Receive delay parameter is measured in samples, and each input frame to the Outer Error Rate block contains three samples. Therefore, the correct value for the Receive delay parameter is 4*3+96 = 108 samples.

Using the Find Delay and Align Signals Blocks

The preceding discussions explained why certain Error Rate Calculation blocks in the models had specific Receive delay parameter values. You could have arrived at those numbers independently by using the Find Delay block, or you could have avoided needing to know those numbers by using the Align Signals block. This section explains both techniques using the ADSL demo model, commadsl, as an example. Applying the techniques to the punctured convolutional coding example, discussed in Punctured Coding Model, would be similar.

Using the Find Delay Block to Determine the Correct Receive Delay

Recall from Path for Interleaved Data that the delay in the path for interleaved data is 776 samples. To have the Find Delay block compute that value for you, use this procedure:

  1. Insert a Find Delay block and a Display block in the model near the Error Rate Calculation block that computes the value labeled Interleaved BER.

  2. Connect the blocks as shown below.

  3. Set the Find Delay block's Correlation window length parameter to a value substantially larger than 776, such as 2000.

      Note   You must use a sufficiently large correlation window length or else the values produced by the Find Delay block do not stabilize at a correct value.

  4. Run the simulation.

The new Display block now shows the value 776, as expected.

Using the Align Signals Block Before Computing the Error Rate

To use the Error Rate Calculation block to compute the value labeled Interleaved BER without having to set the Receive delay parameter to a nonzero value, you can use the Align Signals block to automatically align the transmitted and received signals before the Error Rate Calculation block performs its computations. Use this procedure:

  1. Insert an Align Signals block and a Display block in the model near the Error Rate Calculation block that computes the value labeled Interleaved BER.

  2. Connect the blocks as shown below.

  3. Set the Align Signals block's Correlation window length parameter to a value substantially larger than 776, such as 2000.

      Note   You must use a sufficiently large correlation window length or else the Align Signals block cannot find the correct amount by which to delay one of the signals. If the delay output from the Align Signals block does not stabilize at a constant value, the correlation window length is probably too small.

  4. Set the Error Rate Calculation block's Receive delay parameter to 0. You might also want to set the block's Computation delay parameter to a nonzero value to account for the possibility that the Align Signals block takes a nonzero amount of time to stabilize on the correct amount by which to delay one of the signals.

  5. Run the simulation.

The new Display block now shows the value 776. Also, the Align Signals block delays one signal relative to the other so that the signals are aligned. The Error Rate Calculation block therefore processes two signals that are properly aligned with each other and does not need to use a nonzero Receive delay parameter to attempt any further alignment.

Examining the delay output signal from the Align Signals block, using the Display block as in the figure above, is important because if the delay output signal does not stabilize at a constant value, the signals are not truly aligned and the error rate is not reliable. In this case, the Align Signals block's Correlation window length parameter is probably too small.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS