Forum Discussion
Altera_Forum
Honored Contributor
13 years agoAsynchronous Signal
Hi.
I have a problem that my FPGA design failing after several seconds. The code purposes isto measurement frequency from external signal generator (50kHz)*. I'm working with 50Mhz clock, LPM_Divide [0-27], Pipe Line [20], Fmax=90MHz. On ModelSim, the code works perfectly, but on Altera Evaluation Board (Cyclone IV)- the code stuck!. Using Altera SignalTap, I sew that my state machine is missing states and even jump to undefended state (completely disregard from the "when others =>Idan_State_Machine<=Idle_State;" line at the end of the state machine??!!). When I transfered the external input signal to another register and then used it in my code- the problem seems to be disappearing. How this is even possible? I agree that I should expect for one clock latency due to diss synchronization between the external input signal to the FPGA main clock, but to sent the state machine to the undefined state?! To stuke the code? *Using two falling edge (idan_input_signal is the external input): This is the partial code that failed: " elsif clk'event and clk='1' then idan_input_signal_buf <= idan_input_signal; case Idan_State_Machine is when Idle_State => if (Idan_input_signal_buf = '1' and idan_input_signal = '0') then " This is the partial code that didn't failed: " elsif clk'event and clk='1' then Idan_input_signal_buf <= Idan_Input_Signal; idan_input_signal_buf_two <= idan_input_signal_buf; case Idan_State_Machine is when Idle_State => if (Idan_input_signal_buf_two = '1' and Idan_input_signal_buf = '0') then " Thanks, Idan14 Replies
- Altera_Forum
Honored Contributor
--- Quote Start --- Thanks for your replay! Yes, in Quatus II I'm getting all good. My colleague wrote the question on the same problem… From my understanding, metastability is the statistic problem that should occur with time prior of years, so it don't make any sense that all the statistic had failed every time, after couple of seconds, with ~10 kHz external signal and 50MHz clock… Is it possible? If I'll extract from Quartus II timing the MTBF, will the result be several seconds? I don't think so. I'f I'm right, I still don't have the answer to my wondering ("that I agree that I should expect for one clock latency due to diss synchronization between the external input signal to the FPGA main clock, but to sent the state machine to the undefined state?! To stuke the code?") Idan --- Quote End --- Your thinking is right. We tend to exagerate metastability issue. In most cases what happens with asynchronous signals is that the logic is sampled wrong compared to simulation. For example in simulation you decide when your signals are driven but in actual hardware the drive may have different moments relative to clock and thus upsets the logic. An asynchronous signal change will either hit timing window (and may cause metastability or not) or hit after timing window leading to delayed sample point. Regarding undefined states: my understanding is that the tool ignores "when others" for state machine(but check that) and the advice is you better reset your state machine at start up rather than depend on "when others" and also make sure that your state transitions never enter undefined state. - Altera_Forum
Honored Contributor
Thanks for your replay!
Yes, in Quatus II I'm getting all good. My colleague wrote the question on the same problem… From my understanding, metastability is the statistic problem that should occur with time prior of years, so it don't make any sense that all the statistic had failed every time, after couple of seconds, with ~10 kHz external signal and 50MHz clock… Is it possible? If I'll extract from Quartus II timing the MTBF, will the result be several seconds? I don't think so. I'f I'm right, I still don't have the answer to my wondering ("that I agree that I should expect for one clock latency due to diss synchronization between the external input signal to the FPGA main clock, but to sent the state machine to the undefined state?! To stuke the code?") Idan - Altera_Forum
Honored Contributor
Are you meeting timing with all paths constrained?
- Altera_Forum
Honored Contributor
This thread seems to offer some information for you to look at. The problem is with asynchronous signals you have metastability. When you register the external signal you help improve this which eliminates your problems. I believe there is a document link in the thread which discusses it in further detail.
http://www.alteraforum.com/forum/showthread.php?t=39099