基于VHDL的秒表.doc
文本预览下载声明
数字电子技术课程设计
秒表
院系:计算机学院
班级:计112—3班
姓名:
学号:
指导教师:王玲玲
内容
总体设计要求
具有启动停止功能;
计时器能显示0.01s的时间;
计时器最长计时时间为24h;
具有复位功能?在任何情况下?按复位键?秒表无条件清零
各功能模块设计说明及源程序
100进制计数器
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt_99 is
port(clk,en,cir:in std_logic;
q0,q1:buffer std_logic_vector(3 downto 0);
co:buffer std_logic);
end cnt_99;
architecture rtl of cnt_99 is
signal s1:std_logic_vector(3 downto 0);
signal s2:std_logic_vector(3 downto 0);
begin
process(clk)
begin
if(clkevent and clk=1)then
if(cir=0)then
s1=0000;s2=0000;co=1;
elsif(en=1)then
if(s1=1001 and s2=1001)then
s1=0000;s2=0000;co=1;
elsif(s2=1001)then
s2=0000;s1=s1+1;co=0;
else s2=s2+1;co=0;
end if;
end if;
end if;
q0=s1;q1=s2;
end process;
end rtl;
这是100进制的源程序:
设计中包含了清零功能,并且当en输入信号为1时,100进制计数器开始工作,当clk的信号为1时,100进制计数器开始计数,当cir为0时,100进制计数器无条件清零,当数码管上显示99时,数码管清零,并且产生进位信号co为1,当满足数码管上最低位显示为9时,高位在原来的基础上加1,而低位则是清零,并且进位信号为0;当上述的条件都不满足时,最低位在原来的基础上加1。
60进制计数器
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt_59 is
port(clk,en,cir:in std_logic;
q0,q1:buffer std_logic_vector(3 downto 0);
co:buffer std_logic);
end cnt_59;
architecture rtl of cnt_59 is
signal s1:std_logic_vector(3 downto 0);
signal s2:std_logic_vector(3 downto 0);
begin
process(clk)
begin
if(clkevent and clk=1)then
if(cir=0)then
s1=0000;s2=0000;co=1;
elsif(en=1)then
if(s1=0101 and s2=1001)then
s1=0000;s2=0000;co=1;
elsif(s2=1001)then
s2=0000;s1=s1+1;co=0;
else s2=s2+1;co=0;
end if;
end if;
end if;
q0=s1;q1=s2;
end process;
end rtl;
这是60进制计数器的源程序:
设计中包含了清零功能,并且当en输入信号为1时,100进制计数器开始工作,当clk的信号为1时,60进制计数器开始计数,当cir为0时,60进制计数器无条件清零,当数码管上显示59时,数码管清零,并且产生进位信号co为1,当满足数码管上最低位显示为9时,高位在原来的基础上加1,而低位则是清零,并且进位信号为0;当上述的条件都不满足时,最低位在原来的基础上加1。
23进制计数器
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt_23 is
port(clk,en,cir:in std_logic;
q0,q1:buffer std_logic_vector(3 downto 0);
co:buffer std_logic);
end cnt_23;
architecture rt
显示全部