2.4.1. Nanos6 FPGA Architecture API

The following sections list and summarize the Nanos++ FPGA Architecture API. The documentation is for the version 10.

2.4.1.1. Memory Management

2.4.1.1.1. nanos6_fpga_malloc

Allocates memory in the FPGA address space and returns a pointer valid for the FPGA tasks. The returned pointer cannot be dereferenced in the host code.

Arguments:
  • size: Size in bytes to allocate.
  • fpga_addr: Pointer to the FPGA address space as a 64-bit integer.
Return value:
  • NANOS6_FPGA_SUCCESS on success, NANOS6_FPGA_ERROR on error.
typedef enum {
    NANOS6_FPGA_SUCCESS,
    NANOS6_FPGA_ERROR
} nanos6_fpga_stat_t;

nanos6_fpga_stat_t nanos6_fpga_malloc(uint64_t size, uint64_t* fpga_addr);

2.4.1.1.2. nanos_fpga_free

nanos6_fpga_stat_t nanos6_fpga_free(uint64_t fpga_addr);

2.4.1.1.3. nanos_fpga_memcpy

typedef enum {
    NANOS6_FPGA_DEV_TO_HOST,
    NANOS6_FPGA_HOST_TO_DEV
} nanos6_fpga_copy_t;

nanos6_fpga_stat_t nanos6_fpga_memcpy(
    void* usr_ptr,
    uint64_t fpga_addr,
    uint64_t size,
    nanos6_fpga_copy_t copy_type);

2.4.1.2. Data copies

These Nanos6 API only can be called inside an FPGA task. They alloy copies to be performed through a single port that can be wider than the data type being copied.

If any of the data copy API calls are used, the fompss-fpga-memory-port-width option is mandatory.

Data accessed through this functions, has to be aligned to the port width. Otherwise this will result in undefined behaviour.

Also, data should to be multiple of the port width. If this cannot be guaranteed, fompss-fpga-check-limits-memory-port option is needed so that no out of bounds data is accessed. Otherwise this will result in undefined behaviour.

2.4.1.2.1. nanos6_fpga_memcpy_wideport_in

nanos6_fpga_stat_t nanos6_fpga_memcpy_wideport_in(void* dst, const unsigned long long int addr, const unsigned int num_elems);

Arguments:

  • dst: Pointer to the destination (local) data. It can be any data type.
  • addr: FPGA memory address space where the data is stored.
  • num_elems: Number of elements of the array type to be copied.

2.4.1.2.2. nanos6_fpga_memcpy_wideport_out

nanos6_fpga_stat_t nanos6_fpga_memcpy_wideport_out(void* dst, const unsigned long long int addr, const unsigned int num_elems);

Arguments:

  • dst: Pointer to the source (local) data. It can be any data type.
  • addr: FPGA memory address space where the data is written.
  • num_elems: Number of elements of the array type to be copied.