data/full_repos/permissive/132439949/sources_1/new/vga_pong.v
1: b'%Error: data/full_repos/permissive/132439949/sources_1/new/vga_pong.v:53: Cannot find file containing module: \'music_instrument\'\n        music_instrument ms(clk, toggle, note, sound);\n        ^~~~~~~~~~~~~~~~\n        ... Looked in:\n             data/full_repos/permissive/132439949/sources_1/new,data/full_repos/permissive/132439949/music_instrument\n             data/full_repos/permissive/132439949/sources_1/new,data/full_repos/permissive/132439949/music_instrument.v\n             data/full_repos/permissive/132439949/sources_1/new,data/full_repos/permissive/132439949/music_instrument.sv\n             music_instrument\n             music_instrument.v\n             music_instrument.sv\n             obj_dir/music_instrument\n             obj_dir/music_instrument.v\n             obj_dir/music_instrument.sv\n%Error: data/full_repos/permissive/132439949/sources_1/new/vga_pong.v:63: Cannot find file containing module: \'vga_sync\'\n        vga_sync vga_sync_unit (.clk(clk), .reset(reset), .hsync(hsync), .vsync(vsync),\n        ^~~~~~~~\n%Warning-WIDTH: data/full_repos/permissive/132439949/sources_1/new/vga_pong.v:201: Operator GT expects 11 bits on the LHS, but LHS\'s VARREF \'x\' generates 10 bits.\n                                                                                 : ... In instance vga_pong\n                else if((x > paddle_x_l && x < paddle_x_r) && (y > paddle_y_u && y < paddle_y_d))\n                           ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/132439949/sources_1/new/vga_pong.v:201: Operator LT expects 11 bits on the LHS, but LHS\'s VARREF \'x\' generates 10 bits.\n                                                                                 : ... In instance vga_pong\n                else if((x > paddle_x_l && x < paddle_x_r) && (y > paddle_y_u && y < paddle_y_d))\n                                             ^\n%Warning-WIDTH: data/full_repos/permissive/132439949/sources_1/new/vga_pong.v:201: Operator GT expects 11 bits on the LHS, but LHS\'s VARREF \'y\' generates 10 bits.\n                                                                                 : ... In instance vga_pong\n                else if((x > paddle_x_l && x < paddle_x_r) && (y > paddle_y_u && y < paddle_y_d))\n                                                                 ^\n%Warning-WIDTH: data/full_repos/permissive/132439949/sources_1/new/vga_pong.v:201: Operator LT expects 11 bits on the LHS, but LHS\'s VARREF \'y\' generates 10 bits.\n                                                                                 : ... In instance vga_pong\n                else if((x > paddle_x_l && x < paddle_x_r) && (y > paddle_y_u && y < paddle_y_d))\n                                                                                   ^\n%Warning-WIDTH: data/full_repos/permissive/132439949/sources_1/new/vga_pong.v:199: Operator GT expects 11 bits on the LHS, but LHS\'s VARREF \'x\' generates 10 bits.\n                                                                                 : ... In instance vga_pong\n                if((x > ball_x_l && x < ball_x_r) && (y > ball_y_u && y < ball_y_d))\n                      ^\n%Warning-WIDTH: data/full_repos/permissive/132439949/sources_1/new/vga_pong.v:199: Operator LT expects 11 bits on the LHS, but LHS\'s VARREF \'x\' generates 10 bits.\n                                                                                 : ... In instance vga_pong\n                if((x > ball_x_l && x < ball_x_r) && (y > ball_y_u && y < ball_y_d))\n                                      ^\n%Warning-WIDTH: data/full_repos/permissive/132439949/sources_1/new/vga_pong.v:199: Operator GT expects 11 bits on the LHS, but LHS\'s VARREF \'y\' generates 10 bits.\n                                                                                 : ... In instance vga_pong\n                if((x > ball_x_l && x < ball_x_r) && (y > ball_y_u && y < ball_y_d))\n                                                        ^\n%Warning-WIDTH: data/full_repos/permissive/132439949/sources_1/new/vga_pong.v:199: Operator LT expects 11 bits on the LHS, but LHS\'s VARREF \'y\' generates 10 bits.\n                                                                                 : ... In instance vga_pong\n                if((x > ball_x_l && x < ball_x_r) && (y > ball_y_u && y < ball_y_d))\n                                                                        ^\n%Error: Exiting due to 2 error(s), 8 warning(s)\n'
module vga_pong
	(
		input wire clk, reset,
		input left, right,
		output wire hsync, vsync,
		output [11:0] rgb,
		
		output [11:0] sound
	);
	


	localparam key_width = 60;
    localparam key_border_width = 4;
    localparam keyboard_x_l = 66;
    localparam keyboard_x_r = 573;
    localparam keyboard_y_u = 191;
    localparam keyboard_y_d = 523; 
    
    localparam COL_WHITE = 12'b111111111111;
    localparam COL_BLACK = 12'b000000000000; 
    localparam COL_BALL = 12'b001011111010;
	

    reg [10:0] paddle_x_l = 0;
    reg [10:0] paddle_x_r = 50;
    reg [10:0] paddle_y_u = 469;
    reg [10:0] paddle_y_d = 479; 
	

	reg [10:0] ball_x_l = 22;
    reg [10:0] ball_x_r = 28;  
    reg [10:0] ball_y_u = 463;
    reg [10:0] ball_y_d = 469; 
       
	reg [11:0] rgb_reg;
	wire [9:0] x, y;
	
	reg paddle_reverse = 0;
    reg ball_x_reverse = 0;
    reg ball_y_reverse = 0;
    reg ball_stop = 0;
    reg paddle_stop = 0;    
    
    reg booleanAdd = 0;
    reg add=0;
    
    reg [3:0] toggle = 4'b0100;
        reg [6:0] note = 7'b00000000;
        reg [17:0] played = 1;
        reg hit = 0;
        music_instrument ms(clk, toggle, note, sound);
    
    always begin
        paddle_stop = ~(left || right);
    end                

	wire video_on;
    reg [17:0] COUNT = 0;
    reg SLOW_CLK = 0;

        vga_sync vga_sync_unit (.clk(clk), .reset(reset), .hsync(hsync), .vsync(vsync),
                                .video_on(video_on), .p_tick(), .x(x), .y(y));
   


        
         always @ (posedge clk) begin
                if (hit) begin
                        note <= 7'b01000000;
                        played <= played + 1;
                end
                else begin
                        note <= 7'b0;
                end
           end
       
        
        always @ (posedge clk, posedge reset) begin
            if (reset) begin COUNT <= 0; end
            COUNT <= COUNT+1;
            SLOW_CLK = (COUNT == 0)? ~SLOW_CLK : SLOW_CLK;
        end
        
        always @ (posedge clk,posedge reset) begin
            if (reset) begin paddle_reverse = 0; end
            else begin
                if (left) begin
                    paddle_reverse <= 1;
                end
                else begin
                    if (right) begin
                        paddle_reverse <= 0;
                    end
                end
            end                
        end
        
        always @ (posedge clk, posedge reset) begin
            if (reset) begin ball_x_reverse <= 0; end
            else begin
                if (ball_x_r == 639) begin
                    ball_x_reverse <= 1;
                end
                if (ball_x_l == 0) begin
                    ball_x_reverse <= 0;
                end       
            end         
        end
        
        always @ (posedge clk, posedge reset) begin
            if (reset) begin ball_y_reverse <= 0; ball_stop<=0; end
            else begin
                if (ball_y_u == 20) begin
                    ball_y_reverse <= 0;
                end
                if (ball_y_d == 469) begin
                     
                    if (ball_x_l > paddle_x_l && ball_x_r < paddle_x_r) begin 
                        ball_y_reverse <= 1;
                        
                        hit <= 1;

                  
                    end
                end                
                if (ball_y_d == 479) begin
                    ball_stop <= 1;
                end
                if (played == 0) begin
                    hit <= 0;
                end
                
       
            end
        end        
                
        always @ (posedge SLOW_CLK, posedge reset) begin
            if (reset) begin 
                paddle_x_l <= 0;
                paddle_x_r <= 50;
                paddle_y_u <= 469;
                paddle_y_d <= 479; 
                

                ball_x_l <= 22;
                ball_x_r <= 28;  
                ball_y_u <= 463;
                ball_y_d <= 469;
            end
            else begin
                if (!paddle_stop && !ball_stop) begin
                    if (paddle_reverse) begin
                        if (paddle_x_l > 0) begin
                            paddle_x_l <= paddle_x_l - 1;
                            paddle_x_r <= paddle_x_r - 1;
                        end
                    end
                    else begin
                        if (paddle_x_r < 639) begin
                            paddle_x_l <= paddle_x_l + 1;
                            paddle_x_r <= paddle_x_r + 1;
                        end
                    end
                end
                if (!ball_stop) begin
                    if (ball_x_reverse) begin
                        ball_x_l <= ball_x_l - 1;
                        ball_x_r <= ball_x_r - 1;
                    end
                    else begin
                        ball_x_l <= ball_x_l + 1;
                        ball_x_r <= ball_x_r + 1;
                    end
                    if (ball_y_reverse) begin
                        ball_y_u <= ball_y_u - 1;
                        ball_y_d <= ball_y_d - 1;
                    end
                    else begin
                        ball_y_u <= ball_y_u + 1;
                        ball_y_d <= ball_y_d + 1;
                    end
                    
                end
                
             
            end
        end
        
        always @ (posedge clk , posedge reset) begin
            if (reset) begin rgb_reg <= 0; end
            else begin 
                if((x > ball_x_l && x < ball_x_r) && (y > ball_y_u && y < ball_y_d))
                    begin rgb_reg <= COL_BALL; end
                else if((x > paddle_x_l && x < paddle_x_r) && (y > paddle_y_u && y < paddle_y_d))
                    begin rgb_reg <= COL_WHITE; end
                else begin rgb_reg <= 0; end
            end  
        end
        assign rgb = (video_on) ? rgb_reg : 12'b0 ;
                    
endmodule
module vga_pong
	(
		input wire clk, reset,
		input left, right,
		output wire hsync, vsync,
		output [11:0] rgb,
		
		output [11:0] sound
	);

	


	localparam key_width = 60;
    localparam key_border_width = 4;
    localparam keyboard_x_l = 66;
    localparam keyboard_x_r = 573;
    localparam keyboard_y_u = 191;
    localparam keyboard_y_d = 523; 
    
    localparam COL_WHITE = 12'b111111111111;
    localparam COL_BLACK = 12'b000000000000; 
    localparam COL_BALL = 12'b001011111010;
	

    reg [10:0] paddle_x_l = 0;
    reg [10:0] paddle_x_r = 50;
    reg [10:0] paddle_y_u = 469;
    reg [10:0] paddle_y_d = 479; 
	

	reg [10:0] ball_x_l = 22;
    reg [10:0] ball_x_r = 28;  
    reg [10:0] ball_y_u = 463;
    reg [10:0] ball_y_d = 469; 
       
	reg [11:0] rgb_reg;
	wire [9:0] x, y;
	
	reg paddle_reverse = 0;
    reg ball_x_reverse = 0;
    reg ball_y_reverse = 0;
    reg ball_stop = 0;
    reg paddle_stop = 0;    
    
    reg booleanAdd = 0;
    reg add=0;
    
    reg [3:0] toggle = 4'b0100;
        reg [6:0] note = 7'b00000000;
        reg [17:0] played = 1;
        reg hit = 0;
        music_instrument ms(clk, toggle, note, sound);
    
    always begin
        paddle_stop = ~(left || right);
    end                

	wire video_on;
    reg [17:0] COUNT = 0;
    reg SLOW_CLK = 0;

        vga_sync vga_sync_unit (.clk(clk), .reset(reset), .hsync(hsync), .vsync(vsync),
                                .video_on(video_on), .p_tick(), .x(x), .y(y));
   


        
         always @ (posedge clk) begin
                if (hit) begin
                        note <= 7'b01000000;
                        played <= played + 1;
                end
                else begin
                        note <= 7'b0;
                end
           end
       
        
        always @ (posedge clk, posedge reset) begin
            if (reset) begin COUNT <= 0; end
            COUNT <= COUNT+1;
            SLOW_CLK = (COUNT == 0)? ~SLOW_CLK : SLOW_CLK;
        end
        
        always @ (posedge clk,posedge reset) begin
            if (reset) begin paddle_reverse = 0; end
            else begin
                if (left) begin
                    paddle_reverse <= 1;
                end
                else begin
                    if (right) begin
                        paddle_reverse <= 0;
                    end
                end
            end                
        end
        
        always @ (posedge clk, posedge reset) begin
            if (reset) begin ball_x_reverse <= 0; end
            else begin
                if (ball_x_r == 639) begin
                    ball_x_reverse <= 1;
                end
                if (ball_x_l == 0) begin
                    ball_x_reverse <= 0;
                end       
            end         
        end
        
        always @ (posedge clk, posedge reset) begin
            if (reset) begin ball_y_reverse <= 0; ball_stop<=0; end
            else begin
                if (ball_y_u == 20) begin
                    ball_y_reverse <= 0;
                end
                if (ball_y_d == 469) begin
                     
                    if (ball_x_l > paddle_x_l && ball_x_r < paddle_x_r) begin 
                        ball_y_reverse <= 1;
                        
                        hit <= 1;

                  
                    end
                end                
                if (ball_y_d == 479) begin
                    ball_stop <= 1;
                end
                if (played == 0) begin
                    hit <= 0;
                end
                
       
            end
        end        
                
        always @ (posedge SLOW_CLK, posedge reset) begin
            if (reset) begin 
                paddle_x_l <= 0;
                paddle_x_r <= 50;
                paddle_y_u <= 469;
                paddle_y_d <= 479; 
                

                ball_x_l <= 22;
                ball_x_r <= 28;  
                ball_y_u <= 463;
                ball_y_d <= 469;
            end
            else begin
                if (!paddle_stop && !ball_stop) begin
                    if (paddle_reverse) begin
                        if (paddle_x_l > 0) begin
                            paddle_x_l <= paddle_x_l - 1;
                            paddle_x_r <= paddle_x_r - 1;
                        end
                    end
                    else begin
                        if (paddle_x_r < 639) begin
                            paddle_x_l <= paddle_x_l + 1;
                            paddle_x_r <= paddle_x_r + 1;
                        end
                    end
                end
                if (!ball_stop) begin
                    if (ball_x_reverse) begin
                        ball_x_l <= ball_x_l - 1;
                        ball_x_r <= ball_x_r - 1;
                    end
                    else begin
                        ball_x_l <= ball_x_l + 1;
                        ball_x_r <= ball_x_r + 1;
                    end
                    if (ball_y_reverse) begin
                        ball_y_u <= ball_y_u - 1;
                        ball_y_d <= ball_y_d - 1;
                    end
                    else begin
                        ball_y_u <= ball_y_u + 1;
                        ball_y_d <= ball_y_d + 1;
                    end
                    
                end
                
             
            end
        end
        
        always @ (posedge clk , posedge reset) begin
            if (reset) begin rgb_reg <= 0; end
            else begin 
                if((x > ball_x_l && x < ball_x_r) && (y > ball_y_u && y < ball_y_d))
                    begin rgb_reg <= COL_BALL; end
                else if((x > paddle_x_l && x < paddle_x_r) && (y > paddle_y_u && y < paddle_y_d))
                    begin rgb_reg <= COL_WHITE; end
                else begin rgb_reg <= 0; end
            end  
        end
        assign rgb = (video_on) ? rgb_reg : 12'b0 ;
                    
endmodule