【正文】
Change: 計(jì)數(shù)脈沖輸入端。Mod[1..0]: 模式。計(jì)數(shù)器控制模塊符號(hào)圖如圖451所示圖451 計(jì)數(shù)器控制模塊符號(hào)圖端口說(shuō)明:Reset: 復(fù)位信號(hào)輸入端。end a。 end if。 else clk_out = 39。 process (tQ) begin if tQ 100 then clk_out = 39。 end if。begin process(clk) begin if (rising_edge(clk)) then tQ(2 downto 1) = tQ(1 downto 0)。end。entity john_6 is port (clk : in std_logic。use . all。分頻器原理圖如圖441所示圖441分頻器原理圖分頻器模塊圖如圖441所示圖441分頻器模塊圖六分頻模塊符號(hào)圖如圖442所示圖442六分頻模塊符號(hào)圖六分頻模塊代碼:library ieee。此模塊以48MHZ頻率輸入,輸出1HZ和1KHZ兩種頻率。顯示譯碼模塊仿真圖如圖432所示圖432顯示譯碼模塊仿真圖 分頻器模塊分頻器模塊提供各種頻率的時(shí)鐘信號(hào)源,這次設(shè)計(jì)采用的實(shí)驗(yàn)板晶振頻率為48M,必須經(jīng)過(guò)分頻才能為各模塊提供時(shí)鐘。 end process。 when others = null。 when x8 = data_out = x7f。 when x6 = data_out = x7d。 when x4 = data_out = x66。 when x2 = data_out = x5b。 顯示譯碼 process (data) begin case (data) is when x0 = data_out = x3f。 end case。 data = data_in(23 downto 20)。 data = data_in(19 downto 16)。 data = data_in(15 downto 12)。 data = data_in(11 downto 8)。 data = data_in(7 downto 4)。 data = data_in(3 downto 0)。 end process。 if (num = 6) then num = 000。) then num = num + 1。event and clk=39。signal data : std_logic_vector (3 downto 0)。end。 數(shù)碼管掃描時(shí)鐘 data_out : out std_logic_vector (7 downto 0)。 數(shù)碼管顯示譯碼 六位數(shù)碼管 時(shí),分,秒高低各兩位 24位數(shù)據(jù)輸入(每位數(shù)碼管對(duì)應(yīng)四位數(shù)據(jù)), 動(dòng)態(tài)顯示六位數(shù)碼管entity disp_decode is port (data_in : in std_logic_vector (23 downto 0)。use 。顯示譯碼模塊代碼:library ieee。Data_out[7..0]: 數(shù)碼管段數(shù)據(jù)輸出。比較器模塊功能仿真圖如圖4210所示圖4210比較器模塊功能仿真圖 顯示譯碼模塊顯示譯碼模塊如圖431所示圖431 顯示譯碼模塊端口說(shuō)明:Data_in[23..0]: 六位數(shù)碼管數(shù)據(jù)輸入端。 end process。039。139。end。entity par_1 is port (data : in std_logic_vector(7 downto 0)。use 。比較器模塊代碼:library ieee。 數(shù)據(jù)選擇器功能仿真圖如圖428所示圖428據(jù)選擇器功能仿真圖(4)比較器模塊比較器模塊符號(hào)圖如圖429所示圖429比較器模塊符號(hào)圖端口說(shuō)明:Data[7..0] : 分鐘數(shù)據(jù)輸入端。 end process。 else qout = b。039。end。 s : in std_logic。use 。S:計(jì)數(shù)時(shí)鐘輸入選擇端,s=0輸入端為a,否則為b。B: 按鍵置數(shù)輸入端。end。 dout_l = num1。 end if。 end if。 num1 = 0000。 if (num2=0010 and num1 = 0011) then cout = 39。 num2 = num2 +1。 if num11001 then num1 = num1 + 1。) then cout = 39。event and clk_1 = 39。039。 num2 = 0000。039。signal num2 : std_logic_vector (3 downto 0)。end。 dout_l : out std_logic_vector (3 downto 0)。 clr : in std_logic。use 。24進(jìn)制計(jì)數(shù)器代碼:library ieee。Cout:計(jì)數(shù)器進(jìn)位輸出端Dout_l[3..0]: 計(jì)數(shù)值低四位輸出端(時(shí)低位)。24進(jìn)制計(jì)數(shù)器模塊符號(hào)圖如圖425所示圖425 24進(jìn)制計(jì)數(shù)器模塊符號(hào)圖端口說(shuō)明:Clk_1: 計(jì)數(shù)時(shí)鐘輸入端。end。 dout_l = num1。 end if。 end if。139。 else num2 = 0000。 else num1 = 0000。039。139。 else if (clk_139。 cout = 39。 ) then num1 = 0000。begin process (clk_1, clr) begin if (clr =39。architecture bhv of counter_60 issignal num1 : std_logic_vector (3 downto 0)。 dout_h : out std_logic_vector (3 downto 0) )。 cout : out std_logic。entity counter_60 is port (clk_1 : in std_logic。use 。Dout_h[3..0]: 計(jì)數(shù)值高四位輸出端(秒或分高位)。Clr: 計(jì)數(shù)器清零端。(1)60進(jìn)制計(jì)數(shù)器模塊:60進(jìn)制計(jì)數(shù)器用于秒和分計(jì)數(shù),clr清零計(jì)數(shù)器。S_minute:計(jì)數(shù)器計(jì)數(shù)時(shí)鐘選擇端,當(dāng)S_minute=0時(shí)計(jì)數(shù)時(shí)鐘為Clk_1,當(dāng)S_minute=1時(shí)計(jì)數(shù)時(shí)鐘為Set_minute。Set_minute: 時(shí)鐘分鐘設(shè)置輸入端。比較器用于檢測(cè)分計(jì)數(shù)器是否位零,當(dāng)為零時(shí),即到了整點(diǎn),比較器會(huì)輸出1分鐘高電平。此模塊由60進(jìn)制計(jì)數(shù)器,24進(jìn)制計(jì)數(shù)器,數(shù)據(jù)選擇器,比較器構(gòu)成。end。 end if。139。 else count = 000。139。039。 end if。 then if count=5 then count = count。) then if key_in=39。event an