Intel® High Level Synthesis Compiler Pro Edition: Reference Manual

ID 683349
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

4.4.2. Implicit and Explicit Examples of Describing a Memory Interface

Optimize component code that describes a memory interface by specifying an explicit mm_host object.

Implicit Example

The following code example arbitrates the load and store instructions from both pointer dereferences to a single interface on the component's top-level module. This interface will have a data bus width of 64 bits, an address width of 64 bits, and a fixed latency of 1.

#include "HLS/hls.h"
component void dut(int *ptr1, int *ptr2) {
 *ptr1 += *ptr2;
 *ptr2 += ptr1[1];
}

int main(void) {
  int x[2] = {0, 1};
  int y = 2;

  dut(x, &y);

  return 0;
}

Explicit Example

This example demonstrates how to optimize the previous code snippet for a specific memory interface using the explicit mm_host class. The mm_host class has a defined template, and it has the following characteristics:

  • Each interface is given a unique ID that infers two independent interfaces and reduces the amount of arbitration within the component.
  • The data bus width is larger than the default width of 64 bits.
  • The address bus width is smaller than the default width of 64 bits.
  • The interfaces have a fixed latency of 2.

By defining these characteristics, you state that your system returns valid read data after exactly two clock cycles and that the interface never stalls for both reads and writes, but the system must be able to provide two different memories. A unique physical Avalon® MM host port ( as specified by the aspace parameter) is expected to correspond to a unique physical memory. If you connect multiple Avalon® MM Host interfaces with different physical Avalon® MM host ports to the same physical memory, the Intel® HLS Compiler cannot ensure functional correctness for any memory dependencies.

#include "HLS/hls.h"

typedef ihc::mm_host<int, ihc::dwidth<256>,
                          ihc::awidth<32>,
                          ihc::aspace<1>, 
                          ihc::latency<2> > Host1;
typedef ihc::mm_host<int, ihc::dwidth<256>,
                          ihc::awidth<32>,
                          ihc::aspace<4>,
                          ihc::latency<2> > Host2;

component void dut(Host1 &mm1,Host2 &mm2) {
  *mm1 += *mm2;
  *mm2 += mm1[1];
}
int main(void) {
  int x[2] = {0, 1};
  int y = 2;

  Host1 mm_x(x,2*sizeof(int),false);
  Host2 mm_y(&y,sizeof(int),false);

  dut(mm_x, mm_y);

  return 0;
}