else if(left)
begin
case(pos)
3'b000 : pos=3'b100;
3'b001 : pos=3'b011;
default :
begin
if(an==2'b11 )
an <= an;
else
an <= an + 1'b1;
if(pos==3'b101 && an==2'b11)
pos = 3'b100;
else if(pos==3'b010 && an==2'b11)
pos = 3'b011;
end
endcase
end
else if(right)
begin
case(pos)
3'b100 : pos=3'b000;
3'b011 : pos=3'b001;
default :
begin
if(an==2'b00)
an <= an;
else
an <= an - 1'b1;
if(pos==3'b101 && an==2'b00)
pos = 3'b000;
else if(pos==3'b010 && an==2'b00)
pos = 3'b001;
end
endcase
end
end
endmodule
-----------------------------------------------------------------------------------------------
module BCD(
input logic [2:0] Data, //input data
output logic [6:0] BCD //output data for display
);