電子時鐘VHDL程序與仿真_第1頁
電子時鐘VHDL程序與仿真_第2頁
電子時鐘VHDL程序與仿真_第3頁
電子時鐘VHDL程序與仿真_第4頁
電子時鐘VHDL程序與仿真_第5頁
已閱讀5頁,還剩2頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

1、8.20電子時鐘VHDL程序與仿真1. 10進制計數(shù)器設(shè)計與仿真10進制計數(shù)器VHDL程序-文件名:counter10.vhd。-功能:10進制計數(shù)器,有進位C-最后修改日期:2004.3.20library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity counter10 isPort ( clk : in std_logic;reset : in std_logic;din : in std_logic_vector(3 downto

2、0);dout : out std_logic_vector(3 downto 0);c:out std_logic);end counter10;architecture Behavioral of counter10 issignal count : std_logic_vector(3 downto 0);begindout = count;process(clk,reset,din)beginif reset=0thencount = din ;c=0;elsif rising_edge(clk) thenif count = 1001 thencount = 0000;c=1;els

3、ecount = count+1;c=0;end if;end if;end process;end Behavioral;10進制計數(shù)器仿真2. 6進制計數(shù)器設(shè)計與仿真(1) 6進制計數(shù)器VHDL程序-文件名:counter6.vhd。-功能:6進制計數(shù)器,有進位C-最后修改日期:2004.3.20library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity counter6 isPort ( clk : in std_logic;res

4、et : in std_logic;din : in std_logic_vector(2 downto 0);dout : out std_logic_vector(2 downto 0);c:out std_logic);end counter6;architecture Behavioral of counter6 issignal count : std_logic_vector(2 downto 0);begindout = count;process(clk,reset,din)beginif reset= 0 thencount = din;c=0;elsif rising_ed

5、ge(clk) thenif count=101 thencount=000;c=1;elsecount=count+1;c=0;end if;end if;end process;end Behavioral;(2) 6進制計數(shù)器仿真6進制計數(shù)器設(shè)計與仿真(1) 24進制計數(shù)器VHDL程序 -文件名:counter24.vhd。-功能:24進制計數(shù)器。-最后修改日期:2004.3.20library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;ent

6、ity counter24 isPort ( clk : in std_logic;reset : in std_logic;din : in std_logic_vector(5 downto 0);dout : out std_logic_vector(5 downto 0);end counter24;architecture Behavioral of counter24 issignal count : std_logic_vector(5 downto 0);begindout = count;process(clk,reset,din)beginif reset= 0 thenc

7、ount = din;elsif rising_edge(clk) thenif count(3 downto 0)=1001” thencount(3 downto 0)=0000”;count(5 downto 4)=count(5 downto 4) +1; elsecount(3 downto 0)=count(3 downto 0)+1;end if;if count=100011” thencount dout dout dout dout dout dout dout dout dout dout dout=1111111”;end case;end process;end Be

8、havioral;頂層設(shè)計與仿真(1)頂層設(shè)計VHDL程序-文件名:clock.vhdo-功能:時鐘的頂層設(shè)計。-最后修改日期:2004.3.20library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity clock isPort ( clk : in std_logic;-1Hzreset : in std_logic;-復(fù)位信號dins : in std_logic_vector(6 downto 0);-秒 鐘預(yù)置 dinm : i

9、n std_logic_vector(6 downto 0);-分鐘預(yù)置 dinh : in std_logic_vector(5 downto 0);-時鐘預(yù)置 secondl: out std_logic_vector(6 downto 0);-秒鐘低位輸出 secondh: out std_logic_vector(6 downto 0); -秒鐘高位輸出 minutel: out std_logic_vector(6 downto 0);-分鐘低位輸出 minuteh: out std_logic_vector(6 downto 0);-分鐘高位輸出 hourl: out std_lo

10、gic_vector(6 downto 0);-小時低位輸出 hourh: out std_logic_vector(6 downto 0);-小時高位輸出 end clock;architecture Behavioral of clock iscomponent counter10 isPort ( clk : in std_logic;reset : in std_logic;din : in std_logic_vector(3 downto 0); dout : out std_logic_vector(3 downto 0); c:out std_logic);end compon

11、ent;component counter6 isPort ( clk : in std_logic;reset : in std_logic;din : in std_logic_vector(2 downto 0);dout : out std_logic_vector(2 downto 0);c:out std_logic);end component;component counter24 isPort ( clk : in std_logic;reset : in std_logic;din : in std_logic_vector(5 downto 0);dout : out s

12、td_logic_vector(5 downto 0);end component;component decoder isPort (din:in std_logic_vector(3 downto 0 );dout:out std_logic_vector(6 downto 0);end component;signal c1,c2,c3,c4:std_logic;signal doutsl,doutml:std_logic_vector(3 downto 0);signal doutsh,doutmh:std_logic_vector(2 downto 0);signal douth:s

13、td_logic_vector(5 downto 0);signal rdoutsh,rdoutmh:std_logic_vector(3 downto 0);signal rdouth:std_logic_vector(7 downto 0);beginrdoutsh = 0&doutsh;-將秒鐘高位數(shù)據(jù)變?yōu)?位,再進行譯碼 rdoutmh = 0&doutmh;-將分鐘高位數(shù)據(jù)變?yōu)?位,再進行譯碼 rdouth clk,reset=reset,din=dins(3 downto 0), dout=doutsl, c=c1);u2: counter6 port map( clk=c1,re

14、set=reset,din=dins(6 downto 4),dout=doutsh,c=c2);u3: counter10 port map( clk=c2,reset=reset,din=dinm(3 downto 0), dout=doutml, c=c3);u4: counter6 port map( clk=c3,reset=reset,din=dinm(6 downto 4), dout=doutmh, c=c4);u5: counter24 port map( clk=c4,reset=reset, din=dinh,dout=douth);u6: decoder port ma

15、p( din = doutsl,dout = secondl);-秒的低位u7: decoder port map( din = rdoutsh,dout = secondh);-秒的高位u8: decoder port map( din = doutml,dout = minutel);-分的低位u9: decoder port map( din = rdoutmh,dout = minuteh);-分的高位u10: decoder port map( din = rdouth(3 downto 0),dout = hourh);-時的低位 u11: decoder port map( din = rdouth(7 downto 4),dout = hourl);-時的高位 end Behavioral;(2)頂層設(shè)計仿真vave def aultFile E di t v_i ew Irisert Format Tools n_irLiiuw宣,宴i *1J/testbench/clk/testbench/reset.testbench/dins/testbench/dirirri/testbench/dinh/testbench/secondl/testbench/secondh/testbench/minutel/

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論