




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、数字电路与逻辑设计实验报告一 设计课题的任务要求 设计并实现一个学校作息时间管理系统。基本要求:1、该管理系统有常态、考试和假日三种工作模式,三种模式用一个按键BTN 实现切换,并用点阵进行显示:常态模式显示N,考试模式显示E,假日模式显示H。2、常态模式:每天上午的 7 点50、下午13 点20 和18 点20 打预备铃,上午的8 点、9 点、10 点10 分、11 点10 分、下午的13 点30、14 点30、15 点40、16 点40、18点30 和19 点30 打上课铃,上午的8 点50、9 点50、11 点、12 点、下午的14 点20、15 点20、16 点30、17 点30、19
2、 点20 和20 点20 打下课铃,每天晚上的23点打熄灯铃。3、考试模式:每天上午的7 点50、下午12 点50 打预备铃,上午的8 点、10 点、下午的13 点、15 点打考试铃,上午的12 点和下午的17 点打收卷铃,每天晚上的23 点打熄灯铃。4、假日模式:只在晚上 23 点打熄灯铃。5、铃声要求:预备铃声、上课玲声、下课铃声、熄灯铃声、考试铃声和收卷铃声至少用3 种用不同的乐曲表示,每种铃声不短于10 秒,不长于20 秒,且上课铃声和考试铃声必须终止于开始时间,下课铃声和收卷铃声必须起始于课程或考试结束时间。6、任何模式下,时钟都要走时正确,且可以用按键BTN 进行校正调节,时间用6
3、 个数码管显示。提高要求:1、打铃时间可以人工修改。2、自拟其它功能。二 系统设计1. 设计思路第一步先做出一个数字钟,显示正确时间,通电后开始工作,选择模式即正常模式(点阵显示N)、考试模式(点阵显示E)、假期模式(点阵显示H)。例如在正常模式时,按照要求在某一时间上课、下课、熄灯,并通过蜂鸣器发出不同的声音用来代表铃声。再通过按钮来人工调节时间,完成基本功能,其他模式类似,故不再累述。2. 总体框图开始按钮调节时间数字钟H模式选择 EN熄灯熄灯铃下课铃上课铃预备铃铃4铃铃4铃铃3铃铃2铃铃1铃铃4铃铃6铃铃5铃铃1铃熄灯铃收卷开考铃预备铃三 仿真及仿真波形此图表示在秒数个位到9之后,秒数十
4、位进一,且个位变为0重新计数。此图表示在秒数十位达到5之后,分数个位进位,同时秒数十位重新从0开始计数。此图表示在分数个位达到9之后,分数十位进位,同时分数个位重新从0开始计数。其他情况类似,不再累述。四 源程序及注释 library ieee;use ieee. std_logic_1164.all;use ieee.std_logic_unsigned.all;entity djh is port( clk,clear:in std_logic; BTN0,BTN1,BTN2,BTN3,BTN4,BTN5,BTN6:in std_logic; b:o
5、ut std_logic_vector(6 downto 0); choose:in std_logic_vector(1 downto 0);- zuenzemoshi clk_out:out std_logic; cat:out std_logic_vector(5 downto 0); ROW:out std_logic_vector(7 downto 0); COL:out std_logic_vector(7 downto 0);end djh; architecture clock of djh is signa
6、l q1_temp,q2_temp,q3_temp,q4_temp,q5_temp,q6_temp:std_logic_vector(3 downto 0) ;-jishuyong signal q1,q2,q3,q4,q5,q6,q:std_logic_vector(3 downto 0);-ChooseScene signal tmp:integer range 0 to10000; signal tmp2:integer range 0 to 5999999; signal tmp1:integer range 0 to 124
7、99999; signal tmp5:integer range 0 to 1500;-1 signal tmp3:integer range 0 to 5; signal tmp4:integer range 0 to 7; signal ring:integer range 0 to 5; signal tmp10:integer range 0 to 20000; signal tone:std_logic_vector(2 downto 0); signal clktmp,clktmp1,clktmp2,c
8、lktmp3,clktmp4:std_logic; signal clk_out2,clk_out1,clk_out3,clk_out4,clk_out5,clk_out6:std_logic; signal ROW_temp:std_logic_vector(7 downto 0); signal COL_temp:std_logic_vector(7 downto 0); signal start:std_logic; -定义输入输出beginp1:process(clk,BTN0,BTN1,BTN2,BTN3,BTN4,BTN5)variable
9、nothing:integer:=0; begin if clear='0' then tmp1<=0; elsif clk'event and clk='1' then if tmp5=1500 then tmp5<=0; clktmp4<=not clktmp4; else tmp5<=tmp5+1;
10、160; end if; if tmp1=12499999 then tmp1<=0; clktmp1<=not clktmp1; else tmp1<=tmp1+1; end if; end if; clk_out1<=clktmp1; clk_out6<=cl
11、ktmp4; if clk_out6'event and clk_out6='1' then if tmp3=5 then tmp3<=0; else tmp3<=tmp3+1; end if; end if; if(clk_out1'event and clk_out1='1')then
12、60; if clear='0'then q6_temp<="0000" elsif (q6_temp="1001")then if (q5_temp="0101")then if (q4_temp="1001&
13、quot;)then if (q3_temp="0101")then if (q2_temp="1001")then if (q1_temp="0010")then
14、160; q1_temp<="0000" else q1_temp<=q1_temp+1; -此段程序是计秒数并时分秒共六位按规则叠加 end if;
15、60; q2_temp<="0000" else q2_temp<=q2_temp+1; end if; q3_temp<="0000"
16、 else q3_temp<=q3_temp+1; end if; q4_temp<="0000" else q4_temp<=q4_temp+1; end if;
17、160; q5_temp<="0000" else q5_temp<=q5_temp+1; end if; q6_temp<="0000" else q6_temp<=q6_temp+1
18、; end if;if(BTN0='1')then if q6_temp="1001" then -调节秒数个位 q6_temp<="0000" elseq6_temp<=q6_temp+1; end if;elsif(BTN1='1')then if q5_temp="0101" then -调节秒数十位 q5_temp&
19、lt;="0000" else q5_temp<=q5_temp+1; end if;elsif( BTN2='1')then if q4_temp="1001" then -调节分数个位 q4_temp<="0000" else q4_temp<=q4_temp+1; end if;elsif(BTN3='1')then if q3_temp=&q
20、uot;0101" then q3_temp<="0000" -调节分数十位 else q3_temp<=q3_temp+1; end if;elsif( BTN4='1')then if q2_temp="1001" then -调节小时数个位 q2_temp<="0000" else q2_temp<=q2_temp+1; end
21、 if;elsif(BTN5='1')then if q1_temp="0010" then -调节小时数十位 q1_temp<="0000" elseq1_temp<=q1_temp+1;end if; end if;end if;case tmp3 is when 0=>cat<="011111"q<=q1; when 1=>cat<="101111"q<=q
22、2; when 2=>cat<="110111"q<=q3; when 3=>cat<="111011"q<=q4; -依次显示六个数码管 when 4=>cat<="111101"q<=q5; when 5=>cat<="111110"q<=q6; when others=>cat<="000000" end case; case q is&
23、#160; when"0000" => b <="1111110" when"0001" => b <="0110000" when"0010" => b <="1101101" wh
24、en"0011" => b <="1111001" when"0100" => b <="0110011" -数码管显示09数字 when"0101" => b <="1011011" when"0110" =>
25、b <="1011111" when"0111" => b <="1110000" when"1000" => b <="1111111" when"1001" => b <="1111011"
26、60; when others=> b <="0000000"end case;q1<=q1_temp;q2<=q2_temp;q3<=q3_temp;q4<=q4_temp;q5<=q5_temp;q6<=q6_temp;end process p1;ChooseScene:process(choose,clk,clear,a)variable divide:integer:=0;variable count:integer:=0;variable nothing:integer:=
27、0;beginif clk'event and clk='1' then clk_out3<='1' if tmp=divide then tmp<=0; clktmp<=not clktmp; -点阵分频 else tmp<=tmp+1; end if;if tmp10=
28、20000 then tmp10<=0;clktmp3<=not clktmp3;else tmp10<=tmp10+1;end if; if tmp2=5999999 then tmp2<=0; clktmp2<=not clktmp2; else tmp2<=tmp2+1; end if;
29、 else clk_out3<='0'end if;clk_out4<=clktmp3;clk_out<=clktmp;clk_out2<=clktmp2; -分频为2hzcase tone is when"001"=>divide:=23899;-1,25Mhz when"010"=>divide:=21283;-2 when"011&q
30、uot;=>divide:=18959;-3 when"100"=>divide:=17894;-4 when"101"=>divide:=15943;-5 when"110"=>divide:=14204;-6 when"111"=>divide:=12653;-7 when other
31、s=>divide:=0; end case; if clk_out4'event and clk_out4='1' then if tmp4=7 then tmp4<=0; else tmp4<=tmp4+1; end if; end if; if(choose="00")the
32、n case tmp4 is when 0=> COL<="00000000"ROW<="00000000" when 1=> COL<="00000000"ROW<="00000000" when 2=> COL<="00000000"ROW<="00000000"
33、 when 3=> COL<="00000000"ROW<="00000000" when 4=> COL<="00000000"ROW<="00000000" -无模式选择 when 5=> COL<="00000000"ROW<="00000000" when
34、6=> COL<="00000000"ROW<="00000000" when 7=> COL<="00000000"ROW<="00000000" when others =>COL<="00000000"ROW<="00000000" end case; elsif(choose
35、="01")then - N case tmp4 is when 0=> COL<="00000000"ROW<="01111111" when 1=> COL<="00000000"ROW<="10111111" when 2=> COL<=&qu
36、ot;01000010"ROW<="11011111" when 3=> COL<="01000110"ROW<="11101111" when 4=> COL<="01001010"ROW<="11110111" -模式选择为N when 5=> COL<="01010010"ROW<=
37、"11111011" when 6=> COL<="01100010"ROW<="11111101" when 7=> COL<="01000010"ROW<="11111110" when others =>COL<="00000000"ROW<="00000000"end case
38、; if( ( q4_temp="0000"and q3_temp="0101"and q2_temp="0111"and q1_temp="0000"and q5_temp="0000") -07:50 or ( q4_temp="0000&qu
39、ot;and q3_temp="0010"and q2_temp="0011"and q1_temp="0001"and q5_temp="0000") -13:20 or ( q4_temp="0000"and q3_temp="0010"and q2_temp="1000"and q1_temp="0001"an
40、d q5_temp="0000") -18:20 )then ring<=0; -预备时间和预备铃 elsif( (q4_temp="1001"and q3_temp="0101"and q2_temp="0111"and q1_temp=&q
41、uot;0000"and q5_temp="0101") or (q4_temp="1001"and q3_temp="0101"and q2_temp="1000"and q1_temp="0000"and q5_temp="0101") or
42、60; (q4_temp="1001"and q3_temp="0000"and q2_temp="0000"and q1_temp="0001"and q5_temp="0101") or (q4_temp="1001"and q3_temp="0000"and q2_temp="0001"and q1_temp=
43、"0001"and q5_temp="0101") or (q4_temp="1001"and q3_temp="0010"and q2_temp="0011"and q1_temp="0001"and q5_temp="0101") or
44、 (q4_temp="1001"and q3_temp="0010"and q2_temp="0100"and q1_temp="0001"and q5_temp="0101") or (q4_temp="1001"and q3_temp="0011"and q2_temp="0101"
45、and q1_temp="0001"and q5_temp="0101") or (q4_temp="1001"and q3_temp="0011"and q2_temp="0110"and q1_temp="0001"and q5_temp="0101")
46、0; or (q4_temp="1001"and q3_temp="0010"and q2_temp="1000"and q1_temp="0001"and q5_temp="0101") or (q4_temp="1001"and q3_temp="0010"and q2_temp="1001&q
47、uot;and q1_temp="0001"and q5_temp="0101") )then ring<=1; -上课时间及上课铃 elsif( (q4_temp="0000"and q3_temp="0101"and q2_t
48、emp="1000"and q1_temp="0000"and q5_temp="0000") -08:50 or (q4_temp="0000"and q3_temp="0101"and q2_temp="1001"and q1_temp="0000"and q5_temp="0000")
49、; -09:50 or (q4_temp="0000"and q3_temp="0000"and q2_temp="0001"and q1_temp="0001"and q5_temp="0000") -11:00 or (q4_temp=&
50、quot;0000"and q3_temp="0000"and q2_temp="0010"and q1_temp="0001"and q5_temp="0000") -12:00 or (q4_temp="0000"and q3_temp="0010"and q2_temp="0100"and q1_temp=
51、"0001"and q5_temp="0000") -14:20 or (q4_temp="0000"and q3_temp="0010"and q2_temp="0101"and q1_temp="0001"and q5_temp="0000") -15:20
52、60; or (q4_temp="0000"and q3_temp="0011"and q2_temp="0101"and q1_temp="0001"and q5_temp="0000") -16:30 or (q4_temp="0000"and q3_temp="
53、;0011"and q2_temp="0111"and q1_temp="0001"and q5_temp="0000") -17:30 or (q4_temp="0000"and q3_temp="0010"and q2_temp="1001"and q1_temp="0001"and q5_temp=&quo
54、t;0000") -19:20 or (q4_temp="0000"and q3_temp="0010"and q2_temp="0000"and q1_temp="0010"and q5_temp="0000") -20:20 )then &
55、#160; ring<=5; -下课时间及下课铃 elsif (q4_temp="0000"and q3_temp="0000"and q2_temp="0011"and q1_temp="0010"and q5_temp="0000") -23:0
56、0 Then ring<=4; -熄灯时间及熄灯铃 else clk_out<='0' end if; elsif(
57、choose="10")then - E case tmp4 is when 0=> COL<="00000000"ROW<="01111111" when 1=> COL<="00111111"ROW<="10111111" when 2=> COL<="
58、00000001"ROW<="11011111" when 3=> COL<="00000001"ROW<="11101111" -模式选择为E when 4=> COL<="00111111"ROW<="11110111" when 5=> COL<="00000001"ROW<=&qu
59、ot;11111011" when 6=> COL<="00000001"ROW<="11111101" when 7=> COL<="00111111"ROW<="11111110" when others =>COL<="00000000"ROW<="00000000" end c
60、ase; if( (q4_temp="0000"and q3_temp="0101"and q2_temp="0111"and q1_temp="0000"and q5_temp="0000") -07:50 or (q4_temp="0000"and
61、 q3_temp="0101"and q2_temp="0010"and q1_temp="0001"and q5_temp="0000") -12:50 )then ring<=0; elsif( (q4_temp=&q
62、uot;1001"and q3_temp="0101"and q2_temp="0111"and q1_temp="0000"and q5_temp="0101") -08:00 or (q4_temp="1001"and q3_temp="0101"and q2_temp="1001"and q1_
63、temp="0000"and q5_temp="0101") -10:00 or (q4_temp="1001"and q3_temp="0101"and q2_temp="0010"and q1_temp="0001"and q5_temp="0101")
64、; -13:00 or (q4_temp="1001"and q3_temp="0101"and q2_temp="0100"and q1_temp="0001"and q5_temp="0101") -15:00 )then ring<=2; &
65、#160; elsif( (q4_temp="0000"and q3_temp="0000"and q2_temp="0010"and q1_temp="0001"and q5_temp="0000") -12:00 or (q4_temp="0000"and q
66、3_temp="0000"and q2_temp="0111"and q1_temp="0001"and q5_temp="0000") -17:00 )then ring<=3; elsif (q4_temp
67、="0000"and q3_temp="0000"and q2_temp="0011"and q1_temp="0010"and q5_temp="0000") -23:00 then ring<=4; else clk_out<='0'
68、160; end if; elsif(choose="11")then - Hcase tmp4 is when 0=> COL<="01000010"ROW<="01111111" when 1=> COL<="01000010"ROW<="10111111" &
69、#160; when 2=> COL<="01000010"ROW<="11011111" when 3=> COL<="01000010"ROW<="11101111" -模式选择为H when 4=> COL<="01111110"ROW<="11110111" when 5=>
70、COL<="01000010"ROW<="11111011" when 6=> COL<="01000010"ROW<="11111101" when 7=> COL<="01000010"ROW<="11111110" when others =>COL<="00000000"
71、ROW<="00000000" end case; if (q4_temp="0000"and q3_temp="0000"and q2_temp="0011"and q1_temp="0010"and q5_temp="0000") -23:00 th
72、en ring<=4; else
73、0;clk_out<='0' ; end if; elsecase tmp4 is when 0=> COL<="000
74、00000"ROW<="00000000" when 1=> COL<="00000000"ROW<="00000000" when 2=> COL<="00000000"ROW<="00000000" when 3=> COL<="00000000"ROW<=
75、"00000000" when 4=> COL<="00000000"ROW<="00000000" when 5=> COL<="00000000"ROW<="00000000" when 6=> COL<="00000000"ROW<="00000000"
76、 when 7=> COL<="00000000"ROW<="00000000" when others =>COL<="00000000"ROW<="00000000" end case; clk_out<='0'end if;if BTN6='1' or SW3='1' then start<='1'case ring
77、 iswhen 0=> if start='1' thencount:=1; if clk_out2='1'then if count<30 then count:=count+1; else clk_ou
78、t<='0' end if; else NULL; end if;case count is when 1=>tone<="110" when 2=>tone<="110"
79、;when 3=>tone<="001" when 4=>tone<="010" -以下为铃声1-6 when 5=>tone<="011" when 6=>tone<="100" when 7=>tone<="011" when 8=>tone<="010" &
80、#160; when 9=>tone<="110" when 10=>tone<="110" when 11=>tone<="001" when 12=>tone<="010" when 13=>tone<="011" when 14=
81、>tone<="100" when 15=>tone<="011" when 16=>tone<="110" when 17=>tone<="110" when 18=>tone<="001" when 19=>tone<="010" w
82、hen 20=>tone<="011" when 21=>tone<="100" when 22=>tone<="011" when 23=>tone<="010" when 24=>tone<="011" when 25=>tone<="001"
83、 when 26=>tone<="010" when 27=>tone<="001" when 28=>tone<="111" when 29=>tone<="110" when others=>clk_out<='0' end case; else clk_out<='0
84、39;end if; when 1=> if start='1' thencount:=1; if clk_out2='1'then if count<41 then count:=count+1; else
85、 clk_out<='0' end if; else NULL; end if;case count is when 1=>tone<="110" when 2=>tone<="011"
86、; when 3=>tone<="011" when 4=>tone<="011" when 5=>tone<="011" when 6=>tone<="100" when 7=>tone<="100" when 8=>tone<="110"
87、0; when 9=>tone<="011" when 10=>tone<="010" when 11=>tone<="010" when 12=>tone<="010" when 13=>tone<="010"
88、;when 14=>tone<="001" when 15=>tone<="010" when 16=>tone<="010" when 17=>tone<="011" when 18=>tone<="100" when 19=>tone<="0
89、10" when 20=>tone<="010" when 21=>tone<="010" when 22=>tone<="010" when 23=>tone<="110" when 24=>tone<="111" when 25=>tone<=
90、"010" when 26=>tone<="001" when 27=>tone<="001" when 28=>tone<="001" when 29=>tone<="111" when 30=>tone<="110"
91、when 31=>tone<="111" when 32=>tone<="111" when 33=>tone<="111" when 34=>tone<="111" when 35=>tone<="010" when 36=>tone<="001"
92、 when 37=>tone<="111" when 38=>tone<="110" when 39=>tone<="110" when 40=>tone<="110" when others=>clk_out<='0' end case; else clk_out<='0'en
93、d if;when 2=> if start='1' thencount:=1; if clk_out2='1'then if count<31 then count:=count+1; e
94、lse clk_out<='0' end if; else NULL; end if;case count is when 1=>tone<="110" when 2=>tone<="011"
95、160; when 3=>tone<="010" when 4=>tone<="110" when 5=>tone<="011" when 6=>tone<="010" when 7=>tone<="110" when 8=>tone<="011"&
96、#160; when 9=>tone<="010" when 10=>tone<="001" when 11=>tone<="001" when 12=>tone<="011" when 13=>tone<="010"
97、160;when 14=>tone<="101" when 15=>tone<="100" when 16=>tone<="011" when 17=>tone<="010" when 18=>tone<="101"
98、60;when 19=>tone<="100" when 20=>tone<="011" when 21=>tone<="010" when 22=>tone<="110" when 23=>tone<="011" when 24=>tone<="010"
99、60; when 25=>tone<="110" when 26=>tone<="011" when 27=>tone<="010" when 28=>tone<="110" when 29=>tone<="011" when 30=>tone&l
100、t;="010" when others=>clk_out<='0'end case;else clk_out<='0'end if;when 3=> if start='1' thencount:=1; if clk_out2='1'then if count<28 then count:=count+1; else clk_out<='0' end if;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年安徽审计职业学院高职单招高职单招英语2016-2024历年频考点试题含答案解析
- 职工小家培训课件
- 2025年安徽体育运动职业技术学院高职单招职业技能测试近5年常考版参考题库含答案解析
- alcon培训课件教学课件
- 世界读书日活动策划方案
- 肿瘤病病人的护理查房
- 肺心病护理疑难病例讨论
- 6S基础知识课件
- 2025年云南省楚雄市高三下学期期末“3+1”质量调研生物试题含解析
- 莱芜职业技术学院《基本乐理与应用》2023-2024学年第二学期期末试卷
- 高一数学下学期考点精讲+精练(人教A版2019必修第二册)第六章平面向量及其应用章末检测卷(一)(原卷版+解析)
- 2024车辆挂靠证明
- DL∕T 2138-2020 电力专利价值评估规范
- 道法国测题附有答案
- 异地就医备案的个人承诺书
- JT-T-1039-2016公路桥梁聚氨酯填充式伸缩装置
- 航空航天概论智慧树知到期末考试答案章节答案2024年西安航空学院
- 人教版七年级下册生物重点知识提纲(填空版)
- 2024年河南水利与环境职业学院单招职业适应性测试题库审定版
- 幼儿园一等奖公开课:大班绘本《爱书的孩子》课件
- 地板防火检验报告
评论
0/150
提交评论