03-12-2013 07:29 PM
I am encountering the following issue. I have a 256-bit AXI4 bus in the platform. I have computed an integer array in the Vivado_hls-synthesized pcore. I want to use memcpy to transfer the array to DRAM via the AXI4 bus at the maximum possible throughput, i.e., 8 integers per clock cycle. Here is how I try to implement it:
void pcore( volatile uint256* bus, volatile int* addr_fifo )
#pragma AP interface ap_bus port=bus
#pragma AP resource core = AXI4M variable=bus
#pragma AP interface ap_fifo port=ctrl_fifo
compute_on( a );
int addr = *ctrl_fifo;
int buf_offset = addr % ( sizeof(uint256) / sizeof(int) );
reorder_data_layout_from_to( a, b, buf_offset );
int length = ( 1000 - buf_offset ) * sizeof(int);
memcpy( bus + (addr / sizeof(int), b + ( buf_offset / sizeof(int) ), length )
I did allignment on both the two addresses in memcpy so that there is no shifting. However when "addr" is something like 0xC0000010 which is not alligned on the uint256 boundary, the offset "10" will still get lost. If I don't want to lose anything at the starting address since there are some useful data stored in range 0xC00000000 ~ 0xC0000010 and I want my data to be placed right after that range, what should I do? Thank you very much!
05-09-2014 02:46 AM
I know that you might have solved the issue already, but I stumbled upon it right now.
The problem is that your bus is 256-bit
so any offset that you add to your bus (bus + offset) gives you the same address/pointer like &(bus[offset]). Adding an integer to a pointer does not add the integer to the adress value it moves the pointer forward to the element representing that value starting at the address defined by the pointer. (Standard C)
The address in your case would be: (unsigned int)bus + (256/8)*offset.
If you have unaligned 256 bit transfers you have to take care of that yourself or use a DMA and FIFO-based approach which can do the realignment for you.
Are you on the Zynq? The bus to the DDR is limited to 32/64 bit. (HP). So you can as well take that Bus-Width.
05-12-2014 06:38 AM