data/full_repos/permissive/196412397/debounce_switch.v
data/verilator_xmls/f2bb00cf-595d-4658-a7e3-4db2da00f935.xml
module debounce_switch(
    input clk,
    input i_switch,
    output o_switch);

    parameter c_debounce_limit=250000;

reg r_state=1'b0;
reg [17:0] r_count = 0;

    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_count <=0;
            r_state <= i_switch;
        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 r_state=1'b0;
reg [17:0] r_count = 0;

    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_count <=0;
            r_state <= i_switch;
        end
        else
            r_count<=0;
    end

assign o_switch=r_state;

endmodule