Altera_Forum
Honored Contributor
11 years agoCrossing clock domains?
I'm just learning about FPGAs (using VHDL) and have encountered metastability problems which I'm fairly certain are due to crossing clock domains.
I have made a VGA controller (on a DE1 Cyclone II board) and am trying to interface it to an old 8 bit micro (directly into its memory map), and it almost works. My 8 bit micro is running at ~0.9MHz, and the VGA controller is running at 108MHz. When in 'standalone' test mode, the VGA controller is great, but when connected to the micro, I get flickering and other weird effects. Currently, I have the 108MHz FPGA clock running state machines etc, with the CPU clock directly interacting with them to affect state transitions. I believe this is a big crime (forgive me, I'm still learning)! (Debugging with a logic analyser shows things like the state machines ending up in weird and unexpected states) So, to solve the problem of crossing clock domains, would it be OK to just pass the micro's CPU clock signals through a couple of clocked (using the 108MHz clock) registers? I'd end up with ~20ns delay, but to a 1MHz CPU that's not going to be a problem :-) Would that reduce the metastability problems substantially? I don't think I need anything more complicated, such as proper 'handshaking' I don't think I'll need to synchronise the micro's address/data bus etc because they're all guaranteed to be set up before the CPU clock anyway.