【文章內(nèi)容簡介】
ps_alarmon=ns_alarmon。 ps_houralarmon=ns_houralarmon。 end if。 end process。 process(ps_alarmon,keypressed,keyvalue) begin if(ps_alarmon=s_on)then if(keypressed=39。139。and keyvalue=1101)then ns_alarmon=s_off。 else ns_alarmon=ps_alarmon。 end if。 alarmon=39。139。 else if(keypressed=39。139。and keyvalue=1101)then ns_alarmon=s_on。 else ns_alarmon=ps_alarmon。 end if。 alarmon=39。039。 end if。 end process。 process(ps_houralarmon,keypressed,keyvalue) begin if(ps_houralarmon=s_on)then if(keypressed=39。139。and keyvalue=1100)then ns_houralarmon=s_off。 else ns_houralarmon=ps_houralarmon。 end if。 houralarmon=39。139。 else if(keypressed=39。139。and keyvalue=1100)then ns_houralarmon=s_on。 else ns_houralarmon=ps_houralarmon。 end if。 houralarmon=39。039。 end if。 end process。 end rt。 鬧鐘寄存器 library ieee。 use 。 entity alarmreg is port( clk,alarmload:in std_logic。 buffertime:in std_logic_vector(23 downto 0)。 alarmtime:out std_logic_vector(23 downto 0) )。 end alarmreg。 architecture rt of alarmreg is begin process(clk) begin if(clk39。event and clk=39。139。)then if(alarmload=39。139。)then alarmtime=buffertime。 end if。 end if。 end process。 end rt。 鈴聲管理 library ieee。 use 。 entity bell is port( alarmtime,time:in std_logic_vector(23 downto 0)。 alarmon,houralarmon,clk:in std_logic。 alarm_signal:out std_logic )。 end bell。 architecture rt of bell is signal alarm,houralarm:std_logic。 type state is(s0,s1,s2,s3,s4)。 signal present_state,next_state:state:=s0。 begin process(clk,alarmon) begin if(alarmon=39。039。)then present_state=s0。 elsif(clk39。event and clk=39。139。)then present_state=next_state。 end if。 end process。 process(present_state,time,alarmtime ) begin case present_state is when s0= if(alarmtime=time)then next_state=s1。 else next_state=present_state。 end if。 when s1= if(time(6)=39。139。)then next_state=s2。 else next_state=present_state。 end if。 when s2= if(time(6)=39。039。)then next_state=s3。 else next_state=present_state。 end if。 when s3= if(time(6)=39。139。)then next_state=s4。 else next_state=present_state。 end if。 when s4= If(time(6)=39。039。)then next_state=s0。 else next_state=present_state。 end if。 when others= next_state=s0。 end case。 end process。 process(present_state) begin if(present_state=s3 or present_state=s4)then alarm=39。139。 else alarm=39。039。 end if。 end process。 process(houralarmon,time) begin if(houralarmon=39。139。and time(15 downto 0)=0000000000000000)then houralarm=39。139。