Circular Buffer Write FIFO Write navigation bar

Table of Contents

FIFO Read

Reads from 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 Read

The FIFO Read block reads from 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 assigned in a FIFO Write block determines the name of the FIFO. The FIFO Read block accesses the FIFO by name.

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

The FIFO Read 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 Read 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. Because the FIFO Read block can be configured to block until data is available, it may be used to synchronize an asynchronous thread with the main diagram.

The FIFO Read block normally does not wait for the corresponding FIFO Write block to write data to the queue. If the queue becomes empty so that there is no data to read from the queue then the underflow output will go high and the new data output will go low. The data output will be determined by the Action to take on underflow parameter. The underflow output will go low the next time the FIFO Read block executes and there is data available in the queue.

The FIFO Read block may be configured to wait for the FIFO Write block to write data to the queue by checking the Wait for data to become available option. In this case, the block does not return until data becomes available or the specified timeout occurs. The resolution of the timeout depends on the target. For example, on the Windows target the resolution of the timeout is only one millisecond, but on other targets, the resolution may be higher.

Multi-dimensional and variable-size signals, as well as bus signals are supported (with some restrictions). 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.

Helpful Hints

Variable-size signals

Hint When using the FIFO Read 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

def

The current default value for the data output. If the FIFO underflows then this value appears at the output. Otherwise it is not used. This input is only present when the Action to take on underflow parameter is set to "use external input". Multi-dimensional and variable-size inputs are supported as well as arbitrary data types.

Bus signals are not currently supported at the def input. The Action to take on underflow must be set to "hold previous value" or "use default value parameter" when using bus signals.

Output Ports

This block has one output port, data, and three optional output ports: under, new and pos.

data

The sample read from the FIFO queue. If there is no data in the queue and the block is not configured to wait for data to become available, the value of this output depends on the Action to take on underflow parameter. If this parameter is set to "hold previous value" then the value of the output on underflow will be the same as the previous value of the output. If there has never been data available in the queue then the value of the output is determined by the Default value parameter. In this case, the dimensions of the data output are determined by the dimensions of the Default value parameter. Multi-dimensional and variable-size outputs, as well as bus signals, are supported.

If the Action to take on underflow parameter is set to "use default parameter" then the value of the output on underflow is determined by the Default value parameter. In this case, the dimensions of the data output are determined by the dimensions of the Default value parameter.

In the above scenarios, the data type of this output is determined by the Data output data type parameter under the Signal Data Types tab. If the "Specify via dialog" option is selected, then the Data output type name parameter determines the data type of the output. In this case, it is typically the name of a Simulink.Bus object defining a bus. See Using Bus Objects with QUARC for more information on bus signals.

If the Action to take on underflow parameter is set to "use external input" then the value of the output on underflow is determined by the def input. In this case, the dimensions and data type of the data output are determined by the dimensions and data type of the def input. Multi-dimensional and variable-size inputs are supported as well as arbitrary data types in this case. However, bus signals are not supported in this instance.

under

An underflow flag. This Boolean output is normally low, but it goes high when there is no data available to read from the queue. If the underflow flag goes high it indicates that the signal appearing at the data output is not a new sample.

new

A new data flag. This Boolean output is normally high to indicate that the signal appearing at the data output is a new sample. However, it goes low when there is no data available to read from the queue. If the new data flag goes low it indicates that the signal appearing at the data output is not a new sample.

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 Read block outputs signals of any of the built-in Simulink datatypes, except fixed point, for the data and FIFO position outputs. The data types are set using the options under the Signal Data Types tab. The underflow and new data outputs are always Boolean. The data and def ports may be multi-dimensional or variable-size signals. See Variable-Size Signals for more information on variable-size signals.

Arbitrary data types are supported for the data output if the Action to take on underflow parameter is set to "use external input". In this case, the data type of the def input determines the data type of the data output.

Bus signals are supported at the data output if the Action to take on underflow parameter is set to any of the other options. See Using Bus Objects with QUARC for more information on bus signals.

Parameters and Dialog Box

FIFO Read

FIFO name

The name of the FIFO to read. There may only be one FIFO Read block assigned to a FIFO.

Action to take on underflow

This option determines what value appears at the data output if there is no data available in the FIFO and the block is not configured to wait for data to become available. If this parameter is set to "hold previous value" then the value of the output on underflow will be the same as the previous value of the output. If there has never been data available in the queue then the value of the output is determined by the Default Value parameter. In this case, the dimensions of the data output are determined by the dimensions of the Default value parameter.

If this parameter is set to "use default parameter" then the value of the output on underflow is determined by the Default value parameter. In this case, the dimensions of the data output are determined by the dimensions of the Default value parameter.

If this parameter is set to "use external input" then the value of the output on underflow is determined by the def input. In this case, the dimensions and data type of the data output are determined by the dimensions and data type of the def input.

Default value

The default value for the data output when there is no data available in the FIFO queue. Refer to the Action to take on underflow parameter for the conditions under which this parameter is used. This parameter may be a multi-dimensional array, such as the 2x3 matrix: [0 0 0; 0 0 0]. When variable-size signals are used, the default value may be smaller in dimension than the maximum dimensions of the output but must have the same number of dimensions.

Wait for data to become available

Normally the FIFO Read block does not wait for data to become available. However, if this option is checked then the block does not return until data becomes available in the FIFO queue. This option is useful for synchronizing asynchronous threads to the sample rate of the main diagram. Such synchronization is often convenient for communications because the use of an asynchronous thread ensures that blocking communications do not interfere with the fixed sample rates of the diagram while sending or receiving data from a remote client.

Timeout

The amount of time to wait for data to become available in blocking operation. This option is ignored when the Wait for data to become available option is not checked.

Output underflow flag

If this option is checked then the block is given an extra output called under that indicates when the FIFO queue has underflowed. Underflow occurs when the FIFO Read block fails to read from the queue because there is no data available in the queue. This output is normally low unless underflow occurs, in which case it goes high.

Output new data flag

If this option is checked then the block is given an extra output called new that indicates whether the data at the output is new i.e., whether the data at the output was just read from the queue. This output is normally high unless underflow occurs, in which case it goes low.

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, before the sample has been removed from the queue. Hence, the FIFO position is often equal to one, indicating that the only sample was in the queue at the time of the read.

Use variable-size signals

If this option is checked then the block outputs a variable-size signal at its data port. The maximum dimensions of the output are determined by the Maximum dimensions parameter. The dimensions at any given time are determined by the dimensions of the signal read from the FIFO. Since the FIFO Write block supports writing variable-size signals to the FIFO, these dimensions can change with each new value read from the FIFO. Refer to Variable-Size Signals for more details on variable-size signals.

Maximum dimensions

This parameter is only used when the Use variable-size signals option is checked. It determines the maximum dimensions of the data output. It is a vector of positive integers indicating the dimensions required. For example, a value of 10 would make the output a vector of at most 10 elements. A value of [4 9] would make the output a matrix whose maximum size is 4x9.

If the Maximum dimensions is set to -1 then the maximum dimensions are inherited.

If the Action to take on underflow parameter is set to hold previous value or use default parameter then the maximum dimensions are inherited from dimensions of the Default value parameter. A vector value for the Default value parameter will be treated as a 1-D vector rather than a matrix. To force the output to be a treated as a matrix, specify the dimensions explicitly in the Maximum dimensions parameter rather than inheriting from the Default value parameter.

If the Action to take on underflow parameter is set to use external input then the maximum dimensions are inherited from the maximum dimensions of the def input.

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. Since this is a source block, only inherent the sample time when it is placed in a conditionally executed subsystem, like a Triggered Subsystem, Enabled Subsystem, Function call Subsystem or in a referenced model.

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 qc_get_step_size because this block is a source 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