data/full_repos/permissive/102543783/hdl/top.v
1: b'%Error: data/full_repos/permissive/102543783/hdl/top.v:65: Cannot find file containing module: \'snes_gamepad\'\n    snes_gamepad gamepad\n    ^~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/102543783/hdl,data/full_repos/permissive/102543783/snes_gamepad\n             data/full_repos/permissive/102543783/hdl,data/full_repos/permissive/102543783/snes_gamepad.v\n             data/full_repos/permissive/102543783/hdl,data/full_repos/permissive/102543783/snes_gamepad.sv\n             snes_gamepad\n             snes_gamepad.v\n             snes_gamepad.sv\n             obj_dir/snes_gamepad\n             obj_dir/snes_gamepad.v\n             obj_dir/snes_gamepad.sv\n%Warning-WIDTH: data/full_repos/permissive/102543783/hdl/top.v:98: Logical Operator COND expects 1 bit on the Conditional Test, but Conditional Test\'s VARREF \'rd_counter_ff\' generates 21 bits.\n                                                                 : ... In instance top\n    assign rd = (rd_counter_ff) ? 1\'b0 : 1\'b1;\n                                ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/102543783/hdl/top.v:101: Logical Operator COND expects 1 bit on the Conditional Test, but Conditional Test\'s VARREF \'rd_counter_ff\' generates 21 bits.\n                                                                  : ... In instance top\n    assign rd_counter_ns = (rd_counter_ff) ? rd_counter_ff - 21\'d1\n                                           ^\n%Error: Exiting due to 1 error(s), 2 warning(s)\n'
module top
    (
    input clk,
    input rst_n,
    
    output snes_clk,
    output snes_latch,
    input snes_data,
    
    output [15:0] led
    );
    
    

    
    localparam RD_COUNTER_MAX = 21'd1666666;
    
    

    
    wire rst;
    
    wire rd, busy;
    wire [15:0] buttons;
    
    reg [20:0] rd_counter_ff;
    wire [20:0] rd_counter_ns;
    
    reg busy_ff;
    wire negedge_busy;
    
    reg [15:0] led_ff;
    wire [15:0] led_ns;
    
    

    
    assign rst = ~rst_n;
    

    assign negedge_busy = busy_ff & ~busy;
    
    

    
    snes_gamepad gamepad
        (
        .clk(clk),
        .rst(rst),
        .rd(rd),
        .busy(busy),
        .snes_clk(snes_clk),
        .snes_latch(snes_latch),
        .snes_data(snes_data),
        .buttons(buttons)
        );
    
    

    
    always @(posedge clk, posedge rst)
        if(rst)
            begin
                rd_counter_ff <= RD_COUNTER_MAX;
                busy_ff <= 1'b0;
                led_ff <= 16'd0;
            end
        else
            begin
                rd_counter_ff <= rd_counter_ns;
                busy_ff <= busy;
                led_ff <= led_ns;
            end
    
    

    

    assign rd = (rd_counter_ff) ? 1'b0 : 1'b1;
    

    assign rd_counter_ns = (rd_counter_ff) ? rd_counter_ff - 21'd1
                                           : RD_COUNTER_MAX;
    

    assign led_ns = (negedge_busy) ? buttons : led_ff;
    
    

    
    assign led = led_ff;
    
endmodule
module top
    (
    input clk,
    input rst_n,
    
    output snes_clk,
    output snes_latch,
    input snes_data,
    
    output [15:0] led
    );

    
    

    
    localparam RD_COUNTER_MAX = 21'd1666666;
    
    

    
    wire rst;
    
    wire rd, busy;
    wire [15:0] buttons;
    
    reg [20:0] rd_counter_ff;
    wire [20:0] rd_counter_ns;
    
    reg busy_ff;
    wire negedge_busy;
    
    reg [15:0] led_ff;
    wire [15:0] led_ns;
    
    

    
    assign rst = ~rst_n;
    

    assign negedge_busy = busy_ff & ~busy;
    
    

    
    snes_gamepad gamepad
        (
        .clk(clk),
        .rst(rst),
        .rd(rd),
        .busy(busy),
        .snes_clk(snes_clk),
        .snes_latch(snes_latch),
        .snes_data(snes_data),
        .buttons(buttons)
        );
    
    

    
    always @(posedge clk, posedge rst)
        if(rst)
            begin
                rd_counter_ff <= RD_COUNTER_MAX;
                busy_ff <= 1'b0;
                led_ff <= 16'd0;
            end
        else
            begin
                rd_counter_ff <= rd_counter_ns;
                busy_ff <= busy;
                led_ff <= led_ns;
            end
    
    

    

    assign rd = (rd_counter_ff) ? 1'b0 : 1'b1;
    

    assign rd_counter_ns = (rd_counter_ff) ? rd_counter_ff - 21'd1
                                           : RD_COUNTER_MAX;
    

    assign led_ns = (negedge_busy) ? buttons : led_ff;
    
    

    
    assign led = led_ff;
    
endmodule