Circular Buffer Initialize Circular Buffer Write navigation bar

Table of Contents

Circular Buffer Read

Reads from a circular buffer.

Library

QUARC Targets/Advanced/Asynchronous

Description

Circular Buffer Read

The Circular Buffer Read block reads from a circular buffer every time the block is executed. The circular buffer may be used to communicate between synchronous (fixed sample rate) and asynchronous threads (no sample rate). The name assigned in a Circular Buffer Initialize block determines the name of the circular buffer. The Circular Buffer Read block accesses the circular buffer by name.

The circular buffer may be written using the Circular Buffer Write block. There may any number of Circular Buffer Read, Circular Buffer Write and Circular Buffer Clear blocks in the model, unlike the FIFO queues.

The Circular Buffer 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 Circular Buffer 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 Circular Buffer 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 Circular Buffer Read block normally does not wait for a Circular Buffer Write block to write data to the buffer. If the buffer becomes empty so that there is no data to read from the buffer 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 Circular Buffer Read block executes and there is data available in the buffer.

The Circular Buffer Read block may be configured to wait for a Circular Buffer Write block to write data to the queue by entering a non-zero timeout interval for the Timeout parameter. 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.

Input Ports

def

The current default value for the data output. If the buffer 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".

Output Ports

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

data

The sample read from the circular buffer. If there is no data in the buffer 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.

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 of the data output are determined by the dimensions of the def input.

The data type of this output is determined by the Output data type parameter under the Signal Data Types tab.

under

An underflow flag. This Boolean output is normally low, but it goes high when there is no data available to read from the buffer. 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 buffer. If the new data flag goes low it indicates that the signal appearing at the data output is not a new sample.

Data Type Support

The Circular Buffer Read block outputs signals of any of the built-in Simulink datatypes, except fixed point, for the data output. The data type is set using the options under the Signal Data Types tab. The underflow and new data outputs are always Boolean.

Parameters and Dialog Box

Main Pane

The Main pane of the dialog appears as follows:

Main tab of Circular Buffer Read parameters dialog

Go to Circular Buffer blocks using this buffer

Opens a dialog that lists all the Circular Buffer blocks in the model which are currently using the same interface selected in the Buffer name parameter. The dialog may be used to go to another Circular Buffer block in the model just by double-clicking on the name of the block in the dialog box.

Buffer name

The name of the circular buffer to read. This list of buffer names is derived from all the Circular Buffer Initialize blocks in the model.

Action to take on underflow

This option determines what value appears at the data output if there is no data available in the circular buffer. 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 buffer 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 of the data output are determined by the dimensions of the def input.

Default value

The default value for the data output when there is no data available in the circular buffer. Refer to the Action to take on underflow parameter for the conditions under which this parameter is used.

Timeout

The amount of time to wait for data to become available if there is no data currently in the circular buffer. This parameter may be zero, in which case the block does not wait for data.

Output underflow flag

If this option is checked then the block is given an extra output called under that indicates when the circular buffer has underflowed. Underflow occurs when the Circular Buffer Read block fails to read from the buffer because there is no data available in the circular buffer. 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 circular buffer. This output is normally high unless underflow occurs, in which case it goes low.

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.

Signal Data Types Pane

The Signal Data Types pane of the dialog appears as follows:

Signal Data Types tab of Circular Buffer Read parameters dialog

Output data type

Determines the data type of the data read. If back propagation is selected then the data type will be determined by the block to which the output is connected. If the output is not connected or it is connected to a block which supports multiple datatypes, then the output data type will be double.

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

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

See Also

 

navigation bar