AXI4-Lite Interface and Control Protocols - 2020.2 English

Versal ACAP AI Engine Programming Environment User Guide (UG1076)

Document ID
UG1076
Release Date
2020-11-24
Version
2020.2 English

To conform to stream interface protocol and data flow graph control semantics, PL kernels (whether written in HDL or HLS) are required to adhere to one or more of the following interface protocols.

  • Block level: AXI4-Lite interface with ap_ctrl_hs protocol.

    For HLS kernels, the corresponding INTERFACE pragma is:

    #pragma HLS interface s_axilite port=return bundle=control
    #pragma HLS interface ap_ctrl_hs port=return
    Important: When a PL kernel inside a graph is under the control of the ADF API in each adf::graph::run, the PL kernel is started once, regardless of the number of iterations set for adf::graph::run(). However, in each graph adf::graph::run(), an AI Engine kernel will run the number of iterations set for adf::graph::run(). In the graph adf::graph::wait(), both the AI Engine kernel and PL kernel inside the graphs are waiting to be completed. Make sure that the AI Engine kernel and PL kernel inside the graph can start and complete in synchronous mode.
  • hls::stream port: AXI4-Stream interface.

    For HLS kernels, the corresponding INTERFACE pragma is:

    #pragma HLS interface axis port={hls::stream port name}
  • Synchronous run-time parameter (RTP): AXI4-Lite interface with the ap_hs protocol.

    For HLS kernels, the corresponding INTERFACE pragmas are:

    #pragma HLS interface s_axilite port={RTP port name} bundle=control
    #pragma HLS interface ap_hs port={RTP port name}
  • Asynchronous RTP: AXI4-Lite interface with the ap_none protocol.

    For HLS kernels, the corresponding INTERFACE pragmas are:

    #pragma HLS interface s_axilite port={RTP port name} bundle=control
    #pragma HLS interface ap_none port={RTP port name}
    Important: An asynchronous run-time parameter for a PL kernel should be initialized using adf::graph::update before adf::graph::run.
  • Asynchronous array run-time parameter: AXI4-Lite interface with the ap_memory protocol.

    For HLS kernels, the corresponding INTERFACE pragmas are:

    #pragma HLS interface s_axilite port={RTP port name} bundle=control
    #pragma HLS interface ap_memory port={RTP port name}
  • Array or pointer port: Memory-mapped AXI4 interface.

    For HLS kernels, the corresponding INTERFACE pragmas are:

    #pragma HLS interface m_axi port=mem offset=slave
    #pragma HLS interface s_axilite port=mem bundle=control

Using the previous hls_mul function as an example, and assuming inputParam and loop_count are asynchronous run-time parameters, the required HLS pragmas to conform with the data flow semantics are:

#include "hls_stream.h"
#include "ap_int.h"
extern "C" void hls_mul(hls::stream<ap_axis<32,0,0,0>>& in, hls::stream<ap_axis<32,0,0,0>>& out, ap_int<32> inputParam, unsigned int loop_count)
{
#pragma HLS interface axis port=in
#pragma HLS interface axis port=out
#pragma HLS interface s_axilite port=inputParam bundle=control
#pragma HLS interface ap_none port=inputParam
#pragma HLS interface s_axilite port=loop_count bundle=control
#pragma HLS interface ap_none port=loop_count
#pragma HLS interface s_axilite port=return bundle=control
#pragma HLS interface ap_ctrl_hs port=return
  for (unsigned int n=0; n<loop_count; n++)
  {
    for (int i=0; i<8; i++)
    {
      ap_axis<32,0,0,0> value = in.read();
      value.data *= inputParam;
      out.write(value);
    }
  }
}

Here, loop_count can be used to control the loop count when adf::graph::run is called. Before each adf::graph::run, call adf::graph::update to update the loop_count and the samples by PL kernel will match the samples by AI Engine kernel with adf::graph::run(<ITERATION_NUM>).

Free-running Programmable Logic Kernels without AXI4-Lite Interface

By default, all PL kernels inside the graph are free-running (that is, run forever after reset). The free-running kernels are kernels without any AXI4-Lite interface and control protocols.

To support PL kernels with an AXI4-Lite interface and control protocols, add --pl-axi-lite=true option (default is false) to the AI Engine compiler (aiecompiler).

HLS Programmable Logic Kernels AXI4-Lite Interface

The run-time parameter is supported using the AXI4-Lite interface. To use the AXI4-Lite interface, add the --pl-axi-lite=true option to the AI Engine compiler.