if clk'event and clk='1' then case currentSta is --平时状态, 00 when st0 => sta<="0000"; t1En<='0'; t2En<='0'; if(t4Out>=49825) then currentSta<=st7; else if (sig='1') then currentSta<=st0; else currentSta<=st1; end if; end if;
--检测低电平宽度, 01 when st1 => sta<="0001"; t1En<='1'; t2En<='0'; if(t4Out>=49825) then --17.5us currentSta<=st7; else if sig='1' then --低电平结束,检查计数值 if t1Out<500 and t1Out>300 then --检测到合适的低脉冲 currentSta<=st2; else currentSta<=st5; ---退回空闲状态 end if; else--if sig='0' then currentSta<=st1; --还是低电平, 继续 end if; end if; --检测高电平宽度, 11 |