【正文】
。 u7:fq_divider port map(clk,reset,s5)。 u5:alarm_reg port map(s6,s1,clk,reset,s7)。 u3:alarm_contorller port map(key_down,alarm_botton,time_botton,clk,reset,s1,s2,s3,s4)。 begin u1:decoder port map(keypad,s0)。 signal s1,s2,s3,s4,s5:std_logic。 end ponent decoder。 ARCHITECTURE art of alarm_clock is ponent decoder is port(keypad:in std_logic_vector(9 downto 0)。 sound_alarm:out std_logic)。 key_down,alarm_botton,time_botton,clk,reset:in std_logic。 use 。 use 。最后總體封裝。分頻器接時間寄存器,用來計數(shù)。 八.鬧鐘的整體組裝 計思路:前面已經(jīng)把鬧鐘的各個模塊分別進行了編譯封裝,現(xiàn)在開始整體組裝。 end process。 end if。 t:=t+1。 elsif (t(divide_period1))then clk_out=39。139。039。)then t:=0。 begin if(reset=39。 ARCHITECTURE art of fq_divider is constant divide_period:t_short:=6000。 clk_out:out std_logic)。 use 。 Fq_divider library IEEE。 end art。range loop display(i)=seven_seg(display_time(i)) end loop。 end process。 else assert false report uncertain display_driver control! severity waring。039。then display_time=alarm_time。 elsif show_a=39。139。 end loop sound_loop。039。139。 begin process(new_time,alarm_time,current_time,show_new_time,show_a) begin sound_loop:for i in alarm_time39。 end display_driver。 display:out t_display。 show_new_time:in std_logic。 current_time:in t_clock_time。 use 。反之無效 Display_driver library IEEE。若 show_a 也為低電平,根據(jù) current_time 端口的輸入信號,對 display端口驅(qū)動。 end art。 end process。 i_current_time=c_t。 end if。 end if。 else c_t(2):=0。 end if。 else c_t(2):=0。 else c_t(1):=0。 else c_t(0):=0。then i_current_time=new_current_time。 elsif load_new_c=39。139。 begin process(clk,reset) variable c_t:t_clock_time。 end Alarm_counter。 new_current_time:in t_clock_time。 ENTITY Alarm_counter is port(load_new_c:in std_logic。 use 。 Reset 的優(yōu)先級高于 load_new_c,且當 reset,load_new_c 同時為低電平時,在時鐘上升沿處,對 current_time端口輸出信號進行累加一次加 1,并根據(jù)小時,分鐘 的進位規(guī)律進位。 五. 時間計數(shù)器 的設(shè)計 : 時間計數(shù)器在時鐘上升沿同步下,根據(jù) load_new_c 端口的輸入控制信號控制 current_time口的輸出,當控制信號為高電平時,把 new_current_time端口的值賦給 current_time進行輸出。 end process。 end if。039。then alarm_time=new_alarm_time。 else if rising_edge(clk)then if load_new_a=39。139。 end Alarm_reg。 load_new_a:in std_logic。 ENTITY Alarm_reg is po