always@(posedge clkout0 or negedge nReset)
begin
if(!nReset)begin
flash_rdy<= 1'b1;
flash_counter <= 5'b0;
flash_state<= FLASH_T1;
end
elsebegin
case(flash_state)
FLASH_T1:begin
if((!flash_cs)||(!flash_erase_cs)) begin
flash_rdy<= 1'b0;
flash_state<= FLASH_T2;
end
else
flash_state<= FLASH_T1;
end