Professional Documents
Culture Documents
20311a04f0 Report
20311a04f0 Report
On
DESIGN AND SIMULATION OF SEQUENCE DETECTOR OF THE GIVEN SEQUENCE
BACHELOR OF TECHNOLOGY
In
By
Mrs. E. LAVANYA
ASSISTANT PEOFESSOR
DEPARTMENT OF ECE
1
2
CERTIFICATE
This is to certify that this Summer Industry Internship –I project report entitled
“DESIGN AND SIMULATION OF SEQUENCE DETECTOR OF THE GIVEN SEQUENCE”, is
being submitted by
in partial fulfilment of the requirements for the award of Bachelor of Technology degree in
Electronics and Communication Engineering to Sreenidhi Institute of Science and Technology
affiliated to Jawaharlal Nehru Technological University, Hyderabad (Telangana). This record is a
bonafide work carried out by them under our guidance and supervision . The results embodied in the
project report have not been submitted to any other University or Institution for the award of any
degree or diploma.
3
4
DECLARATION
It is declared to the best of our knowledge that the work reported does not form part of any dissertation
submitted to any other university or institute for award of any degree.
4
5
ACKNOWLEDGEMENT
I would like to express my gratitude to all the people behind the screen who helped me to transform
an idea into a real application.
I would like to express my heart-felt gratitude to my parents without whom I would not have been
privileged to achieve and fulfil my dreams. I am grateful to our principal, Dr. T. Ch. Siva Reddy,
who most ably run the institution and has had the major hand in enabling me to do my project.
I profoundly thank Dr. SPV. Subba Rao, Head of the Department of Electronics & Communication
Engineering who has been an excellent guide and also a great source of inspiration to my work.
.I would like to thank my internal guide Mrs. E. Lavanya for her technical guidance, constant
encouragement and support in carrying out my project at college.
The satisfaction and euphoria that accompany the successful completion of the task would be great
but incomplete without the mention of the people who made it possible with their constant guidance
and encouragement crowns all the efforts with success. In this context, I would like thank all the other
staff members, both teaching and non-teaching, who have extended their timely help and eased
my task.
5
6
TABLE OF CONTENTS
Page No.
Abstract …………... i
List of Figures ……………. ii
Chapter 1. Introduction 1
Chapter 2. Source Code 8
2.1 Test bench for the Verilog code 10
Chapter 3. Results 13
Chapter 4. Conclusion 15
4.1 Advantages and Disadvantages 16
4.2 Applications 17
References: 18
6
7
ABSTRACT
FIFO is a First-In-First-Out memory queue with control logic that manages the read and
write operations, generates status flags, and provides optional handshake signals for interfacing
with the user logic. It is often used to control the flow of data between source and
destination. FIFO can be classified as synchronous or asynchronous depending on whether same
clock or different (asynchronous) clocks control the read and write operations. In this project the
objective is to design, verify and synthesize a synchronous FIFO using binary coded read and
write pointers to address the memory array. FIFO full and empty flags are generated and passed
on to source and destination logics, respectively, to pre-empt any overflow or underflow of data.
In this way data integrity between source and destination is maintained.
7
8
LIST OF FIGURES.
ii
8
CHAPTER 1. INTRODUCTION
FIFO is an acronym for First In First Out, which describes how data is managed relative to time
or priority. In this case, the first data that arrives will also be the first data to leave from a
group of data. A FIFO Buffer is a read/write memory array that automatically keep track of
the order in which data enters into the module and reads the data out in the same order. In
hardware FIFO buffer is used for synchronization purposes. It is often implemented as a circular
queue, and has two pointers;
1. Read Pointer/Read Address Register
II. Write Pointer/Write Address Register
Read and write addresses are initially both at the first memory location and the FIFO queue is
Empty. When the difference between the read address and write address of the FIFO buffer is
equal to the size of the memory array then the FIFO queue is Full
FIFO can be classified as synchronous or asynchronous depending on whether same clock
(synchronous) or different clocks (asynchronous) control the read and write operations.
Synchronous FIFO
A synchronous FIFO refers to a FIFO design where data values are written sequentially into a
memory array using a clock signal, and the data values are read out sequentially from the
memory array using the same clock signal. Figure 1 shows the flow of the operation of a typical
FIFO.
1
2
Figure 1.1: Operation of FIFO with the three data values
Block diagram
Figure 2 presents the Verilog module of the FIFO Buffer. This FIFO Buffer can store eight 32-
bit values. The FIFO Buffer module consists of a 32-bit data input line, data In and a 32-bit data
output line, data Out. The module is clocked using the 1-bit input clock line Clk. The module
also has a 1-bit enable line, EN and a 1- bit active high reset line, Rst.
The 1-bit RD line is used to signal a data read operation on the FIFO Buffer and the 1-bit WR
line is used to signal a data write operation on the FIFO Buffer.
Both the RD and WR lines are active high. The module also has two output lines FULL and
EMPTY which are each 1-bit wide. The FULL line becomes high when the FIFO Buffer is or
becomes full (internal counter becomes eight). The EMPTY line becomes high when the FIFO
Buffer is or becomes empty (internal counter becomes zero).
3
Figure 1.2: Verilog module of a FIFO Buffer
PORT LIST :
4
WRITE SIDE PORTS:
NAME I/ DESCRIPTION
O
write_data I Data input to FIFO
fifo_full O Qualifies the write data. Logic high indicates
the data on write_data bus is valid and need
to be sampled at next rising edge of the
clock.
write_ack O Write acknowledgement to source.
5
FUNCTIONAL DESCRIPTION :
6
6
Figure 1.3: Functional Block Diagram
The above figure depicts the basic building blocks of a synchronous FIFO which are: memory
array, write control logic and read control logic. The memory array can be implemented either
with array of flip-flops or with a dual-port read/write memory. Both of these implementations
allow simultaneous read and write accesses. This simultaneous access gives the FIFO its inherent
synchronization property. There are no restrictions regarding timing between accesses of the two
ports. This means simply, that while one port is writing to the memory at one rate, the other can
be reading at another rate totally independent of one another. The only restriction placed is that
the simultaneous read and write access should not be from/to the same memory location. The
Synchronous FIFO has a single clock port clk for both data-read and data-write operations.
Data presented at the module's data-input port write_data is written into the next available empty
memory location on a rising clock edge when the write-enable input write_enable is high. The
full status output fifo_full indicates that no more empty locations remain in the module's internal
memory. Data can be read out of the FIFO via the module's data-output port read_data in the
order in which it was written by asserting read-enable signal read_enable prior to a rising clock
edge. The memory-empty status output fifo_empty indicates that no more data resides in the
module's internal memory. There are almost empty and almost full flags too viz. fifo_aempty and
fifo_afull which can be used to control the read and write speeds of the requestor and the
source.
6
WRITE CONTROL LOGIC:
Write Control Logic is used to control the write operation of the FIFO’s internal memory. It
generates binary-coded write pointer which points to the memory location where the incoming
data is to be written. Write pointer is incremented by one after every successful write operation.
Additionally, it generates FIFO full and almost full flags which in turn are used to prevent any
data loss. For example, if a write request comes when FIFO is full then Write
Control Logic stalls the write into the memory till the time fifo full flag gets de-
asserted. It intimates the stalling of write to source by not sending any
acknowledgement in response to the write request.
6
FULL AND EMPTY FLAG GENERATION
FIFO full and almost full flags are generated by Write Control Logic whereas empty and almost
empty flags are generated by Read Control Logic. FIFO almost full and almost empty flags are
generated to intimate the source and the requestor about impending full or empty conditions. The
almost full and almost empty levels are parameterized. It is important to note that read and write
pointers point to the same memory location at both full and empty conditions. Therefore, in order
to differentiate between the two one extra bit is added to read and write pointers. For example if
a FIFO has depth of 256 then to span it completely 8- bits will be needed. Therefore with
one extra bit read and write pointers will be of 9-bits. When their lower 8-bits point to same
memory location their MSBs are used to ascertain whether it is a full condition or empty
condition. In empty conditions the MSBs are equal whereas in full condition MSBs are different.
6
CHAPTER 2 .SOURCE CODE
4. input [31:0]dataIn;
9. writeCounter = 0;
13. begin
14. if (EN==0);
17. readCounter = 0;
18. writeCounter = 0;
19. end
26. end
27. else;
28. end
29. if (writeCounter==8)
30. writeCounter=0;
32. readCounter=0;
33. else;
35. Count=readCounter-writeCounter;
36. end
38. Count=writeCounter-readCounter;
39. else;
40. end
41. endmodule
6
Verilog Test Bench for FIFO Buffer
1. `timescale 1ns / 1ps
2. module FIFObuffer_tb;
3. // Inputs
4. reg Clk;
6. reg RD;
7. reg WR;
8. reg EN;
9. reg Rst;
10. // Outputs
16. .Clk(Clk),
17. .dataIn(dataIn),
18. .RD(RD),
19. .WR(WR),
20. .EN(EN),
21. .dataOut(dataOut),
10
22. .Rst(Rst),
23. .EMPTY(EMPTY),
11
24. .FULL(FULL)
25. );
30. RD = 1'b0;
31. WR = 1'b0;
32. EN = 1'b0;
to finish
. #100;
37. EN = 1'b1;
39. #20;
41. WR = 1'b1;
43. #20;
47. #20;
49. #20;
51. #20;
52. WR = 1'b0;
53. RD = 1'b1;
54. end
56. endmodule
12
CHAPTER 3. Results
Figure 3.1: Output waveforms:
13
Figure 6. Timing Diagram of FIFO Buffer
14
CHAPTE R 4. Conclusion
The design of synchronous FIFO was studied and also verified using System Verilog. The following
concepts of System Verily were used in our project :
1. Class
2. Interface
3. Randomization
4. Ports
5. Program
The verification components in our project were split by the following blocks :
1. Push Generator
2. Pop Generator
3. Push Monitor
4. Pop Monitor
5. Scoreboard
6. System Verilog Testbench Top
7. System Verilog Interface File
15
4.1 Advantages and disadvantages
Advantages
1. FIFO method saves money and time in calculating the exact cost of the inventory being
sold because the cost will depend upon the most former cash flows of purchases to be
used first.
2. It is a simple concept which is easy to understand. Even a layman can grab the idea
with little explanation. The managers with little to no accounting information would be
able to understand it easily.
Disadvantages
One of the biggest disadvantages of FIFO approach of valuation for inventory/stock is that
in the times of inflation it results in higher profits, due to which higher “Tax Liabilities”
incur. It can result in increased cash out flows in relation to tax charges.
FIFO may not be a suitable measure in times of “hyper inflation”. In such times there exist
no reasonable pattern of inflation and prices of goods could inflate drastically. And in
such cases the matching of most prior purchases with most recent sales would not be
appropriate and may pump up profits to present a distorted picture
16
4.2 Applications
FIFO’s are used to safely pass data between two asynchronous clock domains. In System-
onChip designs there are components which often run on different clocks. So, to pass data
from one such component to another we need ASYNCHRONOUS FIFO. · Some times
even if the Source and Requestor sides are controlled by same clock signal a FIFO is
needed.
This is to match the throughputs of the Source and the Requestor. For example in one case
source may be supplying data at rate which the requestor can not handle or in other case
requestor may be placing requests for data at a rate at which source can not supply. So, to
bridge this gap between source and requestor capacities to supply and consume data a
SYNCHRONOUS FIFO is used which acts as an elastic buffer.
17
REFERENCES
http://www.systemverilog.us/req_verif_plan.pdf
http://abramovbenjamin.net/labs/FIFO_design.pdf
http://www.asic-world.com/examples/systemverilog/fifo1.html#Verification_Of_FIFO
http://www.cypress.com/?docID=46919
18