Fifa-Memo.com

how does an async fifo work

by Tate Satterfield Published 2 years ago Updated 2 years ago
image

An asynchronous FIFO refers to a FIFO design where data values are written to a FIFO buffer from one clockdomain and the data values are read from the same FIFO buffer from another clock domain, where the two clockdomains are asynchronous to each other. Asynchronous FIFOs are used to safely pass data from one clock domain to another clock domain.

An asynchronous FIFO refers to a FIFO design where data values are written to a FIFO buffer from one clock domain and the data values are read from the same FIFO buffer from another clock domain, where the two clock domains are asynchronous to each other.Nov 30, 2000

Full Answer

What is asynchronous FIFO?

Asynchronous FIFO's are widely used to safely pass the data from one clock domain to another clock domain. Continuous reading Asynchronous FIFO design pdf provided below which covers Asynchronous FIFO test bench written in verilog language.

How does a synchronizer work in FIFO?

In order to avoid such scenarios, the reading and writing is done via a synchronizer. The synchronizer ensures that read and write pointers calculations are consistent and data in FIFO is not accidentally overwritten or read twice.

Does clock crossing affect FIFO full and empty conditions?

However, with the clock crossing we need to ensure that FIFO full and empty conditions are taking into account the clock crossing cycles. In other words, pessimistic full and empty conditions need to be added. Here’s an example to 8-deep FIFO with Write in aclk domain and read in bclk domain:

How does the FIFO interface work?

Cummings’ FIFO has the basic interface shown on the right in Fig 6. Operation starts in the write domain, where i_wdata is written to the FIFO anytime i_wr is true and the o_wfull flag is false. The data can then be read later from o_rdata any time i_rd is true and o_rempty is false, in the values o_rdata.

image

Why is FIFO asynchronous?

An Asynchronous FIFO refers to a FIFO where the data values are written to the FIFO at a different rate and data values are read from the same FIFO at a different rate, both at the same time. The reason for calling it Asynchronous FIFO, is that the read and write clocks are not Synchronized.

How does a 2 clock FIFO work?

This dual clock FIFO is designed as a way for two circuits operating in different clock frequencies to communicate with each other. There is a read side and write side where data is stored into the internal memory of the FIFO using the write side clock and then read from the internal memory using the read side clock.

What is the difference between asynchronous FIFO and synchronous FIFO?

FIFO can be either synchronous or asynchronous. The basic difference between them is that the entire operation of synchronous FIFO is entirely dependent on the clock where as the write operation and read operation of asynchronous FIFO are asynchronous to each other.

How do you verify asynchronous FIFO?

Only read.Only write.Read and write simultaneously.write full.read empty.full and empty are mutually exclusive.simultaneously write_full and read_empty are active ( When read-side-clk is deactivated and other side it is writing)check reset behavior.More items...•

How do you calculate asynchronous FIFO depth?

Example : FIFO Depth Calculation If if we have alternate read cycles i.e between two read cycle there is IDLE cycle. If 10 IDLE cycles betweeen two read cycles . FIFO DEPTH = B - B *F2/(F1*10) .

How does FIFO memory work?

A FIFO is a special type of buffer. The name FIFO stands for first in first out and means that the data written into the buffer first comes out of it first. There are other kinds of buffers like the LIFO (last in first out), often called a stack memory, and the shared memory.

Why gray code is used in asynchronous FIFO?

You use gray code counters in asynchronous FIFO design where the write pointer is in a different clock domain than the read pointer, AND, when the pointers are multi-bit. This is to correctly detect full and empty conditions.

What is the difference between synchronous and asynchronous?

The key difference between synchronous and asynchronous communication is synchronous communications are scheduled, real-time interactions by phone, video, or in-person. Asynchronous communication happens on your own time and doesn't need scheduling.

What are Fifos used for?

FIFO stands for “First-In, First-Out”. It is a method used for cost flow assumption purposes in the cost of goods sold calculation. The FIFO method assumes that the oldest products in a company's inventory have been sold first. The costs paid for those oldest products are the ones used in the calculation.

How do you know if FIFO is synchronous?

The synchronous FIFO design involves implementation of a memory array and associated write/read control logic at the RTL level using Verilog HDL. A verification environment [7] is developed using SystemVerilog and the UVM library to verify the functionality of the Synchronous FIFO design model.

How do you determine FIFO?

To calculate FIFO (First-In, First Out) determine the cost of your oldest inventory and multiply that cost by the amount of inventory sold, whereas to calculate LIFO (Last-in, First-Out) determine the cost of your most recent inventory and multiply it by the amount of inventory sold.

What is verification plan in SV?

VERIFICATION PLAN. The Verification Plan is the focal point for defining exactly what needs to be tested, and drives the coverage criteria. Success of a verification project relies heavily on the completeness and accurate implementation of a verification plan.

Basic FIFO

If you’ve never wrestled with the concept of an asynchronous FIFO before, you might ask yourself what the big deal is? Indeed, in many ways an asynchronous FIFO is just like any other FIFO.

Comparing Gray coded pointers

Let’s examine how we might use these two Gray pointers. Remember, we need to determine when the FIFO is empty and when it is full. Before, we had the two lines,

The Asynchronous Reset

Cummings’ design includes two negative logic asynchronous reset signals, i_wrst_n, and i_rrst_n. These two resets are related to each other. Specifically, we’ll assume that the two resets will always be asserted at the same time together, but that they are only ever de-asserted with their respective clocks.

Assuming Synchronous Inputs

Whenever you build a set of formal properties to describe logic in multiple clock domains , you’ll want to assume that the inputs associated with each clock domain remain synchronous to that domain .

Verifying the Reset

My readers should understand why I use f_past_valid: if you make an assertion using the $past operator, one were the $past () operator references a value before the initial time began, then the solver can immediately declare that assertion to be invalid. Not only that, there will be no trace associated with that past assertion.

Verifying the Fill Levels

All of the steps so far have been preliminary, set up sorts of things. None of them have actually impacted the proof requirements we listed above. Let’s now move into the actual FIFO properties associated with its operation. We’ll start with the pointers in this section, and then verify the two element write test in the next section.

FIFO Contract

Fig 9. Two consecutive items written to a FIFO, must be able to be read out consecutively at a later time

What is asynchronous FIFO?

An asynchronous FIFO is a proven design technique to pass multi-bit data across a clock domain crossing. This article describes one known good method to design an asynchronous FIFO by synchronizing Gray code pointers across the clock domain crossing to determine full and empty conditions.

How to determine if a FIFO is full or empty?

In a synchronous FIFO design, one way to determine whether a FIFO is full or empty is to use separate count register to track the number of entries in the FIFO. This requires the ability to both increment and decrement the counter, potentially on the same clock. The same technique cannot be used in an asynchronous FIFO, however, because two different clocks will be needed to control the counter.

What does the write pointer do in a FIFO?

The write pointer always points to the next location to be written; the read pointer always points to the current FIFO entry to be read. On reset, both pointers are reset to zero. The FIFO is empty when the two pointers (including the extra bit) are equal.

Can asynchronous FIFO be used in asynchronous FIFO?

The same technique cannot be used in an asynchronous FIFO, however, because two different clocks will be needed to control the counter. Instead, the asynchronous FIFO design uses a different technique (also derived from synchronous FIFO design) of using an additional bit in the FIFO pointers to detect full and empty.

What is a synchronous FIFO?

Synchronicity. A synchronous FIFO is a FIFO where the same clock is used for both reading and writing. An asynchronous FIFO uses different clocks for reading and writing and they can introduce metastability issues.

What is a FIFO in a network?

Communication network bridges, switches and routers used in computer networks use FIFOs to hold data packets in route to their next destination. Typically at least one FIFO structure is used per network connection.

When was the first FIFO implemented?

The first known FIFO implemented in electronics was by Peter Alfke in 1969 at Fairchild Semiconductor. Alfke was later a director at Xilinx .

What is a FIFO?

FIFOs are commonly used in electronic circuits for buffering and flow control between hardware and software. In its hardware form, a FIFO primarily consists of a set of read and write pointers, storage and control logic. Storage may be static random access memory (SRAM), flip-flops, latches or any other suitable form of storage.

What is FCFS in computer science?

FCFS is also the jargon term for the FIFO operating system scheduling algorithm, which gives every process central processing unit (CPU) time in the order in which it is demanded . FIFO's opposite is LIFO, last-in-first-out, where the youngest entry or "top of the stack" is processed first.

image

Asynchronous FIFO Pointers

Image
In a synchronous FIFO design, one way to determine whether a FIFO is full or empty is to use separate count register to track the number of entries in the FIFO. This requires the ability to both increment and decrement the counter, potentially on the same clock. The same technique cannot be used in an asynchronous FIFO…
See more on verilogpro.com

Synchronizing Pointers Across Clock Domains

  • Synchronizing a binary count (pointer) across clock domains is going to pose a difficulty, however. All bits of a binary counter can change simultaneously, for example a 4-bit count changing from 7->8 (4’b0111->4’b1000). To pass this value safely across a clock domain crossing requires careful synchronization and handshaking such that all bits are sampled and synchroniz…
See more on verilogpro.com

Gray Code Counter

  • The Gray code counter used in this design is “Style #2” as described in Cliff Cumming’s paper. The FIFO counter consists of an n-bit binary counter, of which bits [n-2:0] are used to address the FIFO memory, and an n-bit Gray code register for storing the Gray count value to synchronize to the opposite clock domain. One important aspect about a Gray code counter is they generally must …
See more on verilogpro.com

Constraining Timing of The Gray Code Signals

  • A coworker educated me that there is one more piece needed, after coding the gray code counters. Gray code solves metastability because the destination sees only 1 bit changing at any time. However, without specifying a timing constraint, it is possible for the design to be implemented as circuitry on silicon (or FPGA) such that the different bits of the gray code count…
See more on verilogpro.com

Generating Full & Empty Conditions

  • The FIFO is empty when the read pointer and the synchronized write pointer, including the extra bit, are equal. In order to efficiently register the rempty output, the synchronized write pointer is actually compared against the rgraynext (the next Gray code to be registered into rptr). The full flag is trickier to generate. Dissecting the Gray code sequence, you can come up with the followi…
See more on verilogpro.com

Asynchronous FIFO (Style #1) – Putting It Together

  • Here is the complete asynchronous FIFO put together in a block diagram. The design is partitioned into the following modules. 1. fifo1 – top level wrapper module 2. fifomem – the FIFO memory buffer that is accessed by the write and read clock domains 3. sync_r2w – 2 flip-flop synchronizer to synchronize read pointer to write clock domain 4. sync_w2r – 2 flip-flop synchro…
See more on verilogpro.com

Conclusion

  • An asynchronous FIFO is a proven design technique to pass multi-bit data across a clock domain crossing. This article describes one known good method to design an asynchronous FIFO by synchronizing Gray code pointers across the clock domain crossing to determine full and empty conditions. Whew! This has been one of the longer articles. I’m simultaneously surprised that 1) …
See more on verilogpro.com

References

  1. Simulation and Synthesis Techniques for Asynchronous FIFO Design
  2. Frank Gray, “Pulse Code Communication.” United States Patent Number 2,632,058. March 17, 1953
See more on verilogpro.com

Sample Source Code

  • The accompanying source code for this article is the dual-clock asynchronous FIFO design with testbench, which generates the following waveform when run. Download and run the code to see how it works!
See more on verilogpro.com

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9