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