Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
16597 Discussions

Edge detection VHDL (what's the best solution)

Altera_Forum
Honored Contributor II
2,000 Views

Hello everybody  

 

Well for Edge detection we always use C language because it's much easier to code the algorithm !! 

 

What do you think is the best solution that can be coded in VHDL for edge detection or motion detection ?  

 

 

Best regards
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
849 Views

Hi, 

do you talk on detecting an external signal rising or falling edge (e.g. an HW-Switch "pressed" detection or a encoder's output)? 

In either case you should synchronise the external signal to your's system clock (twice to prevent metastability issues). Additionally I would suggest to implement a debouncing (especially when talking on HW-Switches...) by using a simple counter to ensure the external signal is stable for xyz clock cycles. This counter could also be used as the edge dectector. 

Just as a Quick'n dirty implementation:  

 

synchronise external signal to system clock (twice) 

when '0' => counter reset, when '1' => counter increments until a) external signal gets '0' again (reset) (i.e. signal was bouncing) or b) signals was stable '1' for xyz cylces (no bouncing and rising edge detected). 

 

(not to mention you could use the external signal directly for asynchronous detection by "if rising_edge(ext_Signal) then..." but be aware with asynchronous logic and not debounced signals) 

 

Best regards, Carlhermann
0 Kudos
Altera_Forum
Honored Contributor II
849 Views

Carl - I think its more complicated than edge detection on a single input signal. Sounds like the OP is talking about edge detection in an image.  

 

The best thing to do is code up your algorithm in C/Matlab so that you know it works. Then learn digital design, and then covert it to VHDL. Compare the VHDL results to the C/Matlab model, and there you go. You can do plenty of edge detection algorithms in VHDL (sobel, Haas, lutz, wavelet ). Its really up to how good your engineering skills are.
0 Kudos
Altera_Forum
Honored Contributor II
849 Views

I suggest the same as ^ matlab to model/sim before you get to the VHDL

0 Kudos
Reply