cornell-zhang/heterocl

Support for hls::stream in VHLS backend

Closed this issue · 8 comments

The FIFO is implemented as an annotated multi-dim array in VHLS backend:

int fifo[100];
#pragma HLS STREAM variable=fifo depth=100

However, this makes it hard to declare multiple FIFO channels (which is needed when combining tiling and streaming).

hls::stream FIFO_arr[O];
for (outer, O)
    for (inner, I)
        FIFO_arr[outer].write(data);

Why is it difficult to declare multiple FIFO channels using the array-based coding style?

@zhangzhiru I meant currently in heterocl we are not able to do so. It is not a problem in HLS.

I see. Can you provide a high-level reason why this is hard in HeteroCL?

@zhangzhiru This is not hard to implement in HeteroCL. This issue is opened just for bookkeeping, and it will be supported in the next release.

@chhzh123 you're saying you've already modified the codegen logic to generate hls::stream?

@chhzh123 you're saying you've already modified the codegen logic to generate hls::stream?

Yes, I use a simple but tricky way to generate the stream reads and writes -- If _pipe or _channel is in variable names, then the varible is supposed to be a stream buffer. This method is used by Shaojie at the very beginning, where only the VHLS codegen needs to be changed. However, to distinguish a normal buffer and a stream buffer, it would be better to register a new IR node, like StreamAllocate. I think @hecmay has done this and make the stream buffers generation robust in his PR?

Yes. This has been done in #265. The load and store operations on FIFOs are replaced into StreamStmt and StreamExpr1 IRs, and will be printed as hls:stream.write() and hls::stream.read().