Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
11 years ago

How fast can a FPGA sense?

I found a problem if i keep pressing and releasing the button.

I found that the FPGA get crazy, can't really follow the logic.

So i think it's the problem of the duration time of the button at 1 or 0. In order word when the time of being button==0 or button==1 is too short, FPGA can't respond.

So my question is how can i find out the reaction time of the FPGA, I need to find a precise time value. any one know? Thank you.

Here is a really simple code for your understand.

module simple(clk, button ,b);

input button,clk;

output b;

always @ (posedge clk)

if(button==1) begin

b<=0;

end else if (button==0)

begin

b<=1;

end

endmodule

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    With this code the "reaction time" will be at most one clock period,so it all depends on what clock you are using.

    The problem you are seeing could also be related to bouncing. Usually development kits don't have external debouncing hardware outside of the FPGA so you need to do it inside.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Use the SignalTap II logic analyzer to probe the signal. You'll likely see that it changes state rapidly due to contact bounce as mentioned by Daixiwen.

    Keep in mind that logic level changes on your external signal are completely *unrelated* to the clock. FPGAs are synchronous systems and expect synchronous signals.

    Your external asynchronous "button" signal should be passed through a synchronizer (cascade of flip-flops) before being used in a clocked process.

    Cheers,

    Dave