module referee(rst,clk ,ball_posx ,b_rst,seven_1,seven_2,seven_3,p1_point,p2_point);
input rst,clk;
input [10:0]ball_posx;
output b_rst;
output [6:0]seven_1,seven_2,seven_3;//seven segment
output [3:0]p1_point,p2_point;
reg b_rst;
reg [3:0]p1_point,p2_point;
seven_segment scorer_1 (.clk(clk),.rst(rst),.point(p1_point),.out(seven_1));//"p1"
seven_segment scorer_2 (.clk(clk),.rst(1'd0),.point(4'd0),.out(seven_2));//"-"
seven_segment scorer_3 (.clk(clk),.rst(rst),.point(p2_point),.out(seven_3));//"p2"
always@(posedge clk,negedge rst)
begin
    if(!rst)
    begin
        b_rst=1'd0;
        p1_point=4'd0;
        p2_point=4'd0;
    end
    else
    begin
        //player 2 got point
        if(ball_posx==0)
        begin
            b_rst=1'd0;
            p2_point=p2_point+1;
        end
        else
        begin
            //player 1 got point
            if(ball_posx+`Ball_size==1024)
            begin
                b_rst=1'd0;
                p1_point=p1_point+1;
            end
            else
                b_rst=1'd1;
        end
    end
end
endmodule