Skip to content

Commit

Permalink
[Codegen] Fix FIFO array reference & Add loop rewinding (cornell-zhan…
Browse files Browse the repository at this point in the history
  • Loading branch information
chhzh123 authored Dec 26, 2023
1 parent 511e65e commit 337cf82
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions lib/Translation/EmitVivadoHLS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,16 +1737,18 @@ void ModuleEmitter::emitArrayDecl(Value array, bool isFunc, std::string name) {

// print stream type
os << "hls::stream< " << getTypeName(array) << " > ";
if (isFunc) {
os << "&"; // pass by reference
}

// Add the new value to nameTable and emit its name.
os << addName(array, /*isPtr=*/false, name);

auto attr_str = attr.cast<StringAttr>().getValue().str();
int S_index = attr_str.find("S"); // spatial
int T_index = attr_str.find("T"); // temporal
if (isFunc &&
!(((int)(arrayType.getShape().size()) > T_index - S_index) &&
(T_index > S_index))) {
os << "&"; // pass by reference, only non-array needs reference
}

// Add the new value to nameTable and emit its name.
os << addName(array, /*isPtr=*/false, name);
if ((int)(arrayType.getShape().size()) > T_index - S_index) {
for (int i = 0; i < T_index - S_index; ++i)
os << "[" << arrayType.getShape()[i] << "]";
Expand Down Expand Up @@ -1849,8 +1851,11 @@ void ModuleEmitter::emitLoopDirectives(Operation *op) {
if (auto ii = getLoopDirective(op, "pipeline_ii")) {
reduceIndent();
indent();
os << "#pragma HLS pipeline II=" << ii.cast<IntegerAttr>().getValue()
<< "\n";
os << "#pragma HLS pipeline II=" << ii.cast<IntegerAttr>().getValue();
// https://docs.xilinx.com/r/en-US/ug1399-vitis-hls/Rewinding-Pipelined-Loops-for-Performance
if (op->hasAttr("rewind"))
os << " rewind";
os << "\n";
addIndent();
}

Expand Down

0 comments on commit 337cf82

Please sign in to comment.