Buffer - Buffer input sequence to smaller or larger frame size - Simulink (original) (raw)

Buffer input sequence to smaller or larger frame size

Libraries:
DSP System Toolbox / Signal Management / Buffers

Description

The Buffer block always performs frame-based processing. The block redistributes the data in each column of the input to produce an output with a different frame size. Buffering a signal to a larger frame size yields an output with a_slower_ frame rate than the input. For example, consider this illustration for a scalar input.

Buffering a signal to a smaller frame size yields an output with a_faster_ frame rate than the input. For example, consider this illustration of a scalar output.

The block coordinates the output frame size and frame rate of nonoverlapping buffers such that the sample period of the signal is the same at both the input and output:Tso =Tsi.

This block supports triggered subsystems when the block input and output rates are the same.

Examples

Ports

Input

expand all

To buffer single-channel signals, input a scalar or column vector. To buffer multichannel signals, input a row vector or matrix. To buffer single-channel signals, input a scalar or column vector of the size_Mi_-by-1, where_Mi_ is the input frame size.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point
Complex Number Support: Yes

Output

expand all

The buffered input signal returned as a vector or a matrix.

When the input is a single-channel signal:

where

The input frame period is_Mi_ ·Tsi, where_Tsi_ is the input sample period. The output frame period is (Mo−L)Tsi, where L is the value of theBuffer overlap parameter and_T_si is the input sample period. When you set the Buffer overlap parameter to _M_o – 1, the output frame period equals the input sample period.

When the input is a multichannel signal:

where

The input frame period is_Mi_ ·Tsi. The output frame period is (Mo−L)Tsi, which equals the sequence sample period when the Buffer overlap is Mo−1. Thus, the output sample period_Tso_ is related to the input sample period_Tsi_ by

The output has the same data type and complexity as the input

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point
Complex Number Support: Yes

Parameters

expand all

Specify the number of consecutive samples,Mo, from each channel to buffer into the output frame.

Data Types: double | int8 | int16 | int32 | uint8 | uint16 | uint32

Specify the number of samples, L, which specifies the amount of overlap or underlap in each successive output frame.

To overlap the data in the buffer, specify a value of_L_ in the range 0≤L<Mo, where Mo is the value of the Output buffer size parameter. The block takes L samples (rows) from the current output and repeats them in the next output. In cases of overlap, the block acquires Mo−L_new_ input samples before propagating the buffered data to the output.

When L<0, you are buffering the signal with underlap. The block discards L input samples after the buffer fills and outputs the buffer with period (Mo−L)Tsi, which is longer than in the zero-overlap case.

The output frame period is (Mo−L)Tsi, which equals the input sequence sample period,Tsi, when theBuffer overlap is Mo−1.

Data Types: double | int8 | int16 | int32 | uint8 | uint16 | uint32

Specify the value of the block's initial output, in cases of nonzero latency, as a scalar, vector, or matrix.

For all cases of single-tasking operation other than those listed inZero-Tasking Latency, the Buffer block's buffer is initialized to the value(s) specified by the Initial conditions parameter. The block reads from this buffer to generate the first D output samples, where

The dimensions of the Initial conditions parameter depend on the Buffer overlap,L, and whether the input is single-channel or multichannel:

For all multitasking operations, use the rebuffer_delay function to compute the exact delay in samples that the Buffer block introduces for a given combination of buffer size and buffer overlap.

For general buffering between arbitrary frame sizes, theInitial conditions parameter must be a scalar, which is then repeated across all elements of the initial output(s). However, in the special case where the input is a 1-by-N row vector, and the output of the block is an_Mo_-by-N matrix, Initial conditions can be:

In the special case where the output is a 1-by-N row vector, which is the result of unbuffering an_Mi_-by-N matrix, the Initial conditions can be:

For more information on latency and the Simulink® tasking modes, see Excess Algorithmic Delay (Tasking Latency) and Time-Based Scheduling and Code Generation (Simulink Coder).

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point
Complex Number Support: Yes

Block Characteristics

Data Types Boolean | double fixed point integer single
Direct Feedthrough no
Multidimensional Signals no
Variable-Size Signals no
Zero-Crossing Detection no

More About

expand all

Zero-tasking latency means that the first input sample, received at t = 0, appears as the first output sample. In the Simulink single-tasking mode, the Buffer block has zero-tasking latency for these special cases:

The Buffer block cannot be used in an enabled subsystem under the following conditions:

The Buffer block has an internal reservoir that temporarily stores data. When the Buffer block is used in an enabled subsystem, there is the possibility that the reservoir can overrun or underrun. The block implements safeguards against these occurrences.

Overrun occurs when more data enters the buffer than what it can hold. For example, consider buffering a scalar input to a frame of size three with a buffer that accepts an input every second and outputs every three seconds. If you place this buffer inside an enabled subsystem that is disabled every three seconds at t = 3s, t = 6s, and so on, the buffer accumulates data in its internal reservoir without being able to empty it. This condition results in an overrun.

Underrun occurs when the buffer runs out of data to output. For example, again consider buffering a scalar input to a frame size of three with a buffer that accepts an input every second and outputs every three seconds. If you place this buffer inside an enabled subsystem that is disabled at t = 10s, t = 11s, t = 13s,t = 14s, t = 16s, and_t_ = 17s, its internal reservoir becomes drained, and there is no data to output at t = 18s. This condition results in an underrun.

To protect from an overrun or an underrun, the Buffer block keeps a record of the amount of data in its internal reservoir. When the Buffer block reads data, the amount of data in its reservoir goes up. When the Buffer block outputs the data, the amount of data in its reservoir goes down. To protect from overrun, the oldest samples in the reservoir are discarded whenever the amount of data in the reservoir is larger than the actual buffer size. To protect from underrun, the most recent samples are repeated whenever an output is due and there is no data in the reservoir.

Extended Capabilities

expand all

The Buffer block supports code generation for Simulink Real-Time™. The code generated for this target is executed concurrently. To generate this code, set the system target file of the model to speedgoat.tlc or to any other target file supported by Simulink Real-Time. The Buffer block also needs to satisfy certain conditions.

To set the system target file:

  1. In the Simulink model window, in the Modeling tab, click Model Settings.
  2. In the Model Settings > Code Generation pane, set the System target file tospeedgoat.tlc or to any other target file supported by Simulink Real-Time.

In addition, the Buffer block must satisfy the following conditions:

Version History

Introduced before R2006a