always@(posedge clk)
begin
if(o1&&in1)
begin
{o1,o2,o3,o4,o5,o6,o7,o8} <=8'b01000000;
rdir <=1;
ldir <=0;
end
if(reset==1)
begin
{score1h,score1l} <=8'b00000000;
{score2h,score2l} <=8'b00000000;
count=0;
end
else if(o8&&in2)
begin
{o1,o2,o3,o4,o5,o6,o7,o8} <=8'b00000010;
rdir <=0;
ldir <=1;
end
else if(o9||o0)
//
begin
rdir <=0;
ldir <=0;
if(count <4)
count=count+1;
else if(count==4)
begin
count=0;
temp=right2;
right2=right1;
right1=temp;
end
if(right1)
{o0,o1,o2,o3,o4,o5,o6,o7,o8,o9} <=10'b0100000000;
else
{o0,o1,o2,o3,o4,o5,o6,o7,o8,o9} <=10'b0000000010;
if(o9)
begin
if(score1l[0]&&score1l[3])
begin score1l <=4'b0000;score1h <=4'b0001;end
else if(score1h[0]&&score1l[0])
begin{score1h,score1l} <=8'b00000000;
{score2h,score2l} <=8'b00000000;
count=0;
end
else score1l <=score1l+1;
end
else if(o0)
begin if(score2l[0]&&score2l[3])
begin score2l <=4'b0000;score2h <=4'b0001;end
else if(score2h[0]&&score2l[0])
begin{score1h,score1l} <=8'b00000000;
{score2h,score2l} <=8'b00000000;
count=0;
end
else score2l <=score2l+1;
end
end
//
else if(rdir&&!o1)
{o0,o1,o2,o3,o4,o5,o6,o7,o8,o9} <={o0,o1,o2,o3,o4,o5,o6,o7,o8,o9}> > 1;
else if(ldir&&!o8)
{o0,o1,o2,o3,o4,o5,o6,o7,o8,o9} <={o0,o1,o2,o3,o4,o5,o6,o7,o8,o9} < <1;
if({o0,o1,o2,o3,o4,o5,o6,o7,o8,o9}==10'b0000000000);
begin
right1=1;
{o0,o1,o2,o3,o4,o5,o6,o7,o8,o9} <=10'b0100000000;
end
end
endmodule