data/full_repos/permissive/427163843/Pong_game_v1.1.srcs/Debounce_Switch.v
data/verilator_xmls/1b77b4e6-0cc3-4ee1-bc51-5f6c0c9ffadf.xml
module Debounce_Switch (input clk, input i_Switch, output o_Switch);
 
  parameter c_DEBOUNCE_LIMIT = 250000;
   
  reg [17:0] r_Count = 0;
  reg r_State = 1'b0;
 
  always @(posedge clk)
  begin


    if (i_Switch !== r_State && r_Count < c_DEBOUNCE_LIMIT)
      r_Count <= r_Count + 1;
 

    else if (r_Count == c_DEBOUNCE_LIMIT)
    begin
      r_State <= i_Switch;
      r_Count <= 0;
    end 
 

    else
      r_Count <= 0;
  end
 

  assign o_Switch = r_State;
 
endmodule
module Debounce_Switch (input clk, input i_Switch, output o_Switch);

 
  parameter c_DEBOUNCE_LIMIT = 250000;
   
  reg [17:0] r_Count = 0;
  reg r_State = 1'b0;
 
  always @(posedge clk)
  begin


    if (i_Switch !== r_State && r_Count < c_DEBOUNCE_LIMIT)
      r_Count <= r_Count + 1;
 

    else if (r_Count == c_DEBOUNCE_LIMIT)
    begin
      r_State <= i_Switch;
      r_Count <= 0;
    end 
 

    else
      r_Count <= 0;
  end
 

  assign o_Switch = r_State;
 
endmodule