design of edge detection circuit

Status
Not open for further replies.

subbareddy443

Newbie level 3
Joined
Jun 4, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,300
hi eny one help me to design a positive edge or negative edge detection circuit
 

What did you start with?
 

    V

    Points: 2
    Helpful Answer Positive Rating
If the signal you want to detect is slower than the main clock, you can use 3 flip-flop in series to get 3 samples of the input and detect the edge by detecting the "100" value (or "110").

d1 <= INPUT;
d2 <= d1;
d3 <= d2;
edge = d1 & !d2 & !d3

You can also detect falling edge the same way. This kind of circuit is used for example in I2C logic to detect the edge on SCL or SDA.
 

    V

    Points: 2
    Helpful Answer Positive Rating
To haykp >
I'm sorry but I don't have a link to a reference with the circuit so I wrote a simple schematic.

Regards.
 

    V

    Points: 2
    Helpful Answer Positive Rating
Code:
Although not obvious at first sight, the suggested logic is still succeptible to metastability, which can result in missing an edge. You should better refer to the standard solution from text books:
Code:
edge = d2 & !d3
It's however not necessarily required to register the edge bit before processing it.

P.S.: On the other hand, if we assume, that a single FF is sufficient to defeat metastability and connect d1 and d2, what's the purpose of d3? Maybe I missed a feature of your code.
 
Last edited:

    V

    Points: 2
    Helpful Answer Positive Rating
Hi FvM,
You are right, there is a risk of metastability. But I would say that it is almost always the case when trying to sample external data.
Using several FF in series with no logic in the middle can help avoid metastability (care is needed during P&R).
As for using 3 FF, it's to make sure glitch are not detected as an edge. Of course the size of the glitch that can be avoided depends on the clock speed.
This circuit can not be used in all case, but is OK for simple case.
 

    V

    Points: 2
    Helpful Answer Positive Rating
try searching testbench.in or asic-world.com
 

    V

    Points: 2
    Helpful Answer Positive Rating
Is input signal which has to be detected is synchronous to destination domain ?
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…