data/full_repos/permissive/127044786/blocks/Display/iPxs/Overlay/DynPong.v
 line:26: before: "="
1: b'%Warning-WIDTH: data/full_repos/permissive/127044786/blocks/Display/iPxs/Overlay/DynPong.v:132: Operator SUB expects 10 bits on the RHS, but RHS\'s VARREF \'speed_x\' generates 3 bits.\n                                                                                              : ... In instance DynPong\n        x_ball <= x_ball - speed_x;\n                         ^\n                ... Use "/* verilator lint_off WIDTH */" and lint_on around source to disable this message.\n%Warning-WIDTH: data/full_repos/permissive/127044786/blocks/Display/iPxs/Overlay/DynPong.v:134: Operator ADD expects 10 bits on the RHS, but RHS\'s VARREF \'speed_x\' generates 3 bits.\n                                                                                              : ... In instance DynPong\n        x_ball <= x_ball + speed_x; \n                         ^\n%Warning-WIDTH: data/full_repos/permissive/127044786/blocks/Display/iPxs/Overlay/DynPong.v:138: Operator SUB expects 10 bits on the RHS, but RHS\'s VARREF \'speed_y\' generates 3 bits.\n                                                                                              : ... In instance DynPong\n        y_ball <= y_ball - speed_y;\n                         ^\n%Warning-WIDTH: data/full_repos/permissive/127044786/blocks/Display/iPxs/Overlay/DynPong.v:140: Operator ADD expects 10 bits on the RHS, but RHS\'s VARREF \'speed_y\' generates 3 bits.\n                                                                                              : ... In instance DynPong\n        y_ball <= y_ball + speed_y; \n                         ^\n%Error: Exiting due to 4 warning(s)\n'
module DynPong (
    input wire       dyn_clk,
    input wire       reset,
    input wire       play,
    input wire [9:0] pos_ply1,
    input wire [9:0] pos_ply2,
    output reg       reset_goals,
    output reg       goal_ply1,
    output reg       goal_ply2,
    output reg [9:0] x_ball = 10'd100,
    output reg [9:0] y_ball = 10'd100,
    output reg       mute = 1'b1,
    output reg [1:0] sound = 2'd0
);


localparam width_screen = 640;
localparam height_screen = 480;
localparam size_ball = 10;
localparam size_player = 80;
localparam offset_players = 20;
localparam width_players = 10;


reg [7:0] mseg = 0;


reg [2:0] speed_x = 2;
reg [2:0] speed_y = 2;

reg dx = 1'b0;
reg dy = 1'b0;


always @(posedge dyn_clk)
begin

    if (reset)
    begin
        x_ball <= width_screen/2;
        y_ball <= height_screen/2;
        dx <= ~dx;
        dy <= 1'b0;
    end


    if (x_ball == 0)
        begin
        goal_ply2 <= 1'b1;
        sound <= 3; 
        mseg <= 40;
        end
    else
        goal_ply2 <= 1'b0;

    if (x_ball == width_screen-size_ball)
        begin
        goal_ply1 <= 1'b1;
        sound <= 3;
        mseg <= 40;
        end
    else
        goal_ply1 <= 1'b0;


    if  (

        ((x_ball < offset_players + width_players) &&
        (y_ball > pos_ply1) && 
        (y_ball < pos_ply1 + size_player) &&
        (dx == 1'b1)) 
        ||

        ((x_ball > width_screen - offset_players - width_players - size_ball) &&
        (y_ball > pos_ply2) && 
        (y_ball < pos_ply2 + size_player) &&
        (dx == 1'b0))
        ||

        (x_ball == width_screen-size_ball)
        ||

        (x_ball == 0)
        )
        begin
        dx = ~dx;

        if (!((x_ball == width_screen-size_ball) || (x_ball == 0)))
            begin
            sound <= 2;
            mseg <= 30;
            end
        end


    if ((y_ball == 0) || (y_ball == height_screen-size_ball))
        begin
        dy = ~dy;
        sound <= 1;
        mseg <= 10;
        end


    if (mseg == 0)
        begin
        mute <= 1'b1;
        end
    else
        begin
        mseg <= mseg - 1;
        mute <= 1'b0;
        end


    if (dx)
        x_ball <= x_ball - speed_x;
    else
        x_ball <= x_ball + speed_x; 


    if (dy)
        y_ball <= y_ball - speed_y;
    else
        y_ball <= y_ball + speed_y; 
end

endmodule
module DynPong (
    input wire       dyn_clk,
    input wire       reset,
    input wire       play,
    input wire [9:0] pos_ply1,
    input wire [9:0] pos_ply2,
    output reg       reset_goals,
    output reg       goal_ply1,
    output reg       goal_ply2,
    output reg [9:0] x_ball = 10'd100,
    output reg [9:0] y_ball = 10'd100,
    output reg       mute = 1'b1,
    output reg [1:0] sound = 2'd0
);



localparam width_screen = 640;
localparam height_screen = 480;
localparam size_ball = 10;
localparam size_player = 80;
localparam offset_players = 20;
localparam width_players = 10;


reg [7:0] mseg = 0;


reg [2:0] speed_x = 2;
reg [2:0] speed_y = 2;

reg dx = 1'b0;
reg dy = 1'b0;


always @(posedge dyn_clk)
begin

    if (reset)
    begin
        x_ball <= width_screen/2;
        y_ball <= height_screen/2;
        dx <= ~dx;
        dy <= 1'b0;
    end


    if (x_ball == 0)
        begin
        goal_ply2 <= 1'b1;
        sound <= 3; 
        mseg <= 40;
        end
    else
        goal_ply2 <= 1'b0;

    if (x_ball == width_screen-size_ball)
        begin
        goal_ply1 <= 1'b1;
        sound <= 3;
        mseg <= 40;
        end
    else
        goal_ply1 <= 1'b0;


    if  (

        ((x_ball < offset_players + width_players) &&
        (y_ball > pos_ply1) && 
        (y_ball < pos_ply1 + size_player) &&
        (dx == 1'b1)) 
        ||

        ((x_ball > width_screen - offset_players - width_players - size_ball) &&
        (y_ball > pos_ply2) && 
        (y_ball < pos_ply2 + size_player) &&
        (dx == 1'b0))
        ||

        (x_ball == width_screen-size_ball)
        ||

        (x_ball == 0)
        )
        begin
        dx = ~dx;

        if (!((x_ball == width_screen-size_ball) || (x_ball == 0)))
            begin
            sound <= 2;
            mseg <= 30;
            end
        end


    if ((y_ball == 0) || (y_ball == height_screen-size_ball))
        begin
        dy = ~dy;
        sound <= 1;
        mseg <= 10;
        end


    if (mseg == 0)
        begin
        mute <= 1'b1;
        end
    else
        begin
        mseg <= mseg - 1;
        mute <= 1'b0;
        end


    if (dx)
        x_ball <= x_ball - speed_x;
    else
        x_ball <= x_ball + speed_x; 


    if (dy)
        y_ball <= y_ball - speed_y;
    else
        y_ball <= y_ball + speed_y; 
end

endmodule