1、二数字钟各具体模块2.1 分频器(fengp)模块本系统共需 3 种频率时钟信号(10MHz、1Hz、1KHz)。为减少输入引脚,本系统采用分频模块,只需由外部提供 10MHz 基准时钟信号, 其余两种频率时钟信号由分频模块得到。分频器管脚分频器代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity fengp is port(clk0:in std_logic;clk_1Hz,clk_1kHz:out std_logic);end entity;architecture one of
2、 fengp issignal q1Hz:integer range 0 to 9999999 ; signal q1kHz:integer range 0 to 9999 ; beginprocess(clk0) beginif clk0event and clk0=1thenif q1Hz5000000-1 then clk_1Hz=0;q1Hz=q1Hz+1; elsif q1Hz=10000000-1 then q1Hz=0;elseclk_1Hz end if;if q1kHz5000-1 then clk_1kHzq1kHz=q1kHz+1; elsif q1kHz=10000-1
3、 then q1kHzelseclk_1kHzend if;end process; end;2.2 60(count60)进制计数校时模块本模块要实现的功能是:正常计时、校时、校分在每个状态下都会产生不同控制信号实现相应的功能。60 进制计数器管脚图60 进制计数器代码: library ieee;entity count60 is port(clk,set:CLR:in std_logic: co:out std_logic;h,l:buffer std_logic_vector(3 downto 0); end entity;architecture one of count60 is
4、signal co1,set1 : std_logic;set1 = set ;co = (set1 or co1); process(clk,CLR) beginif CLR=then h=0000lelseif clkevent and clk=-if start= then- h=d(7 downto 4);- l=d(3 downto 0);if(h=0101 and l=1001)then co1hif l then l=l+1;if h then h=h+1;co1 end process;2.3 24(count24)进制计数器模块24 进制计数器管脚图24 进制计数器时代码:e
5、ntity count24 is port(clk:- d: in std_logic_vector(7 downto 0)- co:architecture one of count24 is beginprocess(clk,CLR) beginelsif clk- if start=-h-lbt null; end case;end process P1;p2:process(clk) beginif(clk)then cnt sg = 1000000sg end process P3;2.4 数字钟顶层设计模块数字钟顶层设计模块管脚图数字钟顶层设计模块代码:entity dclock is port(clk,s1,s0,k0:sg7: bt8:architecture one of dclock is component fengpport(clk0: clk_1Hz,clk_1kHz:end component; component count60port(clk,set:- d:co: end component;component count24 port(clk:in std_log
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1