This is "Poki".
There was a strange sounding word I heard at a company meeting.
It is FIFO, which is also in the title.
I was curious and looked it up.
What is FIFO?
FIFO (First-In First-Out) is a type of memory, which directly translates to "first in, first out.
The first in (oldest) goes out first. Isn't that a matter of course?
In both convenience stores and supermarkets, products that are close to their expiration date (lined up first) are put out first to make it easier to pick them up, don't you think?
This is also the FIFO way of thinking! This is also a FIFO concept, isn't it?
How FIFO works
So I decided to check how FIFO works.
FIFO is registered as a Megafunction of Quartus II, so we will use it.
In Quartus II 14.0, you can select an IP Catalog from the Tools menu to select a Megafunction that has been registered in advance.
(In versions prior to Quartus II 13.1, select MegaWizard Plug-In Manager from the Tools menu.)
In this case, we have chosen the minimum configuration and created a 4-bit × 4-word FIFO running on a single clock (Figure 1). (Figure 1)
Figure 1: 4 bit × 4 word FIFO
Among the input signals, write is a signal that enables new data to be written into the FIFO when it is set to 1.
When read is 1, it is a signal that enables the oldest data written in the FIFO to be read out and reflected in the output q.
The operation is shown in Figure 2.
Figure 2: FIFO Operation
The output signal is full = 1 when 4 words are filled, and conversely empty = 1 when there is nothing in the FIFO.
Question
At this point, I had questions about the following three situations.
1. What value is output when read = 0?
2. What happens to the data inside if I write when full = 1?
3. What values are output when read = 1 and write = 1 with empty = 1?
We will verify these three questions by running simulations in ModelSim!
Question 1 : What values are output when read = 0?
What value will be output when the data in the FIFO is not read?
Is it indefinite?
Is it 0000?
Or, is the value read out one before output?
Verification:
Data is written for 4 words (write = 1) and only 2 words are read (write = 0 and read = 1),
Then look at the value of output q when reading is stopped (read = 0).
Result:
The result is shown in Figure 3.
Figure 3: When read = 0
Looking at the value of output q, "0010" written in the second word is output as it is in the third clock cycle.
The result is
" The same value is output as before read = 0".
When read = 0, the previous value is output as it is.
Question 2: What happens to the data inside when full = 1?
What happens to the data inside when only writing when 4 words have already been written (full = 1)?
Is it overwritten?
Does the oldest data disappear and the newest data is written?
Or, is each bit ORed?
Verification:
Since we are using a 4-word FIFO, we write 5 words (write = 1), which is one more than the number of words in the FIFO, and after the writing is finished, we perform a read operation (write = 0 and read = 1).
After writing, read (write = 0 and read = 1) 5 times. What will be the output of the 5th word?
The result:
The result is as shown in Figure 4.
Figure 4: Output when 5 words are written into a 4-word FIFO
The "0110" written in the 5th word is not output when checking the output q.
The result is "Not written."
We now know that the data in the FIFO will not be overwritten until full = 0.
Question 3: If read = 1 and write = 1 with empty = 1, what values are output?
What is output when write and read are performed simultaneously when there is no data in the FIFO?
Unspecified?
0000?
Or the same value as before?
Verification:
Write 2 words (write = 1), read 2 words (read = 1), and then look at the output when read and write are performed simultaneously (write = 1 and read = 1).
Result:
The results are shown in Figure 5.
Figure 5: Output when reading and writing are performed simultaneously
The written data "1000" is not immediately output, but the previous value "0101" is output.
Therefore, the result is
"Same output as the previous one."
In the single clock FIFO created this time, we found that when empty = 1, the written data is output one clock after it is written.
In the single clock FIFO, it takes one clock to write, one clock to read, and one clock to output data,
Therefore, the data is output 1 clock after "read" is completed.
Finally
We now know that a FIFO is a type of memory because it can store data.
The concept of "first in, first out" is that the data in the FIFO is not overwritten, and when reading is stopped, the FIFO outputs the same value as the last time it was read.
In fact, it is said to be used as a primary storage buffer to avoid heavy processing when processing data acquired for such purposes as keeping data input order, not being overwritten, and so on.
From this verification, I now understand why it is used for this purpose. FIFO,” which sounds strange, is actually an order-keeping memory.
The point of this time
A FIFO is a memory that holds data until a read request comes in and keeps the order of input data.
When the data in the FIFO is full, newly input data is not taken in.
If read/write operations are performed while the data in the memory is empty, three clocks are required for "write," "read," and "output,
The data is output one clock after "read" is completed.
New Engineer's Blush Blog Article List