Intel® FPGA SDK for OpenCL™ Pro Edition: Programming Guide

ID 683846
Date 10/04/2021
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

5.4.5.5. Emulating I/O Channels

When you emulate a kernel that has a channel declared with the io attribute, I/O channel input is emulated by reading from a file, and channel output is emulated by writing to a file.

When you run your emulation, the file name used for reading or writing matches the name in the io attribute. For example, if you have a channel declaration as follows, your emulation reads or writes (but not both) to a file called myIOChannel.
channel uint chanA __attribute__((io("myIOChannel")));
I/O channels are unidirectional. You can either read from a channel or write to a channel, but not both. However, you can have separate read channels and write channels with the same io attribute value.
channel uint readChannel __attribute__((io("myIOChannel")));
channel uint writeChannel __attribute__((io("myIOChannel")));

Emulating Reading from an I/O Channel

If a read is issued from a channel with an io attribute called myfile, a read attempt is made on a file on the disk called myfile. If the myfile file does not exist or there is insufficient data to read from the file, the behavior depends on the call type:
Non-blocking read
If the file does not exist or there is insufficient data, the read attempt returns with a failure message.
Blocking read
If the file does not exist or there is insufficient data, the read attempt blocks your program until the file is created on the disk, or the file contains sufficient data.

Emulating Writing to an I/O Channel

If a write is issued to a channel with an io attribute called myfile, a write attempt is made to a file on the disk called myfile. If the myfile file does not exist, a regular file is created and written to. If the myfile file exists, it is overwritten. If the write fails, the behavior depends on the call type:
Non-blocking write
If the write attempt fails, an error is returned.
Blocking write
If the write attempt fails, further write attempts are made.