Queue
Store inputs in FIFO register
Libraries:
DSP System Toolbox /
Signal Management /
Buffers
Description
The Queue block stores a sequence of input samples in a first-in first-out (FIFO) register. Depending on the inputs at the ports, the block can push, pop, or empty the queue.
When the block receives a trigger event at the Push port, it pushes the input at the In port to the end of the queue. When the block receives a trigger event at the Pop port, it 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.
Examples
Queues
Push and pop elements from a queue using a Queue block with a system of selection switches.
Ports
Input
In — Input to FIFO register
scalar | vector | matrix
Specify the input to the FIFO register as a scalar, vector, or a matrix.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| Boolean
| fixed point
Push — Trigger signal to push queue
scalar
Specify the trigger signal to push the queue as a real scalar.
Input to the Push port must have the same data type as the input to the Pop and Rst ports.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| Boolean
Pop — Trigger signal to pop queue
scalar
Specify the trigger signal to pop the queue as a real scalar.
Input to the Pop port must have the same data type as the inputs to the Push and Rst ports.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| Boolean
Rst — Trigger signal to empty queue
scalar
Specify the trigger signal to empty the queue as a real scalar.
Input to the Rst port must have the same data type as the inputs to the Push and Pop ports.
Dependencies
To enable this port, select Show reset port (Rst) to clear internal stack buffer.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| Boolean
Output
Out — Output of FIFO register
scalar | vector | matrix
Output of the FIFO register, returned as a scalar, vector, or a matrix.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| Boolean
| fixed point
Empty — Indicates if queue is empty
1
| 0
The block returns 1
at this port to indicate an
empty queue and 0
otherwise.
Dependencies
To enable this port, select Show empty register indicator port (Empty).
Data Types: double
| Boolean
Full — Indicates if queue is full
1
| 0
The block returns 1
at this port to indicate a full
queue and 0
otherwise.
If you select Dynamic reallocation
in the
Push onto full register parameter, the
Full port remains 0
.
Dependencies
To enable this port, select Show full register indicator port (Full).
Data Types: double
| Boolean
Num — Track number of elements in queue
scalar
Track the number of elements in the queue at any given time.
If the data type at the In port is
double
, the data type at the
Num port is double
.
Otherwise, the data type at the Num port is
uint32
.
Dependencies
To enable this port, select Show number of register entries port (Num).
Data Types: double
| uint32
Parameters
Register size — Number of entries FIFO register can hold
8 (default) | positive integer
The number of entries that the FIFO register can hold, specified as a positive integer.
Trigger type — Type of trigger event for Push, Pop, and Rst ports
Rising edge
(default) | Falling edge
| Either edge
| Non-zero sample
The type of event that triggers the execution of the block. Select one of these options:
Trigger Type | Description |
---|---|
Rising edge | Triggers execution of the block when the trigger input does one of the following:
|
Falling edge | Triggers execution of the block when the trigger input does one of the following:
|
Either edge | Triggers execution of the block when the trigger
input type is |
Non-zero sample | Triggers execution of the block at each sample time that the trigger input is not zero. |
The rate of the trigger signal must be the same as the rate of the data signal input.
Push onto full register — Specify block behavior to push request when register is full
Dynamic reallocation
(default) | Ignore
| Warning
| Error
Specify the block behavior when it receives a trigger at the Push port but the register is full. The available options are:
Dynamic reallocation
— Dynamically resize the register to accept as many additional inputs as memory permits.To use this option, set the System target file parameter on the Code Generation pane of the Model Configuration Parameters dialog box to
grt_malloc.tlc – Generic Real-Time Target with dynamic memory allocation
.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 the accelerator mode in Simulink®.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 is a diagnostic
parameter. Like all diagnostic parameters in the Configuration
Parameters dialog box, this parameter is set to
Ignore
in the code generated for this
block by the Simulink
Coder™ code generation software.
Pop empty register — Specify block behavior to pop request when register is empty
Warning
(default) | Ignore
| Error
Specify the block behavior when it receives a trigger at the Pop port but the register is empty. The available options are:
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 Pop empty register is a diagnostic parameter.
Like all diagnostic parameters in the Configuration Parameters dialog
box, this parameter is set to Ignore
in the
code generated for this block by the Simulink
Coder code generation software.
Show empty register indicator port (Empty) — Enable Empty output port
off (default) | on
Select to enable the Empty output port to indicate an empty register.
Show full register indicator port (Full) — Enable Full output port
off (default) | on
Select to enable the Full output port to indicate a full register.
Show number of register entries port (Num) — Enable Num output port
off (default) | on
Select to enable the Num output port to show the number of register entries.
Show reset port (Rst) to clear internal stack buffer — Enable Rst input port
off (default) | on
Select to enable the Rst input port. The block empties the queue when it receives a trigger at this port.
Clear output port on reset — Set Out port to 0
when clearing queue
off (default) | on
If 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 0
.
This setting also applies when a disabled subsystem containing the
Queue block is re-enabled.
Dependencies
To enable this parameter, select the Show reset port (Rst) to clear internal stack buffer parameter.
Allow direct feedthrough — Allow input data to be readily available at Out port
on (default) | off
Select to allow the input data to be available immediately at the Out port of the block. Clear to delay the input data by an extra frame.
When you select the Allow direct feedthrough parameter and trigger two or more of the control input ports at the same time step, the block executes the operations in the following order:
Reset
Push
Pop
When you clear the Allow direct feedthrough parameter and trigger two or more of the control input ports at the same time step, the block executes the operations in the following order:
Reset
Pop
Push
The rate of the trigger signal must be the same as the rate of the data signal input.
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
More About
Operation of Queue Block
This table shows how the Queue block operates when you set the
Register size to 4
, Trigger
type to Either edge
, and enable the
Clear output port on reset parameter. Because the block
triggers on both rising and falling edges, each transition from 1
to 0
or 0
to 1
in the
Push, Pop, and
Rst columns represents a distinct trigger event.
1
in the Empty column indicates an empty
queue, while 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 |
In the last time step, there are triggers at the Push and Rst ports simultaneously. The Rst trigger takes precedence: the block first clears the queue and then pushes the value at the In port into the queue.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
The following limitations apply:
Generated code relies on the
memcpy
ormemset
function (string.h
) under certain conditions.When you select
Dynamic reallocation
, you must set the System target file parameter on the Code Generation pane of the Configuration Parameters dialog box togrt_malloc.tlc - Generic Real-Time Target with dynamic memory allocation
.
Version History
Introduced before R2006a
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)