data/full_repos/permissive/137045072/uart_transmit_debouncing.v
data/verilator_xmls/05dceed3-5c4c-4b67-8a4e-004dfea0f460.xml
module uart_transmit_debouncing #(
    parameter threshold = 100000
)(
    input clk,
    input btn1,
    output reg transmit
    );
    
    reg button_ff1 = 0;
    reg button_ff2 = 0;
    reg [30:0]count = 0;



    always @(posedge clk)
    begin
        button_ff1 <= btn1;
        button_ff2 <= button_ff1;
    end



    always @(posedge clk)
    begin 
        if (button_ff2)
        begin
            if (~&count)
                count <= count + 1;
        end else begin
            if (|count)
                count <= count - 1;
        end
        if (count > threshold)
            transmit <= 1;
        else
            transmit <= 0;
    end


endmodule
module uart_transmit_debouncing #(
    parameter threshold = 100000
)(
    input clk,
    input btn1,
    output reg transmit
    );

    
    reg button_ff1 = 0;
    reg button_ff2 = 0;
    reg [30:0]count = 0;



    always @(posedge clk)
    begin
        button_ff1 <= btn1;
        button_ff2 <= button_ff1;
    end



    always @(posedge clk)
    begin 
        if (button_ff2)
        begin
            if (~&count)
                count <= count + 1;
        end else begin
            if (|count)
                count <= count - 1;
        end
        if (count > threshold)
            transmit <= 1;
        else
            transmit <= 0;
    end


endmodule