资源描述
电子线路CAD实验报告
—数字秒表设计
学 院 :理学院
专 业 :光信息科学与技术
班 级 :20081461
姓 名 :苏伟
学 号 :2008146136
指导教师 :吴正平
一、设计任务与要求
1、数字秒表的计时范围是00:00:00:00~23:59:59:99,显示的最长时间:23小时59分59秒99微秒。
2、数字秒表的计时精度是0.01s。
3、复位开关可以在任何情况下使用,即便在计时过程中,只要按一下复位开关,计时器就清零,并做好下次计时的准备。
4、具有启/停开关,即按一下启/停开关,启动计时器开始计时,再按一下启/停开关则停止计时。
二、总体框图
频率信号输入
微妙模块
秒模块
分模块
置数/位选
显示模块
进位
进位
由频率信号输出端输出频率为100HZ的时钟信号,输入到微妙模块的时钟端clk,微妙模块为100进制的计数器,产生的进位信号输入到下一级秒模块的时钟端,以此类推,直到分模块计数到59进60时,产生的进位信号不输出,计数清零。将微妙、秒、分产生的计数通过置数/位选再通过显示模块实时显示。
设计方案:
利用一块芯片完成除时钟源,按键和显示器之外的所有数字电路功能。所有数字逻辑功能都在CPLD器件上用VHDL语言实现。这样设计具有体积小,设计周期短,调试方便,故障率地和修改升级容易等特点,
本设计采用自顶向下,混合输入方式(原理图输入——顶层文件链接和VHDL语言输入——各模块程序设计)实现数字秒表的设计,下载和调试。
三、功能模块
1:分频器设计程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnte is
port( clk0:in std_logic;
clk1: buffer std_logic);
end cnte;
architecture one of Cnte is
signal cout: integer range 0 to 14999;
begin
process(clk0,clk1)
begin
if clk0'event and clk0='1' then
if(cout=14999) then
cout<=0;
clk1<='1';
else cout<=cout+1;
clk1<='0';
end if;
end if;
end process;
end one;
分
频
器
波
形
图
2:秒模块设计程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt100 is
port( clk1,stop,ret:in std_logic;
clk2: buffer std_logic;
dl,dh:buffer std_logic_vector (3 downto 0));
end cnt100;
architecture second of cnt100 is
begin
process(clk1,stop,ret)
begin
if(ret='1') then
dl<="0000";
dh<="0000";
elsif(stop='0') then
if clk1'event and clk1='1' then
if dl=9 then
dl<="0000";
if dh=9 then
dh<="0000";
clk2<='1';
else dh<=dh+1;
clk2<='0';
end if;
else dl<=dl+1;
end if;
end if;
end if;
end process;
end second;
秒
模
块
波
形
图
3:分模块设计程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt60 is
port( clk2,stop,ret:in std_logic;
clk3: buffer std_logic;
dl,dh:buffer std_logic_vector (3 downto 0));
end cnt60;
architecture minute of cnt60 is
begin
process(clk2,stop,ret)
begin
if(ret='1') then
dl<="0000";
dh<="0000";
elsif(stop='0') then
if clk2'event and clk2='1' then
if dl=9 then
dl<="0000";
if dh=5 then
dh<="0000";
clk3<='1';
else dh<=dh+1;
clk3<='0';
end if;
else dl<=dl+1;
end if;
end if;
end if;
end process;
end minute;
分
模
块
波
形
图
4:时钟模块设计程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity cnt24 is
port( clk3,stop,ret:in std_logic;
clk4: buffer std_logic;
dl,dh:buffer std_logic_vector (3 downto 0));
end cnt24;
architecture hour of cnt24 is
begin
process(clk3,stop,ret)
begin
if(ret='1') then
dl<="0000";
dh<="0000";
elsif(stop='0') then
if clk3'event and clk3='1' then
if dl=3 and dh=2 then
dl<="0000";
dh<="0000";
elsif dl=9 then
dl<="0000";
if dh=2 then
dh<="0000";
else dh<=dh+1;
end if;
else dl<=dl+1;
end if;
end if;
end if;
end process;
end hour;
时
模
块
波
形
图
四、总体设计电路图
1:连接图
2:仿真图
五 心得体会
经过本次课程设计,我发现以我现在的学习水平,独立自主的进行课程设计还为时尚早,目前最重要的就是积累自己的知识面,多进行些实验方面的设计,锻炼下动手能力,本次设计经过老师的帮助,基本上独立自主的完成了本次设计。
本次设计上仍有许多不足,还有待进一步的改进以便完善功能。
2011年5月3日
展开阅读全文