Asynchronous FIFO Design Using Verilog PDF
Asynchronous FIFO Design Using Verilog PDF
2.1 Introduction:
An Asynchronous FIFO Design refers to a FIFO Design where in the data values are
written to the FIFO memory from one clock domain and the data values are read from a different
clock domain, where in the two clock domains are Asynchronous to each other. Asynchronous
FIFO’s are widely used to safely pass the data from one clock domain to another clock domain
The above figure’s refers of an Asynchronous FIFO, it will be better if each block is
explained
FIFO MEMROY
This is the heart of the FIFO, the depth of memory is 16 bits and width is 8 bits,
It has an the following inputs
Write Data (8 bit), Write Enable, Read Enable, Write Clock, Write address (4 bit), Read Address
(4 bit) And an output i.e. Read Data (8 bit)
Data which is to be written and the address where it has to be written is supplied at the
input port write data and write address. At the positive edge of the clock when Write enable is
http://www.rfwireless-world.com
enabled so now the data is been written into the FIFO memory, now it has to be Read out, for
that to happen Read enable should be Enabled and the address from which the data has to be read
should be specified at the input port Read address.
This is the Memory operation in brief .now we have to control the memory in such a way
that it meets the requirements of the FIFO.
SYNCHRONIZER’S
Synchronizers are very simple in operation; they are made of 2 D Flip Flop’s.
As the FIFO is operating at 2 different clock domains so there is a need to synchronize the Write
and Read pointers for generating empty and full logic which in turn is used for addressing the
FIFO memory.
The Figure below shows how synchronization takes place; the logic behind this is very simple.
What we are trying to do over here is , passing the Write Pointer to a D Flip Flop which is
driven by the Read clock and in the same manner the Read pointer is fed to a D Flip Flop
which is driven by Write Clock, so as a result of this we get Read Pointer (which is
operating under Read clock) and Synchronized Write Pointer which is also operating
under Read clock, and the same with Write pointer and Synchronized Read Pointer, so
now we can compare them and derive a logic for Generating Empty and Full conditions,
which is the most important design part of this FIFO
http://www.rfwireless-world.com
Fig 2.2: Synchronizer Logic
http://www.rfwireless-world.com
Fig 2.4: Output Waveform 1
http://www.rfwireless-world.com
Fig 2.7: Output Waveform 4
As we can see from the waveform when the write_Address reached 15 i.e.
The FIFO memory is filled hence the Full signal goes high
Empty signal goes high when ever the data which is being written into the memory is
Read out
http://www.rfwireless-world.com
Fig 2.8(a): FIFO operation for different clock frequencies
> Here we can notice that even if we change the write and read clock frequencies the FIFO
design works
http://www.rfwireless-world.com
We now write the stimulus block to check if the Asynchronous FIFO Design is
functioning correctly. In this case we must control the following
Write & Read Clock’s
Write & Read Resets
Write & Read Enable
Write Data
So that the regular function of the Asynchronous FIFO and the Reset and Enable
Mechanism are both tested, we use the Waveform shown in Fig 2.9(a) to test the Design,
Waveform’s for Write clock, Read Clock, Write & Read Resets , Write & Read Enable are
shown.
Data out, Empty and full signal’s are then monitored. as we can see in the fig 2.9(b)
Stimulus Block
module tb_top();
reg wr_clk,rd_clk;
reg[7:0] data_in;
wire[7:0] data_out;
wire rd_empty,wr_full;
reg reset_w;
reg reset_r;
reg write_enable,read_enable;
top top_1(.wr_data(data_in),
.rd_data(data_out),
.wr_clk(wr_clk),
.rd_clk(rd_clk),
.w_reset(reset_w),
.r_reset(reset_r),
.write_enable(write_enable) ,
.read_enable(read_enable),
.empty(rd_empty),
.full(wr_full));
initial
begin
#0data_in=8'h0;
#50_000 data_in=8'b00000001; // DATA WHICH IS SUPPLIED
#80_000 data_in=8'h2;
#70_000 data_in=8'h3;
#79_000 data_in=8'h4;
#80_000 data_in=8'h5;
#40_000 data_in=8'h6;
#60_000 data_in=8'h7;
#50_000 data_in=8'h8;
#50_000 data_in=8'h9;
#20_000 data_in=8'h10;
#70_000 data_in=8'h11;
#80_000 data_in=8'h12;
#19_000 data_in=8'h13;
#10_000 data_in=8'h14;
#80_000 data_in=8'h15;
end
initial
begin
wr_clk=1'b0;
write_enable=1'b0;
http://www.rfwireless-world.com
read_enable=1'b0;
end
initial
always
#50000 wr_clk=~wr_clk; //end // READ AND WRITE CLOCK GENERATION
rd_clk=1'b0;
initial
begin
always
#10000 rd_clk=~rd_clk;
end
initial
reset_r=1'b0;
begin
initial
#5000 reset_r=1'b1;
//end
initial
reset_w =1'b0;
initial
#5000 reset_w=1'b1;
initial
#5000 write_enable=1'b1;
initial
# 50000 read_enable=1'b1;
initial
begin
#1000000000 $finish; end
initial
$monitor( "$time data_out,empty ,full= %d %d %d",data_out,rd_empty,wr_full);
endmodule
Once the stimulus Block is completed, we are ready to run the stimulation
and verify the functional correctness of the design block. The output obtained when the
stimulus and design blocks are stimulated is shown in Fig 2.9(a) and 2.9(b)
http://www.rfwireless-world.com
Fig 2.9(a) : Stimulus Waveform
http://www.rfwireless-world.com
Fig 2.9(b): Monitoring output’s (out put of stimulus)
Logic Synthesis is the process of converting a high level description of the design into an
optimized, gate-level representation, using the cells in the technology library.
Logic Synthesis tool accepts high level descriptions at the register transfer Level (RTL).
And a technology library produces an optimized gate level net list, Translation, Logic
optimization, and technology mapping are the internal process in a logic synthesis tool and
are normally invisible to the user. Not all verilog constructs are acceptable to a logic synthesis
tool.
=========================================================================
* Advanced HDL Synthesis *
=========================================================================
http://www.rfwireless-world.com
Dynamic shift register inference ...
=========================================================================
HDL Synthesis Report
Macro Statistics
# LUT RAMs :1
16x8-bit dual-port distributed RAM: 1
# Adders/Subtractors :2
5-bit adder :2
# Registers : 10
1-bit register :2
5-bit register :8
# Comparators :3
4-bit comparator equal :1
5-bit comparator equal :2
# Xors :8
1-bit xor2 :8
=========================================================================
* Final Report *
=========================================================================
Final Results
RTL Top Level Output File Name : top.ngr
Top Level Output File Name : top
Output Format : NGC
Optimization Goal : Speed
Keep Hierarchy : NO
Design Statistics
# IOs : 24
Macro Statistics :
# RAM :1
# 16x8-bit dual-port distributed RAM: 1
# Registers : 10
# 1-bit register :2
# 5-bit register :8
# Comparators :3
# 4-bit comparator equal :1
# 5-bit comparator equal :2
Cell Usage :
# BELS : 39
# LUT1 :4
# LUT1_D :1
# LUT2 : 16
# LUT2_D :1
# LUT2_L :3
# LUT3 :2
# LUT3_L :4
# LUT4 :4
# LUT4_L :4
# FlipFlops/Latches : 41
# FDC :1
http://www.rfwireless-world.com
# FDCE : 21
# FDP :1
# FDR : 18
# RAMS :8
# RAM16X1D :8
# Clock Buffers :2
# BUFGP :2
# IO Buffers : 22
# IBUF : 12
# OBUF : 10
=========================================================================
http://www.rfwireless-world.com
Fig 2.9(d): Schematic of the memory
http://www.rfwireless-world.com
Fig 2.9(e): Schematic of Full and empty logic
http://www.rfwireless-world.com