I was trying to write some imperative code with data struct, where we multiply two values from a data struct and assign the product back to another struct.
stype = hcl.Struct({"fa": ccl.Int(), "fb": ccl.Fixed(12,8)})
t = hcl.scalar(tensor[r,c], dtype=stype)
r = hcl.scalar(0, dtype=stype)
r.v.fa = t.v.fa * t.v.fb
The generated code failed to capture the computation r.v.fa = t.v.fa * t.v.fb and outputs some incomplete convertors for it like this.
The workaround is to write the program in the following way.
stype = hcl.Struct({"fa": ccl.Int(), "fb": ccl.Fixed(12,8)})
t = hcl.scalar(tensor[r,c], dtype=stype)
r = hcl.scalar(0, dtype=stype)
x = hcl.scalar(t.v.fa)
y = hcl.scalar(t.v.fb)
r.v.fa = x.v * y.v
The generated code has some redundant bit slicing operations, which confuses Vivado HLS in streaming channel analysis, and leads to pre-synthesis failure.
ap_uint<32> _converter;
// Vivado HLS complains grad_x has been consumed more than once
_converter(31, 0) = grad_x[(x + (y * 1024))](31,0);
// We have to manually remove the bit-slicing operation
// so that grad_x can be implemented as a FIFO
_converter(31, 0) = grad_x[(x + (y * 1024))];
The generated code failed to capture the computation
r.v.fa = t.v.fa * t.v.fb
and outputs some incomplete convertors for it like this.The workaround is to write the program in the following way.