FIFO Read End of trail navigation bar

Table of Contents

FIFO Write

Writes to a FIFO queue.

Library

QUARC Targets/Advanced/Asynchronous

MATLAB Command Line

Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:

qc_open_library('quarc_library/Advanced/Asynchronous')

Description

FIFO Write

The FIFO Write block writes to a FIFO queue every time the block is executed. The FIFO may be used to communicate between synchronous (fixed sample rate) and asynchronous threads (no sample rate). The name of the FIFO is specified as a block parameter. It must be unique throughout the diagram.

The FIFO may be read using the FIFO Read block. There may only be one FIFO Read block for each FIFO Write block.

The FIFO Write block is typically used to communicate between the main diagram, which runs a fixed sample rate, and blocks inside the Function Call Subsystem attached to an Asynchronous Thread block, which have no associated sample rate. However, the FIFO Write block may be used anywhere in the diagram. Also, any number of these blocks may be placed in the model, although it is more efficient to use fewer blocks.

The FIFO Write block typically never waits for the corresponding FIFO Read block to read the data from the queue. If the queue becomes full so that it is not possible to write to the queue then the overflow output will go high and the input will be discarded. The overflow output will go low the next time the FIFO Write block executes and there is space available in the queue. If this behaviour is undesirable, then the FIFO Write block may be configured to wait for a timeout period, or indefinitely, for space to become available in the queue.

Helpful Hints

Variable-size signals

Hint When using the FIFO Write block with variable-size signals in subsystems, make sure any

Action Port

MATLAB Command Line

Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:

doc ActionPort;
,
Enable

MATLAB Command Line

Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:

doc Enable
or
Trigger

MATLAB Command Line

Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:

doc Trigger
ports are configured to propagate the sizes of variable-size signals during execution.

Input Ports

data

The data to write to the FIFO queue. Multi-dimensional and variable-size signals as well as bus inputs are supported, with arbitrary data types. See Using Bus Objects with QUARC for more information on bus signals, and refer to Variable-Size Signals for more details on variable-size signals.

Output Ports

This block has two optional output ports: an overflow flag and a FIFO position.

over

An overflow flag. This boolean flag is normally false (0), but will go high (1) if there is no space left in the FIFO when the block attempts to write the value of its input signal to the FIFO. It will go low again the next time the FIFO succeeds in writing to the queue.

pos

The FIFO position. The data type of this output is determined by the Position output data type parameter under the Signal Data Types tab. It indicates the number of samples currently in the queue. One sample consists of the full value of the input vector that was stored in the queue. It is not an individual element of the input vector.

Data Type Support

The FIFO Write block outputs signals of any of the built-in Simulink datatypes, except fixed point, for the FIFO position output. The data type is set using the Position output data type parameter. The overflow output is always Boolean. The data port may be multi-dimensional and any data type.

The FIFO Write block also accepts bus signals at its data input. Buses are useful for sending a mix of different data types in a single write operation. Bus signals are created using the

Bus Creator

MATLAB Command Line

Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:

doc('Bus Creator')
block supplied with Simulink. A
Simulink.Bus

MATLAB Command Line

Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:

doc('Simulink.Bus')
object must be created that defines the data types of the signals within the bus. This object may be created using the Bus Editor and then saved to a MAT file. To ensure that the bus object is always defined, load this MAT file within the InitFcn callback of the Simulink model. See Using Bus Objects with QUARC for more information on bus signals.

If a variable-size signal is fed to its data input then the corresponding FIFO Read block must be configured to output variable-size signals. The maximum dimensions for the variable-size signals of both blocks must be identical. If the FIFO Read is configured for variable-size signals it is still possible to feed a fixed-size signal to the FIFO Write block's data input. See Variable-Size Signals for more information on variable-size signals.

Parameters and Dialog Box

FIFO Write

FIFO name

The name to assign to the FIFO queue. This name will show up in the FIFO Read block in the list of FIFO queues.

Number of samples in buffer

The number of samples in the FIFO queue. A sample consists of the full value of the input vector not an individual element of the input vector.

Wait for space to become available (blocking operation)

If this option is checked then the FIFO Write block will not complete execution until enough space becomes available in the FIFO for the data at its input. If this option is not checked, then an overflow condition occurs, the data at its input is discarded and the optional overflow flag output is set to true.

Timeout (seconds)

The length of time, in seconds, but the block will wait for space to become available in the FIFO queue for the data at its input. If the timeout expires before space becomes available then an overflow condition occurs as described in the preceding parameter's description.

Ignore repeated samples

If this option is checked then the signal present at the input of the FIFO is only written to the queue if it differs from the previous value written to the queue. Otherwise the input signal is always written to the FIFO queue.

Output overflow flag

If this option is checked then the block is given an extra output called over that indicates when the FIFO queue has overflowed. Overflow occurs when the FIFO Read block fails to read the queue before the FIFO becomes full.

Output FIFO position

If this option is checked then the block is given an extra output called pos that indicates the number of samples currently in the FIFO queue, after the input signal has already been added to the queue. Hence, the FIFO position is often equal to one, indicating that the only sample in the queue is the one just written.

Sample time

The sample time of the block. A sample time of 0 indicates that the block will be treated as a continuous time block. A positive sample time indicates that the block is a discrete time block with the given sample time.

A sample time of -1 indicates that the block inherits its sample time from its input.

To use the fundamental sampling time of the model, set the sample time to qc_get_step_size, which is a QUARC function that returns the fundamental sampling time of the model.

The default sample time is set to -1 because this block is typically used in a Function Call Subsystem attached to an Asynchronous Thread block.

Targets

Target Name

Compatible*

Model Referencing

Comments

QUARC Win32 Target

Yes

Yes

QUARC Win64 Target

Yes

Yes

QUARC Linux Nvidia Target

Yes

Yes

QUARC Linux QBot Platform Target

Yes

Yes

QUARC Linux QCar 2 Target

Yes

Yes

QUARC Linux QDrone 2 Target

Yes

Yes

QUARC Linux Raspberry Pi 3 Target

Yes

Yes

QUARC Linux Raspberry Pi 4 Target

Yes

Yes

QUARC Linux RT ARMv7 Target

Yes

Yes

QUARC Linux x64 Target

Yes

Yes

QUARC Linux DuoVero Target

Yes

Yes

QUARC Linux DuoVero 2016 Target

Yes

Yes

QUARC Linux Verdex Target

Yes

Yes

QUARC QNX x86 Target

Yes

Yes

Last fully supported in QUARC 2018.

Rapid Simulation (RSIM) Target

Yes

Yes

S-Function Target

No

N/A

Old technology. Use model referencing instead.

Normal simulation

Yes

Yes

Fully supported. However, be aware of the restrictions on the Asynchronous Thread block.

* Compatible means that the block can be compiled for the target.

See Also

 

navigation bar