data/full_repos/permissive/464047548/debounce.v
1: b"%Error: data/full_repos/permissive/464047548/debounce.v:25: syntax error, unexpected ')', expecting '['\n) (\n^\n%Error: data/full_repos/permissive/464047548/debounce.v:27: syntax error, unexpected input, expecting IDENTIFIER or do or final\n    input wire [BUTTONS-1:0] btn,\n    ^~~~~\n%Error: data/full_repos/permissive/464047548/debounce.v:28: syntax error, unexpected output, expecting IDENTIFIER or do or final\n    output wire [BUTTONS-1:0] val,\n    ^~~~~~\n%Error: data/full_repos/permissive/464047548/debounce.v:29: syntax error, unexpected output, expecting IDENTIFIER or do or final\n    output wire [BUTTONS-1:0] strb,\n    ^~~~~~\n%Error: data/full_repos/permissive/464047548/debounce.v:30: syntax error, unexpected ')', expecting IDENTIFIER or do or final\n);\n^\n%Error: data/full_repos/permissive/464047548/debounce.v:34: syntax error, unexpected genvar\n    genvar i;\n    ^~~~~~\n%Error: Exiting due to 6 error(s)\n"
module debounce #(
    parameter DEBOUNCE_TIME = 400_000,
    parameter BUTTONS = 4,
) (
    input wire  clk,
    input wire [BUTTONS-1:0] btn,
    output wire [BUTTONS-1:0] val,
    output wire [BUTTONS-1:0] strb,
);
    reg [BUTTONS-1:0] last_btn, btn_change, strobe;
    reg [23:0] timer [0:BUTTONS-1];

    genvar i;
    generate 
        for (i = 0; i < BUTTONS; i = i + 1) begin
            always @(posedge clk) begin
                if (last_btn[i] != btn[i]) begin
                    btn_change[i] <= 1;
                    timer[i] <= 0;
                    strobe[i] <= 0;
                end else if (btn_change[i]) begin
                    if (timer[i] > DEBOUNCE_TIME) begin
                        btn_change[i] <= 0;
                        strobe[i] <= 1;
                    end else begin
                        timer[i] <= timer[i] + 1;
                        strobe[i] <= 0;
                    end
                end else if (strobe[i]) begin
                    strobe[i] <= 0;
                end
                
                last_btn[i] <= btn[i];
            end
        end
    endgenerate

    assign val = last_btn;
    assign strb = strobe;
endmodule
module debounce #(
    parameter DEBOUNCE_TIME = 400_000,
    parameter BUTTONS = 4,
) (
    input wire  clk,
    input wire [BUTTONS-1:0] btn,
    output wire [BUTTONS-1:0] val,
    output wire [BUTTONS-1:0] strb,
);

    reg [BUTTONS-1:0] last_btn, btn_change, strobe;
    reg [23:0] timer [0:BUTTONS-1];

    genvar i;
    generate 
        for (i = 0; i < BUTTONS; i = i + 1) begin
            always @(posedge clk) begin
                if (last_btn[i] != btn[i]) begin
                    btn_change[i] <= 1;
                    timer[i] <= 0;
                    strobe[i] <= 0;
                end else if (btn_change[i]) begin
                    if (timer[i] > DEBOUNCE_TIME) begin
                        btn_change[i] <= 0;
                        strobe[i] <= 1;
                    end else begin
                        timer[i] <= timer[i] + 1;
                        strobe[i] <= 0;
                    end
                end else if (strobe[i]) begin
                    strobe[i] <= 0;
                end
                
                last_btn[i] <= btn[i];
            end
        end
    endgenerate

    assign val = last_btn;
    assign strb = strobe;
endmodule