Forum Discussion
3 Replies
- Altera_Forum
Honored Contributor
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 - Altera_Forum
Honored Contributor
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. - Altera_Forum
Honored Contributor
I suggest the same as ^ matlab to model/sim before you get to the VHDL