data/full_repos/permissive/117026779/src/Keyboard.v
1: b"%Error: data/full_repos/permissive/117026779/src/Keyboard.v:256: Cannot find file containing module: 'Syncronizer'\nSyncronizer #(.WIDTH(1)) sync_clk (\n^~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/117026779/src,data/full_repos/permissive/117026779/Syncronizer\n             data/full_repos/permissive/117026779/src,data/full_repos/permissive/117026779/Syncronizer.v\n             data/full_repos/permissive/117026779/src,data/full_repos/permissive/117026779/Syncronizer.sv\n             Syncronizer\n             Syncronizer.v\n             Syncronizer.sv\n             obj_dir/Syncronizer\n             obj_dir/Syncronizer.v\n             obj_dir/Syncronizer.sv\n%Error: data/full_repos/permissive/117026779/src/Keyboard.v:264: Cannot find file containing module: 'Syncronizer'\nSyncronizer #(.WIDTH(1)) sync_data (\n^~~~~~~~~~~\n%Error: data/full_repos/permissive/117026779/src/Keyboard.v:272: Cannot find file containing module: 'SHIFTREGISTER'\nSHIFTREGISTER #(.WIDTH(11)) scan_code_register (\n^~~~~~~~~~~~~\n%Error: data/full_repos/permissive/117026779/src/Keyboard.v:292: Cannot find file containing module: 'COUNTER'\nCOUNTER #(.WIDTH(4)) counter_ps2_clks (\n^~~~~~~\n%Error: data/full_repos/permissive/117026779/src/Keyboard.v:302: Cannot find file containing module: 'XNOR'\nXNOR #(.WIDTH(8)) parity_checker (\n^~~~\n%Error: data/full_repos/permissive/117026779/src/Keyboard.v:307: Cannot find file containing module: 'XNOR'\nXNOR #(.WIDTH(2)) parity_matcher (\n^~~~\n%Error: data/full_repos/permissive/117026779/src/Keyboard.v:312: Cannot find file containing module: 'AND'\nAND #(.WIDTH(2)) new_signal (\n^~~\n%Error: data/full_repos/permissive/117026779/src/Keyboard.v:317: Cannot find file containing module: 'TRIBUFFER'\nTRIBUFFER #(.WIDTH(8)) scan_code_buffer (\n^~~~~~~~~\n%Error: data/full_repos/permissive/117026779/src/Keyboard.v:97: Cannot find file containing module: 'FIFO'\nFIFO #(\n^~~~\n%Error: data/full_repos/permissive/117026779/src/Keyboard.v:503: Cannot find file containing module: 'VGA_Terminal'\nVGA_Terminal vga_term(\n^~~~~~~~~~~~\n%Error: Exiting due to 10 error(s)\n"
module Keyboard_DEMO(

    input wire clk,
    input wire rst,
    input wire ps2_clk,
    input wire ps2_data,

    input wire text_button,
    input wire background_button,
    output wire ready,

    output wire hsync,

    output wire vsync,

    output wire [`RGB_RESOLUTION-1:0] r,
    output wire [`RGB_RESOLUTION-1:0] g,
    output wire [`RGB_RESOLUTION-1:0] b
);

wire [7:0] ascii;
wire [7:0] scan_code;
wire busy;

reg [12:0] address;
wire next;
wire [31:0] extended_count;
wire command;

ASCII_Keyboard keyboard(
    .clk(!clk),
    .rst(rst),
    .ps2_clk(ps2_clk),
    .ps2_data(ps2_data),
    .oe(1),
    .next(!busy),
    .ascii(ascii),
    .ready(ready),
    .scan_code_reg(scan_code),
    .extended_count(extended_count),
    .command(command)
);

VGA_Terminal vga_term(
    .clk(clk),
    .rst(rst),
    .hsync(hsync),
    .vsync(vsync),
    .r(r),
    .g(g),
    .b(b),
    .value0(32'h0),  .value1(32'h0),  .value2({20'h0, address}),   .value3({24'h0, ascii}),
    .value4(32'h0),  .value5(32'h0),  .value6({24'h0, scan_code}), .value7(extended_count),
    .value8(32'h0),  .value9(32'h0),  .value10(32'h0),             .value11(32'h0),
    .value12(32'h0), .value13(32'h0), .value14(32'h0),             .value15(32'h0),
    .value16(32'h0), .value17(32'h0), .value18(32'h0),             .value19(32'h0),
    .address(address),
    .data(ascii),
    .cs({ ready && !command }),
    .busy(busy),
    .text(text_color_reg),
    .background(background_color_reg)
);

reg [2:0] text_color_reg;
reg [2:0] background_color_reg;
reg previous_tsync;
reg previous_bsync;
reg previously_backspace;
reg previously_busy;

always @(posedge clk or posedge rst)
begin
    if(rst)
    begin
        text_color_reg = 3'b010;
        background_color_reg = 3'b000;
        previous_tsync = 0;
        previous_bsync = 0;
        address = 0;
        previously_busy = 1;
    end
    else
    begin
        if(ready && !busy)
        begin
            if(ascii == "\n")
            begin
                address = (address + 80) - (address % 80);
            end
            else if(ascii == `LEFT_ARROW_ASCII)
            begin
                address = address - 1;
            end
            else if(ascii == `RIGHT_ARROW_ASCII)
            begin
                address = address + 1;
            end
            else if(ascii == `UP_ARROW_ASCII)
            begin
                address = address - 80;
            end
            else if(ascii == `DOWN_ARROW_ASCII)
            begin
                address = address + 80;
            end
            else if(ascii == `BACKSPACE)
            begin
                address = address - 1;
            end
            else
            begin
                address = address + 1;
            end
        end

        if(!background_button && previous_bsync)
        begin
            background_color_reg = background_color_reg + 1;
            previous_bsync = 0;
        end
        if(background_button && !previous_bsync)
        begin
            previous_bsync = 1;
        end

        if(!text_button && previous_tsync)
        begin
            text_color_reg = text_color_reg + 1;
            previous_tsync = 0;
        end
        if(text_button && !previous_tsync)
        begin
            previous_tsync = 1;
        end
    end
end

endmodule
module Keyboard_DEMO(

    input wire clk,
    input wire rst,
    input wire ps2_clk,
    input wire ps2_data,

    input wire text_button,
    input wire background_button,
    output wire ready,

    output wire hsync,

    output wire vsync,

    output wire [`RGB_RESOLUTION-1:0] r,
    output wire [`RGB_RESOLUTION-1:0] g,
    output wire [`RGB_RESOLUTION-1:0] b
);


wire [7:0] ascii;
wire [7:0] scan_code;
wire busy;

reg [12:0] address;
wire next;
wire [31:0] extended_count;
wire command;

ASCII_Keyboard keyboard(
    .clk(!clk),
    .rst(rst),
    .ps2_clk(ps2_clk),
    .ps2_data(ps2_data),
    .oe(1),
    .next(!busy),
    .ascii(ascii),
    .ready(ready),
    .scan_code_reg(scan_code),
    .extended_count(extended_count),
    .command(command)
);

VGA_Terminal vga_term(
    .clk(clk),
    .rst(rst),
    .hsync(hsync),
    .vsync(vsync),
    .r(r),
    .g(g),
    .b(b),
    .value0(32'h0),  .value1(32'h0),  .value2({20'h0, address}),   .value3({24'h0, ascii}),
    .value4(32'h0),  .value5(32'h0),  .value6({24'h0, scan_code}), .value7(extended_count),
    .value8(32'h0),  .value9(32'h0),  .value10(32'h0),             .value11(32'h0),
    .value12(32'h0), .value13(32'h0), .value14(32'h0),             .value15(32'h0),
    .value16(32'h0), .value17(32'h0), .value18(32'h0),             .value19(32'h0),
    .address(address),
    .data(ascii),
    .cs({ ready && !command }),
    .busy(busy),
    .text(text_color_reg),
    .background(background_color_reg)
);

reg [2:0] text_color_reg;
reg [2:0] background_color_reg;
reg previous_tsync;
reg previous_bsync;
reg previously_backspace;
reg previously_busy;

always @(posedge clk or posedge rst)
begin
    if(rst)
    begin
        text_color_reg = 3'b010;
        background_color_reg = 3'b000;
        previous_tsync = 0;
        previous_bsync = 0;
        address = 0;
        previously_busy = 1;
    end
    else
    begin
        if(ready && !busy)
        begin
            if(ascii == "\n")
            begin
                address = (address + 80) - (address % 80);
            end
            else if(ascii == `LEFT_ARROW_ASCII)
            begin
                address = address - 1;
            end
            else if(ascii == `RIGHT_ARROW_ASCII)
            begin
                address = address + 1;
            end
            else if(ascii == `UP_ARROW_ASCII)
            begin
                address = address - 80;
            end
            else if(ascii == `DOWN_ARROW_ASCII)
            begin
                address = address + 80;
            end
            else if(ascii == `BACKSPACE)
            begin
                address = address - 1;
            end
            else
            begin
                address = address + 1;
            end
        end

        if(!background_button && previous_bsync)
        begin
            background_color_reg = background_color_reg + 1;
            previous_bsync = 0;
        end
        if(background_button && !previous_bsync)
        begin
            previous_bsync = 1;
        end

        if(!text_button && previous_tsync)
        begin
            text_color_reg = text_color_reg + 1;
            previous_tsync = 0;
        end
        if(text_button && !previous_tsync)
        begin
            previous_tsync = 1;
        end
    end
end

endmodule