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

ID 683846
Date 12/19/2022
Document Table of Contents Interaction between RTL Module and External Memory

Allow your RTL module to interact with external memory only if the interaction is necessary and unavoidable.

Important: The preferred method for having your RTL module interact with external memory is to have the OpenCL kernel access global memory and then feed that memory content to the RTL module. For operations like reading from and writing to external memory on every kernel invocation, instruct the OpenCL™ kernel to perform the operation. To do so, you can create an OpenCL helper function for the OpenCL kernel in the same Intel® FPGA SDK for OpenCL™ library as the RTL module.

The following examples demonstrate how to structure code in an RTL module for easy integration into an OpenCL library:

Table 18.  Example Code in an RTL Module that Interacts with External Memory
Complex RTL Module Simplified RTL Module
// my_rtl_fn does:
// out_ptr[idx] = fn(in_ptr[idx])
my_rtl_fn (in_ptr, out_ptr,idx);
int in_value = in_ptr[idx];
// my_rtl_fn now does: out = fn(in)
int out_value = my_rtl_fn (in_value);
out_ptr[idx] = out_value;

The complex RTL module on the left reads a value from external memory, performs a scalar function on the value, and then writes the value back to global memory. Such an RTL module is difficult to describe when you integrate it into an OpenCL library. In addition, this RTL module is harder to verify and causes very conservative pointer analysis in the Intel® FPGA SDK for OpenCL™ Offline Compiler.

The simplified RTL module on the right provides the same overall functionality as the complex RTL module. However, the simplified RTL module only performs a scalar-to-scalar calculation without connecting to global memory. Integrating this simplified RTL module into the OpenCL library makes it much easier for the offline compiler to analyze the resulting OpenCL kernel.

There are times when an RTL module requires an Avalon® memory-mapped interface port to communicate with external memory. This Avalon® memory-mapped interface port connects to the same arbitration network to which all other global load and store units in the OpenCL kernels connect.

If an RTL module receives a memory pointer as an argument, the offline compiler enforces the following memory model:

  • If an RTL module writes to a pointer, nothing else in the OpenCL kernel can read from or write to this pointer.
  • If an RTL module reads from a pointer, the rest of the OpenCL kernel and other RTL modules may also read from this pointer.
  • You may set the access field of the MEM_INPUT attribute to specify how the RTL module uses the memory pointer. Ensure that you set the value for access correctly because there is no way to verify the value.

Did you find the information on this page useful?

Characters remaining:

Feedback Message