当前位置:文档之家› 数电课设大作业数字钟

数电课设大作业数字钟

大连理工大学本科实验报告题目:数字钟课程名称:数字电路课程设计学院(系):电信专业:电气班级:1201学生姓名:学号:完成日期:2014.11.23成绩:2014 年11 月23 日课程设计得分表一、数字钟课程设计要求:1、设计一个具有‘时’、‘分’、‘秒’的十进制数字显示(小时从00~23)计时器。

2、整点报时。

两种方法任选其一:⑴发出仿中央人民广播电台的整点报时信号,即从59分50秒起,每隔2秒钟发出一次低音“嘟”的信号,连续5次,最后一次要求高音“嘀”的信号,此信号结束即达到整点。

“嘟”是500Hz左右的频率输出,“嘀”是1000Hz左右的频率输出⑵通过LED闪烁实现,闪烁频率及花型可自己设计并在这里说明。

3、手动校时、校分、校秒。

4、定时与闹钟功能,能在设定的时间发出闹铃声。

5、设计一个秒表,显示1%秒到60秒、手动停止。

6、设计一个倒计时,显示小时、分钟、秒。

7、其他创新。

第1题25分,其他每题5分二、课程设计考试(40分,每题分):考试题目:1、实体名□2、计数器□3、异步清零□4、进位输出□5、仿真图□6、数码管输出□7、分频□8、元件例化□9、引脚分配□10、下载□题目:数字钟(1.大连理工大学电信学院,辽宁大连,116023;2. 大连理工大学电工电子实验中心,辽宁大连,116023;)1.设计要求一、电子表部分:(1)由晶振电路产生1HZ的校准秒信号。

?(2)设计一个具有‘时’、‘分’、‘秒’的十进制数字显示(小时从00~23)计时器具有手动校时、校分,校秒和清零的功能。

?(3)整点报时功能,通过LED闪烁实现,此实验LED灯亮一秒。

二、秒表部分:(1)有晶振产生100HZ的校准0.01秒信号。

(2)设计一个有“时”、“分”、“秒”、“0.1秒”、“0.01秒”(23小时59分59秒99)显示功能(3)具有开始计时暂停计时功能和清零功能三、具有电子表和秒表状态切换。

四、划出框图和逻辑电路图,写出设计。

2. 设计分析及系统方案设计1设计主要分为数字钟和秒表计时两个部分并选择用二选一数据选择器来实现两种功能切换。

2由于时钟用的是cyclone2开发板上提供的50MHz晶振的频率,所以数字时钟和秒表计时都用到分频器分频分别得到1Hz和100Hz的时钟频率。

3数字时钟部分包括分频部分即分频器;计时部分,包含模六计数器、模十计数器;选位调节部分,分别对时钟分钟和小时部分进行调节,用二选一数据选择器实现;数字显示部分,用到6个4-16译码器,和6个数码显示管;整点报时部分,其中报时用LED灯闪烁代替;含有清零端开关。

4 秒表计时包含分频器;计时器包含模六计数器,模十计数器,模三计数器;数字显示器包含有8个4-16译码器,8个数码显示管;计时启停开关,清零开关。

3.系统以及模块硬件电路设计输入:晶振50MHz,选位开关(0为可调节,1为正常计时),数字钟清零开关(0为清零),开关切换计时状态(1为数字计时,0为秒表计时),秒表启停开关(1启动,0停止),秒表复位开关(0复位),选择输出开关(1输出数字计时数字,0输出秒表计时数字)。

输出:LED灯,数字显示部分。

4 系统的VHDL 设计library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity keshe isport(clk:in std_logic;qo1,qo2,qo3,qo4,qo5,qo6,qo7,qo8:out std_logic_vector(6 downto 0);rst1:in std_logic;--开关1rst2:in std_logic;--开关2 输入分频得1Hz 分频得100Hz晶振 计时器部分(时、分、秒) 计时器部分选位调节 启停 复位清零 开关 1 0 选择输出开关 输出数字显示输入 1LED 整点计时rst3:in std_logic;--开关3rst4:in std_logic;--开关4switch1:in std_logic;switch2:in std_logic;key1:in std_logic;--分钟调节key2:in std_logic;--小时调节key3:in std_logic;runstop:in std_logic;--秒表启停开关led:out std_logic_vector(7 downto 0));end;architecture a of keshe issignal qh,ql,qhs,qls,qhf,qlf,qhh,qlh:std_logic_vector(3 downto 0):="0000";signal run:std_logic:='0';signal cnt,ct:integersignal qqh1,qqh2,qql1,qql2,qqhf1,qqhf2,qqhs1,qqhs2,qqls1,qqls2,qqhh1,qqhh2,qqlh1,qqlh2,qqlf1,qqlf2:std_logic_vector(3 downto 0);signal clk1s,csf,csh,css,clk1s2,csf2,csh2,css2,csh2in,csf2in,css2in: std_logic;component segmentport(qi:in std_logic_vector(3 downto 0);qo:out std_logic_vector(6 downto 0));end component;beginu1: segment port map (qh,qo1);u2: segment port map (ql,qo2);u3: segment port map (qhf,qo5);u4: segment port map (qlf,qo6);u5: segment port map (qhh,qo7);u6: segment port map (qlh,qo8);u7: segment port map (qhs,qo3);u8: segment port map (qls,qo4);process(rst1,qqh1,qqh2,qql1,qql2,qqhf1,qqhf2,qqhs1,qqhs2,qqls1,qqls2,qqhh1,qqhh2,qqlh1,qqlh2, qqlf1,qqlf2)--电子表秒表切换beginif rst1='1' thenqh<=qqh1; qhs<=qqhs1; qhf<=qqhf1; qhh<=qqhh1;ql<=qql1; qls<=qqls1;qlf<=qqlf1;qlh<=qqlh1;elseqh<=qqh2;qhs<=qqhs2; qhf<=qqhf2; qhh<=qqhh2;ql<=qql2;qlf<=qqlf2;qlh<=qqlh2;end if;end process;process(runstop,rst2)--秒表计停开关beginif rst2='0' thenrun<='0';elsif runstop'event and runstop='1' then run<=not run;end if;end process;process(clk ,clk1s,rst2,run)beginif rising_edge(clk)thenif cnt=499999 thencnt<=0;clk1s<='1';else cnt<=cnt+1;clk1s<='0';end if;end if; if rst2='0' thenqql1<="0000";qqh1<="0000";elsif run='1' thenif clk1s'event and clk1s='1' thenif (qql1="1001" and qqh1="1001" )thenqql1<="0000";qqh1<="0000";css<='1' ;else if qql1="1001" thenqqh1<=qqh1+1;qql1<="0000";css<='0' ;elseqql1<=qql1+1;css<='0' ;end if;end if;end if;end if;end process;process(css,rst2)beginqqls1<="0000";qqhs1<="0000";elsif run='1' thenifcss'event and css='1' thenif (qqls1="1001" and qqhs1="0101" )thenqqls1<="0000";qqhs1<="0000";csf<='1' ;else if qqls1="1001" thenqqhs1<=qqhs1+1;qqls1<="0000";csf<='0' ;elseqqls1<=qqls1+1;csf<='0' ;end if;end if;end if;end if;end process;process(csf,rst2)beginif rst1='0' thenqqlf1<="0000";qqhf1<="0000";elsif run='1' thenifcsf'event and csf='1' thenif (qqlf1="0011" and qqhf1="0010" )thenqqlf1<="0000";qqhf1<="0000";csh<='1' ;else if qqlf1="1001" thenqqhf1<=qqhf1+1;qqlf1<="0000";csh<='0' ;elseqqlf1<=qqlf1+1;csh<='0' ;end if;end if;end if;end if;end process;process(csh,rst2)beginif rst2='0' thenqqlh1<="0000";qqhh1<="0000";elsif run='1' thenifcsh'event and csh='1' thenif (qqlh1="1001" and qqhh1="0101" )thenqqlh1<="0000";qqhh1<="0000";else if qqlh1="1001" thenqqhh1<=qqhh1+1;qqlh1<="0000";elseqqlh1<=qqlh1+1;end if;end if;end if;end if;end process;process(clk ,clk1s2,rst3)beginif rising_edge(clk)thenif ct=499999 thenct<=0;clk1s2<='1';else ct<=ct+1;clk1s2<='0';end if;end if;if rst3='0' thenqql2<="0000";qqh2<="0000";elsif clk1s2'event and clk1s2='1' thenif (qql2="1001" and qqh2="1001" )thenqql2<="0000";qqh2<="0000";css2<='1' ;else if qql2="1001" thenqqh2<=qqh2+1;qql2<="0000";css2<='0' ;elseqql2<=qql2+1;css2<='0' ;end if;end if;end if;end process;process(css2,rst4,key3)beginif rst4='1' thencss2in<=css2;elsecss2in<=key3;end if;end process;process(css2in,rst3)beginif rst3='0' thenqqls2<="0000";qqhs2<="0000";elsif css2in'event and css2in='1' thenif (qqls2="1001" and qqhs2="0101" )thenqqls2<="0000";qqhs2<="0000";csf2<='1' ;else if qqls2="1001" thenqqhs2<=qqhs2+1;qqls2<="0000";csf2<='0' ;elseqqls2<=qqls2+1;csf2<='0' ;end if;end if;end if;end process;process(csf2,switch1,key1)beginif switch1='1' thencsf2in<=csf2;elsecsf2in<=key1;end if;end process;process(csf2in,rst3)beginif rst3='0' thenqqlf2<="0000";qqhf2<="0000";elsifcsf2in'event and csf2in='1' thenif (qqlf2="0011" and qqhf2="0010" )thenqqlf2<="0000";qqhf2<="0000";csh2<='1' ;else if qqlf2="1001" thenqqhf2<=qqhf2+1;qqlf2<="0000";csh2<='0' ;elseqqlf2<=qqlf2+1;csh2<='0' ;end if;end if;end if;if(qqlf2="0000" and qqhf2="0000"and qqls2="0000" and qqhs2="0000" ) then ledelse led<="00000000";end if;end process;process(csh2,switch2,key2)beginif switch2='1' thencsh2in<=csh2;elsecsh2in<=key2;end if;end process;process(csh2in,rst3)beginif rst3='0' thenqqlh2<="0000";qqhh2<="0000";elsifcsh2in'event and csh2in='1' thenif (qqlh2="0011" and qqhh2="0010" )thenqqlh2<="0000";qqhh2<="0000";else if qqlh2="1001" thenqqhh2<=qqhh2+1;qqlh2<="0000";elseqqlh2<=qqlh2+1;end if;end if;end if;end process;end;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity segment isport(qi:in std_logic_vector(3 downto 0);qo:out std_logic_vector(6 downto 0));end;architecture b of segment isbeginprocess(qi)begincase qi iswhen "0000"=> qo<="1000000";when "0001"=> qo<="1111001";when "0010"=> qo<="0100100";when "0011"=> qo<="0110000";when "0100"=> qo<="0011001";when "0101"=> qo<="0010010";when "0110"=> qo<="0000010";when "0111"=> qo<="1111000";when "1000"=> qo<="0000000";when "1001"=> qo<="0010000";when others => qo<="1111111";end case;end process;end;1分频部分新时钟状态图如下:2秒表电子表输出切换部分开关判断为1时输出为数字计时输出,为0时输出为秒表计时输出。

相关主题