Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Queue

Store inputs in FIFO register

Library

Signal Management / Buffers

dspbuff3

Description

The Queue block stores a sequence of input samples in a first in, first out (FIFO) register. The register capacity is set by the Register size parameter, and inputs can be scalars, vectors, or matrices.

The block pushes the input at the In port onto the end of the queue when a trigger event is received at the Push port. When a trigger event is received at the Pop port, the block pops the first element off the queue and holds the Out port at that value. The first input to be pushed onto the queue is always the first to be popped off.

A trigger event at the optional Rst port empties the queue contents. When you select Clear output port on reset, then a trigger event at the Rst port empties the queue and sets the value at the Out port to zero. This setting also applies when a disabled subsystem containing the Queue block is reenabled; the Out port value is only reset to zero in this case when you select Clear output port on reset.

When you select the Allow direct feedthrough check box and two or more of the control input ports are triggered at the same time step, the operations are executed in the following order:

  1. Rst

  2. Push

  3. Pop

When you clear the Allow direct feedthrough check box and two or more of the control input ports are triggered at the same time step, the operations are executed in the following order:

  1. Rst

  2. Pop

  3. Push

The rate of the trigger signal must be the same as the rate of the data signal input. You specify the triggering event for the Push, Pop, and Rst ports by the Trigger type pop-up menu:

  • Rising edge — Triggers execution of the block when the trigger input does one of the following:

    • Rises from a negative value to a positive value or zero

    • Rises from zero to a positive value, where the rise is not a continuation of a rise from a negative value to zero; see the following figure

  • Falling edge — Triggers execution of the block when the trigger input does one of the following:

    • Falls from a positive value to a negative value or zero

    • Falls from zero to a negative value, where the fall is not a continuation of a fall from a positive value to zero; see the following figure

  • Either edge — Triggers execution of the block when the trigger input is a Rising edge or Falling edge (as described above).

  • Non-zero sample — Triggers execution of the block at each sample time that the trigger input is not zero.

    Note:   If your model contains any referenced models that use a Queue block with the Push onto full register parameter set to Dynamic reallocation, you cannot simulate your top-level model in Simulink® Accelerator mode.

The Push onto full register parameter specifies the block's behavior when a trigger is received at the Push port but the register is full. The Pop empty register parameter specifies the block's behavior when a trigger is received at the Pop port but the register is empty. The following options are available for both cases:

  • Ignore — Ignore the trigger event, and continue the simulation.

  • Warning — Ignore the trigger event, but display a warning message in the MATLAB® Command Window.

  • Error — Display an error dialog box and terminate the simulation.

    Note   The Push onto full register and Pop empty register parameters are diagnostic parameters. Like all diagnostic parameters on the Configuration Parameters dialog box, they are set to Ignore in the code generated for this block by Simulink Coder™ code generation software.

The Push onto full register parameter additionally offers the Dynamic reallocation option, which dynamically resizes the register to accept as many additional inputs as memory permits. To find out how many elements are on the queue at a given time, enable the Num output port by selecting the Show number of register entries port parameter.

    Note:   When Dynamic reallocation is selected, the System target file parameter on the Code Generation pane of the Model Configuration Parameters dialog box must be set to grt_malloc.tlc – Generic Real-Time Target with dynamic memory allocation.

Examples

Example 1

The table below illustrates the Queue block's operation for a Register size of 4, Trigger type of Either edge, and Clear output port on reset enabled. Because the block triggers on both rising and falling edges in this example, each transition from 1 to 0 or 0 to 1 in the Push, Pop, and Rst columns below represents a distinct trigger event. A 1 in the Empty column indicates an empty queue, while a 1 in the Full column indicates a full queue.

In

Push

Pop

Rst

Queue

Out

Empty

Full

Num

1

0

0

0

0

1

0

0

2

1

0

0

0

0

0

1

3

0

0

0

0

0

0

2

4

1

0

0

0

0

0

3

5

0

0

0

0

0

1

4

6

0

1

0

2

0

0

3

7

0

0

0

3

0

0

2

8

0

1

0

4

0

0

1

9

0

0

0

5

1

0

0

10

1

0

0

5

0

0

1

11

0

0

0

5

0

0

2

12

1

0

1

0

0

0

1

Note that at the last step shown, the Push and Rst ports are triggered simultaneously. The Rst trigger takes precedence, and the queue is first cleared and then pushed.

Example 2

The dspqdemodspqdemo example provides another example of the operation of the Queue block.

Dialog Box

Register size

The number of entries that the FIFO register can hold.

Trigger type

The type of event that triggers the block's execution. The rate of the trigger signal must be the same as the rate of the data signal input.

Push onto full register

Response to a trigger received at the Push port when the register is full. Inputs to this port must have the same built-in data type as inputs to the Pop and Rst input ports.

When Dynamic reallocation is selected, the System target file parameter on the Code Generation pane of the Model Configuration Parameters dialog box must be set to grt_malloc.tlc – Generic Real-Time Target with dynamic memory allocation.

Pop empty register

Response to a trigger received at the Pop port when the register is empty. Inputs to this port must have the same built-in data type as inputs to the Push and Rst input ports.

Show empty register indicator port

Enable the Empty output port, which is high (1) when the queue is empty, and low (0) otherwise.

Show full register indicator port

Enable the Full output port, which is high (1) when the queue is full, and low (0) otherwise. The Full port remains low when you select Dynamic reallocation from the Push onto full register parameter.

Show number of register entries port

Enable the Num output port, which tracks the number of entries currently on the queue. When inputs to the In port are double-precision values, the outputs from the Num port are double-precision values. Otherwise, the outputs from the Num port are 32-bit unsigned integer values.

Show reset port to clear internal stack buffer

Enable the Rst input port, which empties the queue when the trigger specified by the Trigger type is received. Inputs to this port must have the same built-in data type as inputs to the Push and Pop input ports.

Clear output port on reset

Reset the Out port to zero, in addition to clearing the queue, when a trigger is received at the Rst input port.

Allow direct feedthrough

When you select this check box, the input data is available immediately at the output port of the block. You can turn off direct feedthrough and delay the input data by an extra frame by clearing the Allow direct feedthrough check box.

Supported Data Types

PortSupported Data Types

In

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed and unsigned)

  • Boolean

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

Push

  • Double-precision floating point

  • Single-precision floating point

  • Boolean

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

    Inputs to this port must have the same built-in data type as inputs to the Pop and Rst input ports

Pop

  • Double-precision floating point

  • Single-precision floating point

  • Boolean

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

    Inputs to this port must have the same built-in data type as inputs to the Push and Rst input ports.

Rst

  • Double-precision floating point

  • Single-precision floating point

  • Boolean

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

    Inputs to this port must have the same built-in data type as inputs to the Push and Pop input ports.

Out

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point (signed only)

  • Boolean

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

Empty

  • Double-precision floating point

  • Boolean

Full

  • Double-precision floating point

  • Boolean

Num

  • Double-precision floating point

    The block outputs a double-precision floating-point value at this port when the data type of the In port is double-precision floating-point.

  • 32-bit unsigned integers

    The block outputs a 32-bit unsigned integer value at this port when the data type of the In port is anything other than double-precision floating-point.

See Also

BufferDSP System Toolbox
Delay LineDSP System Toolbox
StackDSP System Toolbox

Was this topic helpful?