Professional Documents
Culture Documents
Fpga Assignment 2 Osama
Fpga Assignment 2 Osama
Fpga Assignment 2 Osama
Grading:
Comments:
Section: Electronics
Assignment Title:
Design of 4MB RAM and FIFO module along with test
bench
Batch:
BSEE 2019-23
Semester
6th
1 Objectives:..........................................................................................................................4
2 Introduction:........................................................................................................................4
3 Procedure............................................................................................................................4
4 Results:................................................................................................................................5
4.3 Tasks............................................................................................................................6
5 FIFO Module....................................................................................................................10
5.1 Procedure:..................................................................................................................10
2 Introduction:
Random-access memory is a form of computer memory that can be read and changed in
any order, typically used to store working data and machine code. A random-access
memory device allows data items to be read or written in almost the same amount of time
irrespective of the physical location of data inside the memory.
FIFO is an approach for handling program work requests from queues or stacks so that
the oldest request is handled first. In hardware, it is either an array of flops or read/write
memory that stores data from one clock domain and on request supplies the same data
to other clock domains following FIFO logic
3 Procedure
Assigned RAM: 4MB
The address lines were computed as 𝑎 = 𝑙𝑜𝑔2(4000 ∗ 1024) and were taken as
22. The address lines were taken to be 8.
The memory was filled with write only commands and the data wrote was
random.
The read function was enabled, and the read function requested random
addresses between 0 and 4194304.
Read and write data was dumped into output text files.
Different task modules were used to implement the RAM testbench.
.
4 Results:
4.1 Main RAM module:
4.3.3 To write data in from the text file and update the write signal:
4.3.4 To read data from the text file and update the read signal;
4.3.5 To compare the two text files and see if they equal:
4.4 Console View:
The RAM assigned was 4Mb. The RAM module was defined and initialized. The
parameter was defined for the specific RAM which was parameter [23:0] DEPTH = 2^23.
Random data was stored into the RAM and then read when the read function was
enabled.The read and write data was stored in different output files respectively. Both the
data were compared using the compare function and the data was stored in an output file
named compare_data.txt as shown in the results section. Different task modules were used to
implement the RAM testbench as shown in section 4. In short, the data files were writte
according to the defined RAM and the outputs verified the correct working of the 4Mb RAM.
5 FIFO Module
5.1 Procedure:
FIFO is an approach for handling program work requests from queues or stacks so that
the oldest request is handled first. In hardware, it is either an array of flops or read/write
memory that stores data from one clock domain and on request supplies the same data
to other clock domains following FIFO logic. Hence, we first store some data into a text file.
We want that when we have a read signal the date input first comes out first.
To achieve that, a RAM module was used that stores the data is written in the file.
Read and write pointers were used that are basically the address of the read and
write location.
Code writes into FIFO when it is empty and Write signal is enabled
FIFO has some data and Read signal is enabled. If FIFO is full then we cannot write
into it and if FIFO is empty, we cannot read from it.
A combinational logic is used to control the values from RAM. The read and write
pointers are fed as the addr_r and addr_w respectively.
5.2 Block Diagram:
Zoomed Version:
In the test bench, the data was written to the FIFO and than stored into the RAM. The data is read
from the FIFO module using the dout function. It was observed from the waveforms that when the
data was written, FIFO gave a full_signal and when the data was read, an empty_signal was
generated.
When the data was read from an empty FIFO, it gave an underflow_signal and an overflow_signal
was generated when an already full FIFO was written on. All the results were verified and
implemented successfully, and the waveforms are attached in the results section for reference.
The FIFO module was updated to complete the second task and a ram controller module was
defined. Both the ram controller and the general ram module were initialized and called in the
update FIFO top module. The waveforms for both the FIFO working are attached in the results
section 5.3.3 for Simple FIFO using RAM and 5.4.6 for FIFO using RAM controller module. In a
nutshell, all the modules were working and the functioning of the code was verified successfully.
6 References:
[1]
“ModelSim ® Tutorial.” [Online]. Available: https://www.microsemi.com/document-
portal/doc_view/131618-modelsim-tutorial.
[1]
“ISE In-Depth Tutorial,” 2011. [Online]. Available:
https://www.xilinx.com/htmldocs/xilinx13_3/ise_tutorial_ug695.pdf
[1]
“ISE 10.1 Quick Start Tutorial.” Accessed: Apr. 20, 2022. [Online]. Available:
https://www.eng.auburn.edu/~strouce/class/elec4200/qst.pdf