【正文】
hour_rd(3 downto 0) = 0)then hour_rd(3 downto 0) = 1001。 hour_rd(7 downto 4) = hour_rd(7 downto 4) 1。 else hour_rd(3 downto 0) = hour_rd(3 downto 0) 1。 end if。 end if。 else min_rd(7 downto 4) = min_rd(7 downto 4) 1。 end if。 else min_rd(3 downto 0) = min_rd(3 downto 0) 1。 end if。 else sec_rd(7 downto 4) = sec_rd(7 downto 4) 1。 end if。 else sec_rd(3 downto 0) = sec_rd(3 downto 0) 1。 end if。 end if。 end if。 end if。 end if。 end if。 end if。 end if。 end if。 end if。 end process。 fmo=fm_1。 process(clk) begin if clk39。event and clk = 39。139。 then if(min_r=min_ra and hour_r=hour_ra and sec_r(0)=39。039。 and alarm=39。039。)then fm_1=clk_1000Hz。 else if(min_r=min_ra and hour_r=hour_ra and sec_r(0) =39。139。 and alarm=39。039。 )then fm_1=clk_500Hz。 else if ( min_r(7 downto 4 )= 5 and min_r(3 downto 0)= 9 and sec_r(7 downto 4) = 5 and sec_r(0)=39。139。 ) then fm_1=clk_1000Hz。 else if ( min_r(7 downto 4 )= 5 and min_r(3 downto 0)= 9 and sec_r(7 downto 4) = 5 and sec_r(0) = 39。039。) then fm_1=clk_500Hz。 else if (dsk=39。039。 and min_rd(7 downto 0)=00000000 and hour_r(7 downto 0)=00000000 and sec_rd(7 downto 4)=0 and sec_rd( 0)=39。139。) then fm_1=clk_1000Hz。 else if (dsk=39。039。 and min_rd(7 downto 0)=00000000 and hour_r(7 downto 0)=00000000 and sec_rd(7 downto 4)=0 and sec_rd(0)=39。039。) then fm_1=clk_500Hz。 else fm_1=39。139。 end if。 end if。 end if。 end if。 end if。 end if。 end if。 end process。 end rt1。顯示數(shù)碼管,源代碼如下:library ieee。use 。use 。use 。entity disp isport( rst,clk : in std_logic。 k,set,alarm,ds,dsk : in std_logic。 change_1,change_2 : in std_logic。 fm : out std_logic。 dig,Y : out std_logic_vector(7 downto 0))。end disp。architecture rt1 of disp issignal min,hour,sec :std_logic_vector(7 downto 0)。signal clkout,fmo :std_logic。signal scan_t :std_logic_vector(2 downto 0)。signal A :std_logic_vector(3 downto 0)。signal dig_r,Y_r :std_logic_vector(7 downto 0)。ponent adjustport( rst,clk,k,set,alarm,ds,dsk : in std_logic。 change_1,change_2 : in std_logic。 fmo : out std_logic。 sec,min,hour : out std_logic_vector(7 downto 0))。end ponent。beginU2:adjust port map(rst,clk,k,set,alarm,ds,dsk,change_1,change_2,fmo,sec,min,hour)。 process(clk,rst) variable t :integer range 0 to 50000000。 begin if clk39。event and clk = 39。139。 then if rst = 39。039。 then t := 0。 else if t = 99999 then t := 0。 else t := t + 1。 if t = 49999 then clkout = 39。139。 else clkout = 39。039。 end if。 end if。 end if。 end if。 end process。 process(clkout,rst) begin if clkout39。event and clkout = 39。139。 then if rst = 39。039。 then scan_t = 000。 else scan_t = scan_t + 39。139。 end if。 end if。 end process。 fm = fmo。 dig = dig_r。 Y = Y_r。 process(scan_t,sec,min,hour) begin case (scan_t) is when 000 = dig_r = 11111110。 A = sec(3 downto 0)。 when 001 = dig_r = 11111101。 A = sec(7 downto 4)。 when 010 = dig_r = 11110111。 A = min(3 downto 0)。 when 011 = dig_r = 11101111。 A = min(7 downto 4)。 when 100 = dig_r = 10111111。 A = hour(3 downto 0)。 when 101 = dig_r = 01111111。 A = hour(7 downto 4)。 when 110 = dig_r = 11111011。 A = 1010。 when 111 = dig_r = 11011111。 A = 1011。 when others = dig_r = 11111111。 A = 0000。 end case。 end process。 process(A) begin case (A) is when 0000 = Y_r = 11000000。0 when 0001 = Y_r = 11111001。1 when 0010 = Y_r = 10100100。2 when 0011 = Y_r = 10110000。3 when 0100 = Y_r = 10011001。4 when 0101 = Y_r = 10010010。5 when 0110 = Y_r = 10000010。6 when 0111 = Y_r = 11111000。7 when 1000 = Y_r = 10000000。8 when 1001 = Y_r = 10010000。9 when 1010 = Y_r = 10111111。 when 1011 = Y_r = 10111111。 when 1100 = Y_r = 10100110。c when 1101 = Y_r = 10100001。d when 1110 = Y_r = 10000110。e when 1111 = Y_r = 10001110。f end case。 end process。end