cornell-zhang / heterocl

HeteroCL: A Multi-Paradigm Programming Infrastructure for Software-Defined Heterogeneous Computing
https://cornell-zhang.github.io/heterocl/
Apache License 2.0
322 stars 92 forks source link

Include headers for imported external IP #297

Closed hecmay closed 3 years ago

hecmay commented 3 years ago

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);
}
hecmay commented 3 years ago

Fixed in PR #355