电子时钟VHDL程序与仿真_第1页
电子时钟VHDL程序与仿真_第2页
电子时钟VHDL程序与仿真_第3页
电子时钟VHDL程序与仿真_第4页
电子时钟VHDL程序与仿真_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、8.20电子时钟VHDL程序与仿真1. 10进制计数器设计与仿真10进制计数器VHDL程序-文件名:counter10.vhd。-功能:10进制计数器,有进位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进制计数器仿真2. 6进制计数器设计与仿真(1) 6进制计数器VHDL程序-文件名:counter6.vhd。-功能:6进制计数器,有进位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进制计数器仿真6进制计数器设计与仿真(1) 24进制计数器VHDL程序 -文件名:counter24.vhd。-功能:24进制计数器。-最后修改日期: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;顶层设计与仿真(1)顶层设计VHDL程序-文件名:clock.vhdo-功能:时钟的顶层设计。-最后修改日期: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;-复位信号dins : in std_logic_vector(6 downto 0);-秒 钟预置 dinm : i

9、n std_logic_vector(6 downto 0);-分钟预置 dinh : in std_logic_vector(5 downto 0);-时钟预置 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;-将秒钟高位数据变为4位,再进行译码 rdoutmh = 0&doutmh;-将分钟高位数据变为4位,再进行译码 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)顶层设计仿真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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论