找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

帖子
查看: 5822|回復(fù): 1
打印 上一主題 下一主題
收起左側(cè)

24進(jìn)制計(jì)數(shù)器數(shù)碼管顯示用VHDl編寫

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
——24進(jìn)制計(jì)數(shù)器(數(shù)碼管顯示)用VHDl編寫
——樓主用實(shí)驗(yàn)板驗(yàn)證過滿足計(jì)數(shù)0~23
頂層文件 led_24
library  ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity led_24 is
        port(clk,clr,ena:in std_logic;
      cq10_out,cq2_out:out std_logic_vector(3 downto 0)
      );
    end led_24;

architecture behav of led_24 is
        component led24
                port(clk,clr,ena:in std_logic;
                cnt10,cnt2:out std_logic_vector(3 downto 0));
        end component;

        component decoder_10
                port(cq10_1:IN STD_LOGIC_VECTOR (3 DOWNTO 0);
                        cq10_out:OUT STD_LOGIC_VECTOR (6 DOWNTO 0));
        end component;

        component decoder_2
                PORT (cq2_1:IN STD_LOGIC_VECTOR (3 DOWNTO 0);
                        cq2_out:OUT STD_LOGIC_VECTOR (6 DOWNTO 0));
        end component;

signal net1, net2 :std_logic_vector(3 downto 0);
        begin
                u1 : led24 port map(clk=>clk,clr=>clr,ena=>ena,cnt10=>net1,cnt2=>net2);
                u2 : decoder_10 port map(cq10_1=>net1,cq10_out=>cq10_out);
                u3 : decoder_2 port map(cq2_1=>net2,cq2_out=>cq2_out);

END architecture behav;

——例化元器件 U1
——24進(jìn)制計(jì)數(shù)器
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity led24 is
port(clk,clr,ena:in std_logic;
      cnt10,cnt2:out std_logic_vector(3 downto 0)
      );

end led24 ;
architecture behav of led24 is

begin

       process(clk,clr,ena)
        variable cq2:std_logic_vector(3 downto 0);
   variable cq10:std_logic_vector(3 downto 0);         
                 begin
            if clr='1' then
                       cq2:="0000";
                       cq10:="0000";
            elsif clk'event and clk='0' then
                  if ena='1' then
                     if cq10="1001" then
                            cq10:="0000";  
                            cq2:=cq2+'1';        
                     else cq10:=cq10+'1';
                     end if;
                     if cq2="0010" and cq10="0100" then
                           cq2:="0000";cq10:="0000";
                     end if;
                  end if;
             end if;
              cnt2<=cq2;
              cnt10<=cq10;
      end process ;
end architecture behav;

        ——例化元器件u2
——個(gè)位數(shù)譯碼電路
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;

ENTITY decoder_10 IS
        PORT (cq10_1:IN STD_LOGIC_VECTOR (3 DOWNTO 0);
                        cq10_out:OUT STD_LOGIC_VECTOR (6 DOWNTO 0));
END;

ARCHITECTURE ONE OF decoder_10 IS
BEGIN
        PROCESS (cq10_1) BEGIN
        CASE cq10_1 IS
        WHEN "0000" => cq10_out<= "1000000";
        WHEN "0001" => cq10_out<= "1111001";
        WHEN "0010" => cq10_out<= "0100100";
        WHEN "0011" => cq10_out<= "0110000";
        WHEN "0100" => cq10_out<= "0011001";
        WHEN "0101" => cq10_out<= "0010010";
        WHEN "0110" => cq10_out<= "0000010";
        WHEN "0111" => cq10_out<= "1111000";
        WHEN "1000" => cq10_out<= "0000000";
        WHEN "1001" => cq10_out<= "0010000";
        WHEN OTHERS => cq10_out<= "1111111";
        END CASE;
        END PROCESS;
        END architecture ONE;

——        例化元器件u3
十位數(shù)譯碼電路

        LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;

ENTITY decoder_2 IS
        PORT (cq2_1:IN STD_LOGIC_VECTOR (3 DOWNTO 0);
                        cq2_out:OUT STD_LOGIC_VECTOR (6 DOWNTO 0));
END;

ARCHITECTURE two OF decoder_2 IS
BEGIN
        PROCESS (cq2_1) BEGIN
        CASE cq2_1 IS
        WHEN "0000" => cq2_out<= "1000000";
        WHEN "0001" => cq2_out<= "1111001";
        WHEN "0010" => cq2_out<= "0100100";
        WHEN OTHERS => cq2_out<= "1111111";
        END CASE;
        END PROCESS;
        END architecture two;
波形見附件

      


        RTL圖

        
      file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml\wps7658.tmp.jpg
計(jì)數(shù)器波形

譯碼之后波形
file:///C:\Users\ADMINI~1\AppData\Local\Temp\ksohtml\wps7669.tmp.jpg

——這里有完整的工程

24進(jìn)制計(jì)數(shù)器數(shù)碼管顯示用VHDl編寫.zip

53.13 KB, 下載次數(shù): 27, 下載積分: 黑幣 -5

24進(jìn)制計(jì)數(shù)器

評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩

相關(guān)帖子

回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:225731 發(fā)表于 2017-11-24 10:02 | 只看該作者
能不能上傳文件源碼,具體的.VHD文件
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表