OpenCores
URL https://opencores.org/ocsvn/nysa_sata/nysa_sata/trunk

Subversion Repositories nysa_sata

[/] [nysa_sata/] [trunk/] [rtl/] [generic/] [debounce.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 cospan
module debounce #(
2
  parameter INITIAL_STATE     = 0,
3
  parameter DEBOUNCE_COUNT    = 100
4
)(
5
  input         clk,
6
  input         in_signal,
7
  output  reg   out_signal
8
);
9
 
10
reg [DEBOUNCE_COUNT - 1: 0] debounce;
11
 
12
initial begin
13
  out_signal    <=  INITIAL_STATE;
14
  debounce      <=  INITIAL_STATE;
15
end
16
always @ (posedge clk) begin
17
 
18
  debounce  <= {debounce[(DEBOUNCE_COUNT - 2) : 0], in_signal};
19
 
20
  if (debounce[0] == 1 && (& debounce)) begin
21
    out_signal         <=  1;
22
  end
23
  else if ((debounce[0] == 0) && (~| debounce)) begin
24
    out_signal         <=  0;
25
  end
26
end
27
 
28
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.