0

I am using push button of DE2 board as asynchronous reset, but it fails to work. This is my module for a n-bit register:

module regne (D, Clock, Resetn, Q);

    parameter n;
    input [n-1:0] D;
    input Clock, Resetn;
    output reg [n-1:0] Q;

    always @ (posedge Clock or negedge Resetn)
    begin
        if (Resetn == 0)
            Q[n-1:0] <= 'b0;
        else
            Q[n-1:0] <= D[n-1:0];
    end
endmodule

However, the reset fails to work. It does not do anything when I press the push button. I think it is caused by bouncing of push button. So how can I implement debouncing in Verilog?

Greg
  • 18,111
  • 5
  • 46
  • 68
SHuoDo
  • 87
  • 1
  • 2
  • 10
  • 1
    If you press and hold reset does it still not function property? If not, this is a connectivity issue and not a bounce issue. If a long press does cause a reset then check to see if the DE2 board is filtering inputs. – Greg Nov 06 '13 at 01:42
  • Are you sure that the push buttons are pull downs? Your code resets when the `Resetn` line is `0`. Try triggering on `posedge Clock or posedge Resetn` and making the if statement read `if (Resetn == 1)`. – Neil Forrester Nov 06 '13 at 01:46
  • I am sure that the push button on DE2 is pull down. And it does not work even if I press and hold button for a while – SHuoDo Nov 06 '13 at 02:49
  • Check the pinout of the generated bit stream is correct - there are a variety of logfiles with this information in normally – Martin Thompson Nov 06 '13 at 12:07

1 Answers1

0

You don't need to implement debouncer for DE2 buttons. Its buttons (push buttons and switch buttons) have debouncer by themselves.

Replace

always @ (posedge Clock or negedge Resetn)

with

always @ (posedge Clock)

If it didn't work and you are sure about your pin assignments, make sure your board is working correctly.

Mab
  • 13
  • 1
  • 5