1、 题目:秒表设计 内容内容 一:设计任务与要求一:设计任务与要求 秒表的逻辑结构比较简单,它主要由、显示译码器、分频器、十进制计 数器、报警器和六进制计数器组成。在整个秒表中最关键是如何获得一个精确的 100Hz 计时脉冲,除此之外,整个秒表还需要一个启动信号和一个归零信号,以 便能够随时启动及停止。 秒表有六个输出显示,分别为百分之一秒,十分之一秒、秒、十秒、分、十分, 所以共有 6 个计数器与之对应,6 个个计数器全为 BCD 码输出,这样便于同时显 示译码器的连接。当计时达 60 分钟后,蜂鸣器鸣响 3 声。 二:设计原理二:设计原理 本系统采用自上向下的设计方案,系统的整体设计组装原理
2、图如图 2-1 所 示,它主要由控制模块,时基分屏模块,计时模块和显示模块四部分组成。各模 块分别完成控制,分屏,计时和显示的功能 设计原理图 三、三、程序模块程序模块 1、控制模块程序 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity ctrl is port(clr,clk,sp:in std_logic; en:out std_logic); end ctrl; architecture behave of ctrl is type states is (s0,s1,s2,
3、s3); signal current_state,next_state:states; begin com:process(sp,current_state) begin case current_state is when s0=en=0;if sp=1 then next_state=s1;else next_stateen=1;if sp=1 then next_state=s1;else next_stateen=1;if sp=1 then next_state=s3;else next_stateen=0;if sp=1 then next_state=s3;else next_
4、state=s0;end if; end case; end process; synch:process(clk) begin if clr=1 then current_state=s0; elsif clkevent and clk=1 then current_state=next_state; end if; end process; end behave; 2、时基分频模块程序 library ieee; use ieee.std_logic_1164.all; entity cb10 is port(clk: in std_logic; co: buffer std_logic)
5、; end cb10; architecture art of cb10 is signal counter:integer range 0 to 49999; begin process(clk) begin if (clk=1 and clkevent) then if counter=49999 then counter=0; co= not co; else counter=counter+1; end if; end if; end process; end art; 3、计时模块的程序 1) 、十进制计数器 library ieee; use ieee.std_logic_1164
6、.all; use ieee.std_logic_unsigned.all; entity cdu10 is port(clk,clr,en: in std_logic; cn: out std_logic; count10: out std_logic_vector(3 downto 0); end cdu10; architecture art of cdu10 is signal temp:std_logic_vector(3 downto 0); begin process(clk,clr) begin if clr=1 then temp=“0000“; cn=“1001“ then temp=“0000“; cn=1; else temp=temp+1; cn=0; end if; end if; end if; count10=temp; end process; end art; 2) 、六进制计数器 library ieee; use iee