An optimal AXI4 interface is one in which the design never stalls while waiting to access the bus, and after bus access is granted, the bus never stalls while waiting for the design to read/write. To create the optimal AXI4 interface, the following options are provided in the INTERFACE pragma or directive to specify the behavior of burst access and optimize the efficiency of the AXI4 interface. Refer to AXI Burst Transfers for more information on burst transfers.
In some cases, where autmatic burst access has failed, an efficient solution is to re-write the code or use manual burst as described in Using Manual Burst. If that does not work, then another solution might be to use cache memory in the AXI4 interface using the CACHE pragma or directive.
volatile
qualifier on the variable prevents burst access to reado or write
it. Some of these options use internal storage to buffer data and can have an impact on area and resources:
-
latency
: Specifies the expected latency of the AXI4 interface, allowing the design to initiate a bus request a number of cycles (latency) before the read or write is expected. If this figure is too low, the design will be ready too soon and can stall waiting for the bus. If this figure is too high, bus access might be granted but the bus can stall waiting on the design to start the access. -
max_read_burst_length
: Specifies the maximum number of data values read during a burst transfer. -
num_read_outstanding
: Specifies how many read requests can be made to the AXI4 bus, without a response, before the design stalls. This implies internal storage in the design, a FIFO of size:num_read_outstanding
*max_read_burst_length
*word_size
. -
max_write_burst_length
: Specifies the maximum number of data values written during a burst transfer. -
num_write_outstanding
: Specifies how many write requests can be made to the AXI4 bus, without a response, before the design stalls. This implies internal storage in the design, a FIFO of size:num_write_outstanding
*max_write_burst_length
*word_size
The following example can be used to help explain these options:
#pragma HLS interface mode=m_axi port=input offset=slave bundle=gmem0
depth=1024*1024*16/(512/8)
latency=100
num_read_outstanding=32
num_write_outstanding=32
max_read_burst_length=16
max_write_burst_length=16
The interface is specified as having a latency of 100. Vitis HLS seeks to schedule the request for burst
access 100 clock cycles before the design is ready to access the AXI4 bus. To further improve bus efficiency, the options
num_write_outstanding
and num_read_outstanding
ensure the design contains enough buffering to store
up to 32 read and write bursts. This allows the design to continue processing until the
bus requests are serviced. Finally, the options max_read_burst_length
and max_write_burst_length
ensure the maximum burst size is 16 and that the
AXI4 interface does not hold the bus for longer
than this.
These options allow the behavior of the AXI4 interface to be optimized for the system in which it will operate. The efficiency of the operation does depend on these values being set accurately.