I am writing a normal bandwidth kernel in C++ for FPGA, which is reading something from host memory and writing it back to different location in host.
I'm using structs, one of whose elements is addresses for input and output buffers. High-level synthesis tool is giving error for the last line in the following code.
T * pa = ...
U bb = ...
V cc = ...
T dd = ???_cast< T* >( pa + bb + cc * 64 );
???_cast< T* >( pa + bb + cc * 64 ) = dd; // error
The pa is a pointer (T*), while bb, cc and 64 are not.
The bb and cc presumably behave like integers and in that case the type of the pa + bb + cc * 64 would be T*.
1 2 3
T* bar;
T foo;
foo = (T*)(bar); // hmmm
An explicit (C-style) cast from T* into T* does seem unnecessary.
1 2 3 4
T* bar;
T foo;
foo = bar; // scary
bar = foo; // scary
The pa + bb + cc * 64 may be an address, but it is not a named variable. Assignment to unnamed temporary pointer ...
It seems to work. (din_mem + CA_INPUT.address + i*64) is indeed an address. But it's not incrementing the addresses by 64. For the first 64 bytes, temp gets the value which is pointed by input address. But for subsequent iterations of for loop, temp remains 0.
Is there a different way to increment the addresses?