module jyh_4490_mstate(clk,in,en,out,cnt);
input clk,in,en;
output reg out;
output reg [19:0] cnt=0;
reg[1:0] state=0;
parameter s0=0,s1=1,s2=2,s3=3;
parameter TARGET=750000; //50mhz 15ms
always @(posedge clk)
if(!en)
state=s0;
else
case(state)
s0:
begin
out=0;
cnt=0;
if(in)
state=s1;
end
s1:
if(cnt<TARGET)
cnt=cnt+1;
state=s2;
s2:
out=1;
if(!in)
state=s3;
s3:
default:
endcase
endmodule