data/full_repos/permissive/423547971/FPGA Projects/VGA Projects/Pong pt2/pong_graph.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: Projects/Pong\n%Error: Cannot find file containing module: pt2,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: pt2/pong_graph.v\n%Error: Exiting due to 5 error(s)\n'
module pong_graph(
    input clk,  
    input reset,    
    input [1:0] btn,
    input gra_still,
    input video_on,
    input [9:0] x,
    input [9:0] y,
    output graph_on,
    output reg hit, miss,
    output reg [11:0] graph_rgb
    );
    

    parameter X_MAX = 639;
    parameter Y_MAX = 479;
    

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


    parameter L_WALL_L = 32;    
    parameter L_WALL_R = 39;

    parameter T_WALL_T = 64;    
    parameter T_WALL_B = 71;

    parameter B_WALL_T = 472;    
    parameter B_WALL_B = 479;
    
    
    


    parameter X_PAD_L = 600;
    parameter X_PAD_R = 603;

    wire [9:0] y_pad_t, y_pad_b;
    parameter PAD_HEIGHT = 72;

    reg [9:0] y_pad_reg = 204;
    reg [9:0] y_pad_next;

    parameter PAD_VELOCITY = 3;
    
    


    parameter BALL_SIZE = 8;

    wire [9:0] x_ball_l, x_ball_r;

    wire [9:0] y_ball_t, y_ball_b;

    reg [9:0] y_ball_reg, x_ball_reg;

    wire [9:0] y_ball_next, x_ball_next;

    reg [9:0] x_delta_reg, x_delta_next;
    reg [9:0] y_delta_reg, y_delta_next;

    parameter BALL_VELOCITY_POS = 2;
    parameter BALL_VELOCITY_NEG = -2;

    wire [2:0] rom_addr, rom_col;
    reg [7:0] rom_data;
    wire rom_bit;
    
    

    always @(posedge clk or posedge reset)
        if(reset) begin
            y_pad_reg <= 204;
            x_ball_reg <= 0;
            y_ball_reg <= 0;
            x_delta_reg <= 10'h002;
            y_delta_reg <= 10'h002;
        end
        else begin
            y_pad_reg <= y_pad_next;
            x_ball_reg <= x_ball_next;
            y_ball_reg <= y_ball_next;
            x_delta_reg <= x_delta_next;
            y_delta_reg <= y_delta_next;
        end
    
    

    always @*
        case(rom_addr)
            3'b000 :    rom_data = 8'b00111100;
            3'b001 :    rom_data = 8'b01111110;
            3'b010 :    rom_data = 8'b11111111;
            3'b011 :    rom_data = 8'b11111111;
            3'b100 :    rom_data = 8'b11111111;
            3'b101 :    rom_data = 8'b11111111;
            3'b110 :    rom_data = 8'b01111110;
            3'b111 :    rom_data = 8'b00111100;
        endcase
    
    

    wire l_wall_on, t_wall_on, b_wall_on, pad_on, sq_ball_on, ball_on;
    wire [11:0] wall_rgb, pad_rgb, ball_rgb, bg_rgb;
    
    

    assign l_wall_on = ((L_WALL_L <= x) && (x <= L_WALL_R)) ? 1 : 0;
    assign t_wall_on = ((T_WALL_T <= y) && (y <= T_WALL_B)) ? 1 : 0;
    assign b_wall_on = ((B_WALL_T <= y) && (y <= B_WALL_B)) ? 1 : 0;
    
    

    assign wall_rgb   = 12'h00F;
    assign pad_rgb    = 12'h00F;
    assign ball_rgb   = 12'hF00;
    assign bg_rgb     = 12'h0FF;
    
    

    assign y_pad_t = y_pad_reg;
    assign y_pad_b = y_pad_t + PAD_HEIGHT - 1;
    assign pad_on = (X_PAD_L <= x) && (x <= X_PAD_R) &&
                    (y_pad_t <= y) && (y <= y_pad_b);
       
                    

    always @* begin
        y_pad_next = y_pad_reg;
        
        if(refresh_tick)
            if(btn[1] & (y_pad_b < (B_WALL_T - 1 - PAD_VELOCITY)))
                y_pad_next = y_pad_reg + PAD_VELOCITY;
            else if(btn[0] & (y_pad_t > (T_WALL_B - 1 - PAD_VELOCITY)))
                y_pad_next = y_pad_reg - PAD_VELOCITY;
    end
    
    

    assign x_ball_l = x_ball_reg;
    assign y_ball_t = y_ball_reg;
    assign x_ball_r = x_ball_l + BALL_SIZE - 1;
    assign y_ball_b = y_ball_t + BALL_SIZE - 1;

    assign sq_ball_on = (x_ball_l <= x) && (x <= x_ball_r) &&
                        (y_ball_t <= y) && (y <= y_ball_b);

    assign rom_addr = y[2:0] - y_ball_t[2:0];
    assign rom_col = x[2:0] - x_ball_l[2:0];
    assign rom_bit = rom_data[rom_col];

    assign ball_on = sq_ball_on & rom_bit;
 
  

    assign x_ball_next = (gra_still) ? X_MAX / 2 :
                         (refresh_tick) ? x_ball_reg + x_delta_reg : x_ball_reg;
    assign y_ball_next = (gra_still) ? Y_MAX / 2 :
                         (refresh_tick) ? y_ball_reg + y_delta_reg : y_ball_reg;
    

    always @* begin
        hit = 1'b0;
        miss = 1'b0;
        x_delta_next = x_delta_reg;
        y_delta_next = y_delta_reg;
        
        if(gra_still) begin
            x_delta_next = BALL_VELOCITY_NEG;
            y_delta_next = BALL_VELOCITY_POS;
        end
        
        else if(y_ball_t < T_WALL_B)
            y_delta_next = BALL_VELOCITY_POS;
        
        else if(y_ball_b > (B_WALL_T))
            y_delta_next = BALL_VELOCITY_NEG;
        
        else if(x_ball_l <= L_WALL_R)
            x_delta_next = BALL_VELOCITY_POS;
        
        else if((X_PAD_L <= x_ball_r) && (x_ball_r <= X_PAD_R) &&
                (y_pad_t <= y_ball_b) && (y_ball_t <= y_pad_b)) begin
                    x_delta_next = BALL_VELOCITY_NEG;
                    hit = 1'b1;         
        end
        
        else if(x_ball_r > X_MAX)
            miss = 1'b1;
    end                    
    

    assign graph_on = l_wall_on | t_wall_on | b_wall_on | pad_on | ball_on;
    
    

    always @*
        if(~video_on)
            graph_rgb = 12'h000;
        else
            if(l_wall_on | t_wall_on | b_wall_on)
                graph_rgb = wall_rgb;
            else if(pad_on)
                graph_rgb = pad_rgb;
            else if(ball_on)
                graph_rgb = ball_rgb;
            else
                graph_rgb = bg_rgb;
       
endmodule
module pong_graph(
    input clk,  
    input reset,    
    input [1:0] btn,
    input gra_still,
    input video_on,
    input [9:0] x,
    input [9:0] y,
    output graph_on,
    output reg hit, miss,
    output reg [11:0] graph_rgb
    );

    

    parameter X_MAX = 639;
    parameter Y_MAX = 479;
    

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


    parameter L_WALL_L = 32;    
    parameter L_WALL_R = 39;

    parameter T_WALL_T = 64;    
    parameter T_WALL_B = 71;

    parameter B_WALL_T = 472;    
    parameter B_WALL_B = 479;
    
    
    


    parameter X_PAD_L = 600;
    parameter X_PAD_R = 603;

    wire [9:0] y_pad_t, y_pad_b;
    parameter PAD_HEIGHT = 72;

    reg [9:0] y_pad_reg = 204;
    reg [9:0] y_pad_next;

    parameter PAD_VELOCITY = 3;
    
    


    parameter BALL_SIZE = 8;

    wire [9:0] x_ball_l, x_ball_r;

    wire [9:0] y_ball_t, y_ball_b;

    reg [9:0] y_ball_reg, x_ball_reg;

    wire [9:0] y_ball_next, x_ball_next;

    reg [9:0] x_delta_reg, x_delta_next;
    reg [9:0] y_delta_reg, y_delta_next;

    parameter BALL_VELOCITY_POS = 2;
    parameter BALL_VELOCITY_NEG = -2;

    wire [2:0] rom_addr, rom_col;
    reg [7:0] rom_data;
    wire rom_bit;
    
    

    always @(posedge clk or posedge reset)
        if(reset) begin
            y_pad_reg <= 204;
            x_ball_reg <= 0;
            y_ball_reg <= 0;
            x_delta_reg <= 10'h002;
            y_delta_reg <= 10'h002;
        end
        else begin
            y_pad_reg <= y_pad_next;
            x_ball_reg <= x_ball_next;
            y_ball_reg <= y_ball_next;
            x_delta_reg <= x_delta_next;
            y_delta_reg <= y_delta_next;
        end
    
    

    always @*
        case(rom_addr)
            3'b000 :    rom_data = 8'b00111100;
            3'b001 :    rom_data = 8'b01111110;
            3'b010 :    rom_data = 8'b11111111;
            3'b011 :    rom_data = 8'b11111111;
            3'b100 :    rom_data = 8'b11111111;
            3'b101 :    rom_data = 8'b11111111;
            3'b110 :    rom_data = 8'b01111110;
            3'b111 :    rom_data = 8'b00111100;
        endcase
    
    

    wire l_wall_on, t_wall_on, b_wall_on, pad_on, sq_ball_on, ball_on;
    wire [11:0] wall_rgb, pad_rgb, ball_rgb, bg_rgb;
    
    

    assign l_wall_on = ((L_WALL_L <= x) && (x <= L_WALL_R)) ? 1 : 0;
    assign t_wall_on = ((T_WALL_T <= y) && (y <= T_WALL_B)) ? 1 : 0;
    assign b_wall_on = ((B_WALL_T <= y) && (y <= B_WALL_B)) ? 1 : 0;
    
    

    assign wall_rgb   = 12'h00F;
    assign pad_rgb    = 12'h00F;
    assign ball_rgb   = 12'hF00;
    assign bg_rgb     = 12'h0FF;
    
    

    assign y_pad_t = y_pad_reg;
    assign y_pad_b = y_pad_t + PAD_HEIGHT - 1;
    assign pad_on = (X_PAD_L <= x) && (x <= X_PAD_R) &&
                    (y_pad_t <= y) && (y <= y_pad_b);
       
                    

    always @* begin
        y_pad_next = y_pad_reg;
        
        if(refresh_tick)
            if(btn[1] & (y_pad_b < (B_WALL_T - 1 - PAD_VELOCITY)))
                y_pad_next = y_pad_reg + PAD_VELOCITY;
            else if(btn[0] & (y_pad_t > (T_WALL_B - 1 - PAD_VELOCITY)))
                y_pad_next = y_pad_reg - PAD_VELOCITY;
    end
    
    

    assign x_ball_l = x_ball_reg;
    assign y_ball_t = y_ball_reg;
    assign x_ball_r = x_ball_l + BALL_SIZE - 1;
    assign y_ball_b = y_ball_t + BALL_SIZE - 1;

    assign sq_ball_on = (x_ball_l <= x) && (x <= x_ball_r) &&
                        (y_ball_t <= y) && (y <= y_ball_b);

    assign rom_addr = y[2:0] - y_ball_t[2:0];
    assign rom_col = x[2:0] - x_ball_l[2:0];
    assign rom_bit = rom_data[rom_col];

    assign ball_on = sq_ball_on & rom_bit;
 
  

    assign x_ball_next = (gra_still) ? X_MAX / 2 :
                         (refresh_tick) ? x_ball_reg + x_delta_reg : x_ball_reg;
    assign y_ball_next = (gra_still) ? Y_MAX / 2 :
                         (refresh_tick) ? y_ball_reg + y_delta_reg : y_ball_reg;
    

    always @* begin
        hit = 1'b0;
        miss = 1'b0;
        x_delta_next = x_delta_reg;
        y_delta_next = y_delta_reg;
        
        if(gra_still) begin
            x_delta_next = BALL_VELOCITY_NEG;
            y_delta_next = BALL_VELOCITY_POS;
        end
        
        else if(y_ball_t < T_WALL_B)
            y_delta_next = BALL_VELOCITY_POS;
        
        else if(y_ball_b > (B_WALL_T))
            y_delta_next = BALL_VELOCITY_NEG;
        
        else if(x_ball_l <= L_WALL_R)
            x_delta_next = BALL_VELOCITY_POS;
        
        else if((X_PAD_L <= x_ball_r) && (x_ball_r <= X_PAD_R) &&
                (y_pad_t <= y_ball_b) && (y_ball_t <= y_pad_b)) begin
                    x_delta_next = BALL_VELOCITY_NEG;
                    hit = 1'b1;         
        end
        
        else if(x_ball_r > X_MAX)
            miss = 1'b1;
    end                    
    

    assign graph_on = l_wall_on | t_wall_on | b_wall_on | pad_on | ball_on;
    
    

    always @*
        if(~video_on)
            graph_rgb = 12'h000;
        else
            if(l_wall_on | t_wall_on | b_wall_on)
                graph_rgb = wall_rgb;
            else if(pad_on)
                graph_rgb = pad_rgb;
            else if(ball_on)
                graph_rgb = ball_rgb;
            else
                graph_rgb = bg_rgb;
       
endmodule