Queue - Store inputs in FIFO register - Simulink (original) (raw)
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
Ports
Input
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
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 andRst ports.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| Boolean
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 andRst ports.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| Boolean
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 andPop 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
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
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
The block returns 1
at this port to indicate a full queue and 0
otherwise.
If you select Dynamic reallocation
in thePush onto full register parameter, theFull port remains 0
.
Dependencies
To enable this port, select Show full register indicator port (Full).
Data Types: double
| Boolean
Track the number of elements in the queue at any given time.
If the data type at the In port isdouble
, the data type at theNum port is double
. Otherwise, the data type at the Num port isuint32
.
Dependencies
To enable this port, select Show number of register entries port (Num).
Data Types: double
| uint32
Parameters
The number of entries that the FIFO register can hold, specified as a positive integer.
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:Rises from a negative value to zero or a positive value.Rises from zero to a positive value but is not a continuing rise.![]() |
Falling edge | Triggers execution of the block when the trigger input does one of the following:Falls from a positive value to zero or a negative value.Falls from zero to a negative value but is not a continuing fall.![]() |
Either edge | Triggers execution of the block when the trigger input type is Rising edge orFalling edge (as described above). |
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.
Specify the block behavior when it receives a trigger at thePush 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 togrt_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 toDynamic 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 toIgnore
in the code generated for this block by the Simulink Coder™ code generation software.
Specify the block behavior when it receives a trigger at thePop 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.
Select to enable the Empty output port to indicate an empty register.
Select to enable the Full output port to indicate a full register.
Select to enable the Num output port to show the number of register entries.
Select to enable the Rst input port. The block empties the queue when it receives a trigger at this port.
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 theQueue block is re-enabled.
Dependencies
To enable this parameter, select the Show reset port (Rst) to clear internal stack buffer parameter.
Select to allow the input data to be available immediately at theOut 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 | Boolean | double | fixed point | integer | single |
---|---|---|---|---|
Direct Feedthrough | no | |||
Multidimensional Signals | no | |||
Variable-Size Signals | no | |||
Zero-Crossing Detection | no |
More About
This table shows how the Queue block operates when you set theRegister size to 4
, Trigger type to Either edge
, and enable theClear 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 thePush, Pop, andRst 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 andRst 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
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 theCode Generation pane of the Configuration Parameters dialog box togrt_malloc.tlc - Generic Real-Time Target with dynamic memory allocation
.
Version History
Introduced before R2006a