|
TYPE state IS (s0,s1,s2,s3); --正交编码器的状态
SIGNAL status1,status2,status3:state; --状态变量
case status1 is
when s0 =>if((inaclear='1')and (inbclear='0')) then
status1<=s1;
--direct1<='0';
--inpout1last<=inpout1;
inpout0<='1';
ct6<=0;
elsif((inaclear='0')and (inbclear='1')) then
status1<=s3;
--direct1<='1';
--inpout1last<=inpout1;
inpout1<='1';
ct6<=0;
else if(int2mask(5)='0' and not((inaclear='0')and (inbclear='0'))) then
codebit<='1';
vecint2(5)<='1';
end if;
end if;
when s1 =>if((inaclear='1')and (inbclear='1')) then
status1<=s2;
--direct1<='0';
--inpout1last<=inpout1;
inpout0<='1';
ct6<=0;
elsif((inaclear='0') and (inbclear='0')) then
status1<=s0;
--direct1<='1';
--inpout1last<=inpout1;
inpout1<='1';
ct6<=0;
else if(int2mask(5)='0' and not((inaclear='1')and (inbclear='0'))) then
codebit<='1';
vecint2(5)<='1';
end if;
end if;
when s2 =>if((inaclear='0')and (inbclear='1')) then
status1<=s3;
--direct1<='0';
--inpout1last<=inpout1;
inpout0<='1';
ct6<=0;
elsif((inaclear='1') and (inbclear='0')) then
status1<=s1;
--direct1<='1';
--inpout1last<=inpout1;
inpout1<='1';
ct6<=0;
else if(int2mask(5)='0' and not((inaclear='1')and (inbclear='1'))) then
codebit<='1';
vecint2(5)<='1';
end if;
end if;
when s3 =>if((inaclear='0')and (inbclear='0')) then
status1<=s0;
--direct1<='0';
--inpout1last<=inpout1;
inpout0<='1';
ct6<=0;
elsif((inaclear='1') and (inbclear='1')) then
status1<=s2;
--direct1<='1';
--inpout1last<=inpout1;
inpout1<='1';
ct6<=0;
else if(int2mask(5)='0' and not((inaclear='0')and (inbclear='1'))) then
codebit<='1';
vecint2(5)<='1';
end if;
end if;
when OTHERS =>null;
end case;