【正文】
process(clk) begin if (clk=39。139。 and clk39。event) then if counter=49999 then counter=0。 co= not co。 else counter=counter+1。 end if。 end if。 end process。 end art。 計(jì)時(shí)模塊的程序 1)、 十進(jìn)制計(jì)數(shù)器 library ieee。 use 。 use 。 entity cdu10 is port(clk,clr,en: in std_logic。 : out std_logic。 count10: out std_logic_vector(3 downto 0))。 end cdu10。 architecture art of cdu10 is signal temp:std_logic_vector(3 downto 0)。 begin process(clk,clr) begin if clr=39。139。 then temp=0000。 =39。039。 elsif (clk39。event and clk=39。139。) then if en=39。139。 then if temp=1001 then temp=0000。 =39。139。 else temp=temp+1。 =39。039。 end if。 end if。 end if。 count10=temp。 end process。 end art。 2)、 六進(jìn)制計(jì)數(shù)器 library ieee。 use 。 use 。 entity cdu6 is port(clk,clr,en: in std_logic。 : out std_logic。 count6: out std_logic_vector(3 downto 0))。 end cdu6。 architecture art of cdu6 is signal temp:std_logic_vector(3 downto 0)。 begin process(clk,clr) begin if clr=39。139。 then temp=0000。 =39。039。 elsif (clk39。event and clk=39。139。) then if en=39。139。 then if temp=0110 then temp=0000。 =39。139。 else temp=temp+1。 =39。039。 end if。 end if。 end if。 count6=temp。 end process。 end art。 3) 計(jì)時(shí)器程序 library ieee。 use 。 entity count is port(clk:in std_logic。 clr:in std_logic。 en:in std_logic。 S_10ms:out std_logic_vector(3 downto 0)。 S_100ms:out std_logic_vector(3 downto 0)。 S_1s:out std_logic_vector(3 downto 0)。 S_10s:out std_logic_vector(3 downto 0)。 M_1min:out std_logic_vector(3 downto 0)。 M_10min:out std_logic_vector(3 downto 0))。