1、EDA数字秒表设计电子设计自动化大作业题目数字秒表设计学院控制科学与工程学院班级自动化0803姓名学号二OO一一年五月十二日题目:数字秒表的设计一、设计要求:(1)数字秒表的计时精度是10ms;(2)复位开关可以在任何情况下使用,计时在计时过程中,只要按一下复位开关,计时器就清零,并做好下次计时的准备;(3)具有启/停开关,即按一下启/停开关,启动计时器开始计时,再按一下启/停开关则停止计时。(4)数字秒表的计时范围是0秒59分59.99秒,显示的最长时间为59分59秒二、总体设计:1、总体结构图输入到CHOICE中2、各模块功能1) SEL模块:将扫描信号输给选择(CHOICE)模块2)选择
2、模块:按扫描信号的指定选择输出3)3-8译码模块:通过SEL给的信号来控制8位数码管位的亮灭4)计时模块:分别对毫秒,秒,分计时5)显示模块:通过CHOICE模块的输出信号来控制三、单元模块设计1、模块名:sel模块设计(1)模块功能:CLK为扫描时钟脉冲,SELOUT端不停的发出扫描到的信号(2)端口定义:CLK为信号输入端SELOUT2.0为选择到的信号输出(3)VHDL源程序libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityselis port(clk:instd_logic;selou
3、t:outstd_logic_vector(2downto0);endsel;architectureoneofselissignalcount:std_logic_vector(2downto0);beginprocess(clk)beginifclkeventandclk=1thenif(count=101)thencount=000;elsecount=count+1;endif;endif;endprocess;selout=count;endone;(4)仿真结果说明:来一个上升沿,SELOUT的值增1,可以证明模块是正确的。2、模块名:选择模块设计(1)模块功能:按扫描信号的指定选
4、择输出(2)端口定义:a,b,c为控制信号;data13.0,data23.0,data33.0,data43.0,data53.0,data63.0分别是毫秒的低位,毫秒的高位,秒的低位,秒的高位,分的低位,分的高位的数据值;ch_out3.0为选择输出端。(3)VHDL源程序libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitychoiceis port (a,b,c:instd_logic;data1,data2,data3,data4,data5,data6:instd_logic_vec
5、tor(3downto0); ch_out:outstd_logic_vector(3downto0) );endchoice;architecturebehaveofchoiceis signalch:std_logic_vector(2downto0); begin ch(2)=c; ch(1)=b; ch(0)ch_outch_outch_outch_outch_outch_outnull; endcase; endprocess;endbehave;(4)仿真结果说明:abc的值递增,ch_out选择输出data1,data2,data3,data4,data5,data6的值,证明模
6、块是正确的3、模块名:3-8译码模块设计(1)模块功能:通过SEL给的信号来控制8位数码管位的亮灭。(2)端口定义:输入端SEL2.0值大小来选择输出Q的值输出端Q7.0来控制灯哪位亮(3)VHDL源程序LIBRARYieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;ENTITYdecode3_8IS PORT(SEL:IN std_logic_vector(2downto0); Q :OUTstd_logic_vector(7downto0) );ENDdecode3_8;ARCHITECTUREaOFdecode3
7、_8ISBEGIN Q=whensel=0else whensel=1else whensel=2else whensel=3else whensel=4else whensel=5elseENDa;(4)仿真结果说明:Sel的值递增,Q的相应位会亮,证明模块是正确的。41模块名:毫秒计时模块设计(1)模块功能:对毫秒位的计数(2)端口定义:clk为信号时钟输入端 reset为复位端 pause为暂停端 co为进位信号输出端 qh:毫秒信号的高位输出端 ql:毫秒信号的低位输出端(3)VHDL源程序libraryieee;useieee.std_logic_1164.all;useieee.s
8、td_logic_unsigned.all;entitym100is port (clk:instd_logic; reset:instd_logic; pause:instd_logic; co:outstd_logic; qh:bufferstd_logic_vector(3downto0); ql:bufferstd_logic_vector(3downto0) );endm100;architecturebehaveofm100is begin co=1when(qh=1001andql=1001)else0; process(clk,reset,pause) begin if(res
9、et=0)then qh=0000; ql=0000; elsif(pause=0)then qh=qh; ql=ql; elsif(clkeventandclk=1)then if(ql=1001)then ql=0000; if(qh=1001)then qh=0000; elseqh=qh+1; endif; elseql=ql+1; endif; endif; endprocess;endbehave;(4)仿真结果说明:毫秒为100进制,高位和地位都是10进制,高位到10会有进位,可以证明模块的正确性4.2模块名:秒计时模块设计(1)模块功能:对毫秒位的计数(2)端口定义:clk为信
10、号时钟输入端 reset为复位端 pause为暂停端 co为进位信号输出端 qh:毫秒信号的高位输出端 ql:毫秒信号的低位输出端(3)VHDL源程序libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitym60_secis port (reset:instd_logic; pause:instd_logic; ci:instd_logic; co:outstd_logic; qh:bufferstd_logic_vector(3downto0); ql:bufferstd_logic_vector
11、(3downto0) );endm60_sec;architecturebehaveofm60_secis begin co=1when(qh=0101andql=1001andci=1)else0; process(reset,pause,ci) begin if(reset=0)then qh=0000; ql=0000; elsif(pause=0)then qh=qh; ql=ql; elsif(cieventandci=1)then if(ql=1001)then ql=0000; if(qh=0101)then qh=0000; elseqh=qh+1; endif; elseql
12、=ql+1; endif; endif; endprocess;endbehave;(4)仿真结果说明:秒进制为60进制,高位到6会有进位,低位为10进制,可以证明模块的正确性4.3模块名:分计时模块设计(1)模块功能:对毫秒位的计数(2)端口定义:clk为信号时钟输入端 reset为复位端 pause为暂停端 co为进位信号输出端 qh:毫秒信号的高位输出端 ql:毫秒信号的低位输出端(3)VHDL源程序libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitym60_minis port (res
13、et:instd_logic; pause:instd_logic; ci:instd_logic; qh:bufferstd_logic_vector(3downto0); ql:bufferstd_logic_vector(3downto0) );endm60_min;architecturebehaveofm60_minis begin process(reset,pause,ci) begin if(reset=0)then qh=0000; ql=0000; elsif(pause=0)then qh=qh; ql=ql; elsif(cieventandci=1)then if(q
14、l=1001)then ql=0000; if(qh=0101)then qh=0000; elseqh=qh+1; endif; elseqlq_showq_showq_showq_showq_showq_showq_showq_showq_showq_shownull; endcase; endprocess;endbehave;(4)仿真结果说明:随着adr的值增加,q_show输出相应的值,数码管相应的段会亮,证明模块是正确的四、数字秒表整体组装1、顶层原理图1.工作情况输入信号经过分频器输给计时模块,计时模块的各位输给选择(CHOICE)模块,选择模块选择输出,再经过转码(BCD_7
15、)模块控制数码管段的亮灭;输入信号的另一路经过分频器给扫描(SEL)模块,SEL的输出信号一方面给CHOICE模块提供提供选择信号,另一方面又给译码器(decode3_8)模块提供译码信号来控制灯位的亮灭。,pause和reset分别控制暂停和复位。2.模块间的连接关系:扫描(SEL)模块的输出端接译码(decode3_8)模块和选择(CHOICE)模块,计时模块接选择(CHOICE)模块,选择(CHOICE)模块将选到的信号给转码(BCD_7)模块控制数码管段的亮灭2、仿真结果说明:输入信号后,数码管会不停的被扫描,段和位会选择亮,可以证明模块的正确性管脚分配:管脚编号管脚定义管脚编号管脚定义153Clk50MHZ104duan14Pause101duan2127reset100duan386Wei785duan487Wei684duan588Wei583duan693Wei482dp94Wei395Wei298Wei199Wei0duan0hout3clk分频器端的输入频率f=50MHZpause计时模块的暂停输入端reset计时模块的复位输入端duan0.6数码管段的控制端wei7.0数码管位的控制端dp数码管的“.“接地箱子接上电源,下载即可运行,数码管会开始计时
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1