久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

專注電子技術學習與研究
當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

FPGA頻率計帶注釋的VHDL程序

作者:佚名   來源:本站原創   點擊數:  更新時間:2013年11月08日   【字體:

  鎖定一段時間的及時程序:
      library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
entity ss is
  port(clk,cr_start:in std_logic;
              Co:out std_logic);
end;
architecture sec of ss is
signal t,c1,c2:std_logic;
signal qq:std_logic_vector(5 downto 0);
begin
  PROCESS(CLK,cr_start)
   BEGIN
    if cr_start'event and cr_start='1' then t<=not t;end if;
          C1<=CLK and t and c2; 
           IF C1'EVENT AND C1='1' THEN qq<=qq+1;
               IF qq=50 THEN qq<="000000";
               END IF;              
           END IF;
           if qq<45 then c2<='1';else c2<='0';end if;          
               IF qq>5 and qq<16 THEN Co<='1';
                  ELSE Co<='0';
               END IF;
     if cr_start='0' then qq<="000000";t<='0';end if;    
  END PROCESS;           
end;
下面是波形仿真:按一下開始鍵可以從新開始這段計時。


      

以下是在上面鎖定一段時間后編寫的頻率計程序:
library ieee;
Use ieee.std_logic_1164.all;
Use ieee.std_logic_unsigned.all;
entity plj is
  port(cp,cr_start,Dce:in std_logic;
            xs:out std_logic_vector(6 downto 0);
            w:out std_logic_vector(5 downto 0);
              Co:out std_logic);
end;
architecture sec of plj is
signal t,c1,c2,clk,sec,cc:std_logic;
signal qq:std_logic_vector(5 downto 0);
signal q:std_logic_vector(19 downto 0);
signal q0,q1,q2,q3,q4,q5,XSQ:std_logic_vector(3 downto 0);
signal tt:std_logic_vector(9 downto 0);
begin
  process(cp)
  begin
    if cp'event and cp='1' then q<=q+1;tt<=tt+1;
         if q<=999999 then q<="00000000000000000000";clk<='1';
           else clk<='0';
          end if;
         if tt=769 then tt<="0000000000";end if;
    end if;
  end process;
  PROCESS(CLK,cr_start,Dce)
   BEGIN
    if cr_start'event and cr_start='1' then t<=not t;end if;
          C1<=CLK and t and c2; 
           IF C1'EVENT AND C1='1' THEN qq<=qq+1;
               IF qq=50 THEN qq<="000000";
               END IF;              
           END IF;
           if qq<45 then c2<='1';else c2<='0';end if;          
               IF qq>5 and qq<26 THEN sec<='1';
                  ELSE sec<='0';
               END IF;
   
----------------------開始測試頻率----------------------------------
      cc<= Dce and sec ;
      if cc'event and cc='1' then q0<=q0+1;
          if q0=9 then q0<="0000";q1<=q1+1;end if;
          if q1=9 and q0=9 then q1<="0000";q2<=q2+1;end if;
          if q2=9 and q1=9 and q0=9 then q2<="0000";q3<=q3+1;end if;
          if q3=9 and q2=9 and q1=9 and q0=9 then q3<="0000";q4<=q4+1;end if;
          if q4=9 and q3=9 and q2=9 and q1=9 and q0=9 then q4<="0000";q5<=q5+1;end if;
          if q5>9 then  q0<="1111";q1<="1111";q2<="1111";q3<="1111";q4<="1111";q5<="1111";end if;
      end if;
      if tt<128 then XSQ<=q0;w<="111110";end if;
      if tt>=128 and tt<256 then XSQ<=q1;w<="111101";end if;
      if tt>=256 and tt<384 then XSQ<=q2;w<="111011";end if;
      if tt>=384 and tt<512 then XSQ<=q1;w<="111101";end if;
      if tt>=512 and tt<640 then XSQ<=q2;w<="111011";end if;
      if tt>=640 and tt<768 then XSQ<=q2;w<="111011";end if;
       if cr_start='0' then qq<="000000";t<='0';q0<="0000";q1<="0000";
         q2<="0000"; q3<="0000"; q4<="0000";  q5<="0000";
     end if;      
  END PROCESS;
----------------------開始顯示----------------------------------
    process(XSQ)
      begin
         case XSQ is
              when "0000"=>XS<="0000001";
              when "0001"=>XS<="1001111";
              when "0010"=>XS<="0010010";
              when "0011"=>XS<="0000110";
              when "0100"=>XS<="1001100";
              when "0101"=>XS<="0100100";
              when "0110"=>XS<="0100000";
              when "0111"=>XS<="0001111";
              when "1000"=>XS<="0000000";
              when "1001"=>XS<="0000100";
              when "1111"=>XS<="1111110";
              when others=>XS<="0000001";
          end case;
      end process;--顯示結束       
end;
==============下面是六位十進制計數器========
 if clk'event and clk='1' then bq0<=bq0+1;
      if bq0=9 then bq0<="0000";bq1<=bq1+1;end if;    
       if bq1=5 and bq0=9 then bq1<="0000";bq2<=bq2+1;end if;    
       if bq2=9 and bq1=5 and bq0=9 then bq2<="0000";bq3<=bq3+1; end if;   
       if bq3=5 and bq2=9 and bq1=5 and bq0=9 then bq3<="0000";bq4<=bq4+1;end if;    
       if bq4=9 and bq3=5 and bq2=9 and bq1=5 and bq0=9 then bq4<="0000";bq5<=bq5+1;end if;    
       if bq5=2 and bq4=3 and bq3=5 and bq2=9 and bq1=5 and bq0=9 then bq4<="0000";bq5<="0000"; end if;       
end if;
=====================================
   -----------將20M分頻成20Hz-----------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity fpq is
port( clk:in std_logic;
            cp:out std_logic);           
end;
architecture ss of fpq is
signal q:std_logic_vector(23 downto 0);
signal c:std_logic;
begin
process(clk)
   begin   
     if clk'event and clk='1' then q<=q+1;
         if q=499999 then c<=not c;end if;       
     end if;    
end process;
cp<=c;
end;
------------------產生1秒種的計數時間------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity sec_1s is
port( clk,start:in std_logic;
            sec:out std_logic);
           
end;
architecture ss of sec_1s is
signal q:std_logic_vector(5 downto 0);
signal c0,c1,c2:std_logic;
begin
process(clk,start)
   begin
     if start'event and start='1' then c0<=not c0;end if;
     c2<=clk and c0 and (not c1);
     if c2'event and c2='1' then q<=q+1;
         if q>51 then c1<='1';else c1<='0';end if;
         if q>20 and q<41 then sec<='1';else sec<='0';end if;
     end if;
     if start='0' then c0<='0';q<="000000";c1<='0';end if;
end process;
end;



-----------------測試待測頻率------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity plvcs is
port( sec1s,start,daice_f:in std_logic;
            q0,q1,q2,q3,q4,q5:out std_logic_vector(3 downto 0));         
end;
architecture ss of plvcs is
signal qq0,qq1,qq2,qq3,qq4,qq5:std_logic_vector(3 downto 0);
signal cp:std_logic;
begin
process(sec1s,start,daice_f)
   begin
     cp<=sec1s and daice_f;     
     if cp'event and cp='1' then qq0<=qq0+1;
         if qq0=9 then qq0<="0000";qq1<=qq1+1;end if;
         if qq0=9 and qq1=9 then qq1<="0000";qq2<=qq2+1;end if;
         if qq0=9 and qq1=9 and qq2=9 then qq2<="0000";qq3<=qq3+1;end if;
         if qq0=9 and qq1=9 and qq2=9 and qq3=9 then qq3<="0000";qq4<=qq4+1;end if;
         if qq0=9 and qq1=9 and qq2=9 and qq3=9 and qq4=9 then qq4<="0000";qq5<=qq5+1;end if;
         if  qq5>9 then qq4<="1111";qq5<="1111";qq3<="1111";qq2<="1111";qq1<="1111";qq0<="1111";end if;
     end if;
     if start='0' then qq4<="0000";qq5<="0000";qq3<="0000";qq2<="0000";qq1<="0000";qq0<="0000";end if;
end process;
q0<=qq0;q1<=qq1;q2<=qq2;q3<=qq3;q4<=qq4;q5<=qq5;
end;
-------------七段碼顯示測試結果-----------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity xs is
port(clk:in std_logic;
     q0,q1,q2,q3,q4,q5:in std_logic_vector(3 downto 0);
     xs:out std_logic_vector(6 downto 0);
     w:out std_logic_vector(5 downto 0));
end;
architecture ss of xs is
signal q:std_logic_vector(5 downto 0);
signal qq:std_logic_vector(3 downto 0);
begin
  process(q0,q1,q2,q3,q4,q5,clk)
    begin
     if clk'event and clk='1' then q<=q+1;
         if q=59 then q<="000000";end if;
     end if;
     if q<10 then qq<=q0;w<="111110";end if;
     if q>=10 and q<20 then qq<=q1;w<="111101";end if;
     if q>=20 and q<30 then qq<=q2;w<="111011";end if;
     if q>=30 and q<40 then qq<=q3;w<="110111";end if;
     if q>=40 and q<50 then qq<=q4;w<="101111";end if;
     if q>=50  then qq<=q5;w<="011111";end if;
     case qq is
        when "0000"=>xs<="0000001";
        when "0001"=>xs<="1001111";
        when "0010"=>xs<="0010010";
        when "0011"=>xs<="0000110";
        when "0100"=>xs<="1001100";
        when "0101"=>xs<="0100100";
        when "0110"=>xs<="0100000";
        when "0111"=>xs<="0001111";
        when "1000"=>xs<="0000000";
        when "1001"=>xs<="0000100";
        when "1111"=>xs<="1111110";
        when others=>xs<=null;
end case;
end process;
end;
---------------------------原理圖完成頻率計整體測試-----------------------------

關閉窗口

相關文章

主站蜘蛛池模板: 羞羞视频在线网站观看 | 中文字幕 视频一区 | a级毛片免费高清视频 | 亚洲国产一区视频 | 亚洲成人精品 | 亚洲精品99999 | 日韩精品视频中文字幕 | 成人视屏在线观看 | 久久精品视频在线观看 | 91一区 | 国产欧美日韩久久久 | 91在线看 | 欧美精品综合 | 久久亚洲国产精品日日av夜夜 | 五月婷婷丁香 | 91免费视频观看 | 国产精品精品视频 | 亚洲精品在线免费播放 | 九九视频在线观看视频6 | 欧美国产在线一区 | 久久人操| 日批av| 精品久久久久久 | 亚洲一区二区精品视频 | 午夜99| 在线视频一区二区 | 国产精品久久久免费 | 伊人伊成久久人综合网站 | 欧美精品第一区 | 日本一区二区视频 | 看片地址 | 国产日韩久久久久69影院 | 老司机深夜福利网站 | 国产高清精品一区二区三区 | 不卡av电影在线播放 | 色资源在线 | 欧美一级三级在线观看 | 69精品久久久久久 | 精品福利一区二区三区 | 精品欧美一区二区三区久久久 | 天天欧美 |