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

ID 683846
Date 12/13/2021
Public

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

Document Table of Contents

11.1. OpenCL Library

An OpenCL™ library is a single file that contains multiple functions. Each function is comprised of data processing logic that works at any clock frequency.
Note: To understand how to create a static library file using SYCL, refer to Use of Static Library for FPGA in the Intel® oneAPI Programming Guide.

You can create an OpenCL library in OpenCL or register transfer level (RTL). You can then include this library file and use the functions inside your OpenCL kernels or in HLS components. For information about HLS libraries, refer to Intel High Level Synthesis Compiler: Reference Manual .

Figure 27. Overview of Intel® FPGA SDK for OpenCL™ 's Library Support

You may use a previously-created library or create your own library. To use an OpenCL library, you do not require in-depth knowledge in hardware design or in the implementation of library primitives. To create an OpenCL library, you need to create the following files:

Table 10.  Necessary Files and Components for Creating an OpenCL Library
File or Component Description
RTL Components
RTL source files Verilog, System Verilog, or VHDL files that define the RTL component.

Additional files such as Intel® Quartus® Prime IP File (.qip), Synopsys Design Constraints File (.sdc), and Tcl Script File (.tcl) are not allowed.

eXtensible Markup Language File (.xml) Describes the properties of the RTL component. The Intel® FPGA SDK for OpenCL™ Offline Compiler uses these properties to integrate the RTL component into the OpenCL pipeline.
Header file (.hcl) A header file that contains valid OpenCL kernel language and declares the signatures of function(s) that are implement by the RTL component.
OpenCL emulation model file (.cl) Provides C model for the RTL component that is used only for emulation. Full hardware compilations use the RTL source files.
OpenCL Functions
OpenCL source files (.cl) Contains definitions of the OpenCL functions. These functions are used during emulation and full hardware compilations.
Header file (.hcl) A header file describing the functions to be called from OpenCL in the OpenCL kernel language syntax.
HLS Functions  
HLS source files (.cpp) Contains definitions of the OpenCL functions. These functions are used during emulation and full hardware compilations.
Header file (.hcl) A header file describing the functions to be called from OpenCL in the OpenCL kernel language syntax.
Note:

There is no difference in the header file used for RTL, OpenCL, and HLS library functions. A single header file can have all types of functions declared. A single library can contain any of the supported sources. You can create a library from mixed sources (OpenCL, HLS, or RTL) and target these Intel® high-level design products:

  • Intel® FPGA SDK for OpenCL™ Pro Edition
  • Intel® High Level Synthesis Compiler Pro Edition

Creating a OpenCL library is a two-step process:

  1. Each object file is created from input source files using the fpga_crossgen command. The required input source files depend on the type of source code you are creating the object from.
    • An object is effectively an intermediate representation of your source code with both a CPU representation and an FPGA representation of your code.
    • An object can be targeted for use with only one Intel® high-level design product. If you want to target more than one high-level design product, you must generate a separate object for each target product.
  2. Object files are combined into a library file using the fpga_libtool command.

    Objects created from different types of source code can be combined into a library, provided all objects target the same high-level design product.

    A library is assigned a version number, and can be used only with the targeted high-level design product with the same version number (for example, Intel® FPGA SDK for OpenCL™ Pro Edition version 21.4).

Figure 28. High-level View of the Library Creation Process