data/full_repos/permissive/423547971/FPGA Projects/VGA Projects/VGA Bouncing Square/pixel_generation.v
1: b'%Error: Cannot find file containing module: Projects/VGA\n        ... Looked in:\n             data/full_repos/permissive/423547971/FPGA/Projects/VGA\n             data/full_repos/permissive/423547971/FPGA/Projects/VGA.v\n             data/full_repos/permissive/423547971/FPGA/Projects/VGA.sv\n             Projects/VGA\n             Projects/VGA.v\n             Projects/VGA.sv\n             obj_dir/Projects/VGA\n             obj_dir/Projects/VGA.v\n             obj_dir/Projects/VGA.sv\n%Error: Cannot find file containing module: Bouncing\n%Error: Cannot find file containing module: Square,data/full_repos/permissive/423547971\n%Error: Cannot find file containing module: data/full_repos/permissive/423547971/FPGA\n%Error: Cannot find file containing module: Square/pixel_generation.v\n%Error: Exiting due to 5 error(s)\n'
module pixel_generation(
    input clk,
    input reset,
    input video_on,
    input [9:0] x, y,
    output reg [11:0] rgb
    );
    
    parameter X_MAX = 639;
    parameter Y_MAX = 479;
    parameter SQ_RGB = 12'h0FF;
    parameter BG_RGB = 12'hF00;
    parameter SQUARE_SIZE = 64;
    parameter SQUARE_VELOCITY_POS = 2;
    parameter SQUARE_VELOCITY_NEG = -2;
    

    wire refresh_tick;
    assign refresh_tick = ((y == 481) && (x == 0)) ? 1 : 0;
    

    wire [9:0] sq_x_l, sq_x_r;
    wire [9:0] sq_y_t, sq_y_b;
    
    reg [9:0] sq_x_reg, sq_y_reg;
    wire [9:0] sq_x_next, sq_y_next;
    
    reg [9:0] x_delta_reg, y_delta_reg;
    reg [9:0] x_delta_next, y_delta_next;
    

    always @(posedge clk or posedge reset)
        if(reset) begin
            sq_x_reg <= 0;
            sq_y_reg <= 0;
            x_delta_reg <= 10'h002;
            y_delta_reg <= 10'h002;
        end
        else begin
            sq_x_reg <= sq_x_next;
            sq_y_reg <= sq_y_next;
            x_delta_reg <= x_delta_next;
            y_delta_reg <= y_delta_next;
        end
    

    assign sq_x_l = sq_x_reg;
    assign sq_y_t = sq_y_reg;
    assign sq_x_r = sq_x_l + SQUARE_SIZE - 1;
    assign sq_y_b = sq_y_t + SQUARE_SIZE - 1;
    

    wire sq_on;
    assign sq_on = (sq_x_l <= x) && (x <= sq_x_r) &&
                   (sq_y_t <= y) && (y <= sq_y_b);
                   

    assign sq_x_next = (refresh_tick) ? sq_x_reg + x_delta_reg : sq_x_reg;
    assign sq_y_next = (refresh_tick) ? sq_y_reg + y_delta_reg : sq_y_reg;
    

    always @* begin
        x_delta_next = x_delta_reg;
        y_delta_next = y_delta_reg;
        if(sq_y_t < 1)
            y_delta_next = SQUARE_VELOCITY_POS;
        else if(sq_y_b > Y_MAX)
            y_delta_next = SQUARE_VELOCITY_NEG;
        else if(sq_x_l < 1)
            x_delta_next = SQUARE_VELOCITY_POS;
        else if(sq_x_r > X_MAX)
            x_delta_next = SQUARE_VELOCITY_NEG;
    end
    

    always @*
        if(~video_on)
            rgb = 12'h000;
        else
            if(sq_on)
                rgb = SQ_RGB;
            else
                rgb = BG_RGB;
    
endmodule
module pixel_generation(
    input clk,
    input reset,
    input video_on,
    input [9:0] x, y,
    output reg [11:0] rgb
    );

    
    parameter X_MAX = 639;
    parameter Y_MAX = 479;
    parameter SQ_RGB = 12'h0FF;
    parameter BG_RGB = 12'hF00;
    parameter SQUARE_SIZE = 64;
    parameter SQUARE_VELOCITY_POS = 2;
    parameter SQUARE_VELOCITY_NEG = -2;
    

    wire refresh_tick;
    assign refresh_tick = ((y == 481) && (x == 0)) ? 1 : 0;
    

    wire [9:0] sq_x_l, sq_x_r;
    wire [9:0] sq_y_t, sq_y_b;
    
    reg [9:0] sq_x_reg, sq_y_reg;
    wire [9:0] sq_x_next, sq_y_next;
    
    reg [9:0] x_delta_reg, y_delta_reg;
    reg [9:0] x_delta_next, y_delta_next;
    

    always @(posedge clk or posedge reset)
        if(reset) begin
            sq_x_reg <= 0;
            sq_y_reg <= 0;
            x_delta_reg <= 10'h002;
            y_delta_reg <= 10'h002;
        end
        else begin
            sq_x_reg <= sq_x_next;
            sq_y_reg <= sq_y_next;
            x_delta_reg <= x_delta_next;
            y_delta_reg <= y_delta_next;
        end
    

    assign sq_x_l = sq_x_reg;
    assign sq_y_t = sq_y_reg;
    assign sq_x_r = sq_x_l + SQUARE_SIZE - 1;
    assign sq_y_b = sq_y_t + SQUARE_SIZE - 1;
    

    wire sq_on;
    assign sq_on = (sq_x_l <= x) && (x <= sq_x_r) &&
                   (sq_y_t <= y) && (y <= sq_y_b);
                   

    assign sq_x_next = (refresh_tick) ? sq_x_reg + x_delta_reg : sq_x_reg;
    assign sq_y_next = (refresh_tick) ? sq_y_reg + y_delta_reg : sq_y_reg;
    

    always @* begin
        x_delta_next = x_delta_reg;
        y_delta_next = y_delta_reg;
        if(sq_y_t < 1)
            y_delta_next = SQUARE_VELOCITY_POS;
        else if(sq_y_b > Y_MAX)
            y_delta_next = SQUARE_VELOCITY_NEG;
        else if(sq_x_l < 1)
            x_delta_next = SQUARE_VELOCITY_POS;
        else if(sq_x_r > X_MAX)
            x_delta_next = SQUARE_VELOCITY_NEG;
    end
    

    always @*
        if(~video_on)
            rgb = 12'h000;
        else
            if(sq_on)
                rgb = SQ_RGB;
            else
                rgb = BG_RGB;
    
endmodule