cornell-zhang/heterocl

Include headers for imported external IP

Closed this issue · 1 comments

Expected input

When incorporating the external IPs into generated HLS code, we should create non-inlined function call, and include a header before the function call is initiated. The current version IP integration just copy the content into the generated, which is not correct.

def top(...):
    with hcl.Stage("ip") as Module:
        pass

    Moduel.func_name = "func"
    Module.inputs = [A, B, ret, length]
    Module.source = [ os.path.dirname(os.path.abspath(__file__)) + "/vadd.cpp"]
    create_extern_module(Module, ip_type="HLS")

Expected output

The IP integration logic should automatically check the function name, and its argument types. Before the compilation, the IP integration function should check the legality the interface (i.e. FIFO interface should be connected to another FIFO. The program will throw an error if an FIFO is connected to an array pointer).

The expected output HLS code with IP:

void default_function(hls::stream<float>& input, hls::stream<float> &output) {
  #include "ip.h" // auto-generated or user provided header file 
  extern_ip(input, output);
}

Fixed in PR #355