柳德伟的个人世界 https://bbs.21ic.com/?2461 [收藏] [复制] [RSS] “四十不惑”,说的是人生的道理已经参悟得差不多了,明白自己能干啥不能干啥,能够准确的定位自己,干自己喜欢干的事! ...

日志

正交编码的VHDL实现

已有 794 次阅读2008-2-3 06:48 |系统分类:EDA/PLD

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;


路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)