always@(in1 or in2 or in3 or currentstate)
begin
nextstate=s0;// start state
case(currentstate)
s0: if(in1&&!set)
nextstate=s1;
else if(set) nextstate=s2;
s1:if(in2&&set)
nextstate=s3;
else if(!set) nextstate=s2;
s2:if(set) nexstate=s3;
s3:if(in3) nextstate=s0;
default:nextstate=s0;
endcase
end