imageNamaste FPGA
image
AXI2 min read

How to choose between Register, FIFO & RAM for AXI Peripherals.

When we build AXI peripherals, we frequently need storage for control information or data.

We have multiple alternatives for storage it could either be registers to store individual words, or we could adopt a FIFO or RAM inside the peripheral.

How do we choose which one to use?

#1) Let us first consider storing control or status information, such as a done flag. A common property of such information is that we need to access its current value, or the system’s operation depends on its current value.

For example, when we read a status register, we are interested in the current value of the done flag. We usually do not need to retain a history of its previous values.

In such scenarios, we need storage that retains the current value and allows it to be updated when necessary. A register is best for this purpose.

#2) The second situation is when we need to store multiple words until another module consumes them. For example, an ADC generates sensor samples, and we need to hold them until a UART transmits them. If the ADC generates samples faster than the UART can transmit them for a limited period, a FIFO can buffer the pending samples. Here sequence in which data geenrated by ADC matters and FIFO exhibit similar kind of behavior hence its best suitatble in this situation.

Once a sample is consumed, its storage space can be reused. A FIFO is suitable when data must be held until consumed and delivered in the same order in which it arrived.

#3) The third situation is when we need to access stored values by address. For example, an AI accelerator may store coefficients and retrieve a particular coefficient whenever needed. Similarly, a processor accesses its general-purpose registers by register number rather than arrival order. This requires addressable storage, such as RAM or a register file.

Therefore, use a register when you need to retain a current setting, status value, or individual word. Use a FIFO when you need to queue multiple words and consume them in arrival order. Use RAM when you need to store a collection of words and select which word to read or write by address.

image
image
5023 views