Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Why read and write pointers are gray encoded in FIFO design?

Status
Not open for further replies.

dak-ju

Junior Member level 2
Joined
Jul 9, 2005
Messages
22
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Location
India
Activity points
1,534
asychronous fio design

I want to know why in the asynchronous fifo design , the read and the write pointer is gray encoded?
 

funster

Full Member level 4
Joined
Jun 30, 2005
Messages
233
Helped
19
Reputation
38
Reaction score
4
Trophy points
1,298
Activity points
2,742
Re: asychronous fio design

because read clock and write clock are asynchronous,

write address is generated in write clock domain,

read address is generated in read clock domain. in asyn fifio,

we need to compare write address and read address to

determine empty and full flag as well as how many bytes

are in fifo. so we must pass write address to read clock domain

and pass read address to write clock domain.

if read address and write address is not encoded in gray code,

address will has many bits to change, that will lead

wrong address. because we can't pass multi-bits data

across asynchronous boundary reliablely.

by using gray code, this problem is solved.



best regards






dak-ju said:
I want to know why in the asynchronous fifo design , the read and the write pointer is gray encoded?
 
  • Like
Reactions: chipmonkey

    dak-ju

    Points: 2
    Helpful Answer Positive Rating

    chipmonkey

    Points: 2
    Helpful Answer Positive Rating

dBUGGER

Advanced Member level 4
Joined
Apr 18, 2005
Messages
108
Helped
13
Reputation
26
Reaction score
1
Trophy points
1,298
Location
Milky Way
Activity points
2,430
asychronous fio design

Hi,
It is done to get rid of the problem of multiple bits synchronization. With Gray encoding only one bit changes at a time so a simple synchronizer circuit can be used to synchronize the pointers from one domain to another.

Best Regards,
 

Sparc

Member level 5
Joined
Apr 11, 2005
Messages
90
Helped
16
Reputation
32
Reaction score
2
Trophy points
1,288
Location
out of reach..
Activity points
2,295
asychronous fio design

To further simplify dBUGGER, all bits in a signal are unable to change in a single shot of time, and it might result in Glitches. In Gray encoding, only a single bit changes so u need to synchronize only one bit.
 

Thomson

Full Member level 3
Joined
Oct 15, 2004
Messages
181
Helped
4
Reputation
8
Reaction score
1
Trophy points
1,298
Activity points
2,400
Re: asychronous fio design

another method can be used: the asynchronous comparsion of the write pointer and read pointer. the pointers can be implemented using one-hot or gray code to reduce the unnecessary bit transistion so as to reduce the possibilities of the comparision signals represneing the status of FULL or EMPTY. Of course, the FULL or EMPTY shall be sampled by the other clock filed clock to generate the error signal. The synchronous FULL_s and EMPTY_s and Error_s shall be generated with a syncronizer to get rid of the metastability.

There are many articles describing this topic and you can search on the google.


Good Luck!
 

bibo1978

Full Member level 4
Joined
May 1, 2004
Messages
210
Helped
12
Reputation
24
Reaction score
6
Trophy points
1,298
Activity points
2,548
Re: asychronous fio design

Gray codes are used in such case because the empty and full conditions are defined by comparison between the FIFO read and write pointer, however the read and the write process run on different indpendent clocks, if the comparison is made between binary counter false glitches might occur because of data skew to the comparator and because more than one bit might change (for example if you have a four bit counter the transition between 15 and 0 will result the all four bit changes, and because of the skew any value might be seen by the comparator depending on the skew) this might result a false alarm because the read and write clocks are independent it migh occur that this false alarm is captured by the other clock domain, for example if you have the above transition occurs during a read process the glitches might be registered by the write process, introducing a false alarm which in this case might be a full flag.
Other encoding techniques might reduce this propability like one-hot encoding but still with one hot a two bit transition occur which still might introduce a glitch the safest way is to use a gray code.
It is noticeable that with such technique the full or the empty flag deassertion might occur one clock later relative to its clock domain (full is a write clock domain signal, empty is a read clock domain flag) and intutively this is not a big deal,(i.e. you might stay for a clock cycle for a write process while a the fifo is not full or you might stay for a clock cycle for a read process while the fifo is not empty).
still you have to make sure to avoid the metastability by inserting filters in the clock domain whit the appropriate direction of flag motion, for example an empty flag deassertion process (write clock doamain process to a read clock domain flag) should include a metastability filter.
However I prefer that you do it in both ways yet it depends on your design.

that's all folks
 

sushantm

Newbie level 3
Joined
Dec 21, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,303
Re: asychronous fio design

Nice Discussion friends I want verilog code for writing and reading logic of fifo

Please provide me the same and/or give me the guide lines to devlop..

I am a starter please help me.

I have some basic concepts on fifo
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top