【正文】
而這些知識只能靠自己動手才能去體會。對EDA設計流程和設計思想也有了更深的體會,特別是自頂向下的設計思想,把一個個復雜的模塊劃分成一個個簡單的模塊,看似復雜也會變的簡單。但最終還是堅持下來了。(3)電子鐘計數(shù)初值不為零,分鐘和時鐘上電后為1,而按鍵turn切換會導致時鐘計數(shù)器自加,但鬧鐘計數(shù)器正常。進過分析和排除最終確定問題出在分頻計數(shù)器上,由于輸入為48MHZ,頻率比較大,會導致計數(shù)器出現(xiàn)尖峰脈沖,最后用約翰遜計數(shù)器替代掉普通計數(shù)器解決問題。 end if。 ld_h = 39。 when others = null。039。 end if。 else ld_m = 39。) then ld_m = 39。 then ld_alert = 39。139。039。039。039。039。end。 ld_h : out std_logic。 modl : in std_logic_vector (1 downto 0)。use 。Modl[1..0]:模式。顯示輸出控制模塊功能仿真圖如圖4513所示圖4513顯示輸出控制模塊功能仿真圖 led控制模塊顯示當前狀態(tài),當正常計數(shù)時ld_h,ld_m,ld_alert全滅;當設置時間時ld_alert滅,ld_h,ld_m顯示當前設置為時鐘還是分鐘(clk為1);當設置鬧鐘時ld_alert亮,ld_h,ld_m顯示當前設置為時鐘還是分鐘(clk和clk1都為1)。 else dout_disp = din_b。 end process。139。 model : in std_logic_vector (1 downto 0) )。use 。Dout_disp[23..0]:待顯示數(shù)據(jù)輸出端。鬧鐘模塊功能仿真圖如圖4511所示 圖4511鬧鐘模塊功能仿真圖 顯示輸出控制模塊顯示數(shù)據(jù)有兩路,時鐘定時器模塊和鬧鐘定時器模塊數(shù)據(jù),具體顯示那一路,通過model[1..0]信號選擇(按鍵a, b)。039。 when others = beep_out = 39。) then beep_out = clk_1k。) then case (modl) is when 00 = if (alarm = 39。 reset1 : in std_logic )。 modl : in std_logic_vector (1 downto 0)。use 。 end if。architecture bhv of par isbegin process (out_a, out_b) begin if (out_a = out_b) then _out = 39。entity par is port (out_a : in std_logic_vector(15 downto 0)。比較器模塊符號圖如圖458所示圖458比較器模塊符號圖比較器模塊代碼:library ieee。Reset: 全局復位信號。比較器和一個由時鐘計數(shù)器的整點信號經(jīng)過一個或門產(chǎn)生鬧鐘信號;鬧鐘模塊根據(jù)按鍵狀態(tài)及鬧鐘信號決定蜂鳴器是否發(fā)聲。139。 end if。architecture bhv of alarm_set isbegin process (modl, turn, change) begin case (modl) is when 10 = if (turn = 39。 change : in std_logic。use 。 end process。139。) then clkout_minute_t = change。 end if。 minute_s = 39。 when 10 = clk_disp = clk_1。 minute_s = 39。 hour_s = 39。139。 clkout_hour_t : out std_logic。 hour_s :out std_logic。entity control_counter is port (reset : in std_logic。計數(shù)器控制模塊代碼:library ieee。Clk_disp: 時鐘計數(shù)器時鐘信號提供端。Clk_1: 1HZ時鐘信號輸入端。 end process。039。 tQ(0) = not tQ(2)。 clk_out : buffer std_logic )。use . all。由于晶振頻率較大,故分頻所用的計數(shù)器為約翰遜計數(shù)器。 end case。 when x7 = data_out = x07。 when x3 = data_out = x4f。 end process。 when 101 = select_wei = 011111。 when 011 = select_wei = 110111。 when 001 = select_wei = 111101。 end if。139。architecture bhv of disp_decode issignal num : std_logic_vector(2 downto 0)。 顯示數(shù)據(jù)輸入 clk : in std_logic。use 。Clk: 數(shù)碼管掃描時鐘。 end if。architecture bhv of par_1 isbegin process (data) begin if (data = 00000000) then _out = 39。use 。Com_out: 當整點是_out會輸出一分鐘高電平。 end if。 architecture bhv of mux21b isbegin process (s) begin if s=39。entity mux21b is port (a, b : in std_logic。Qout: 計數(shù)脈沖輸出端。 dout_h = num2。 end if。139。 else num1 = 0000。139。 cout = 39。begin process (clk_1, clr) begin if (clr =39。 dout_h : out std_logic_vector (3 downto 0) )。entity counter_24 is port (clk_1 : in std_logic。Dout_h[3..0]: 計數(shù)值高四位輸出端(時高位)。60進制計數(shù)器功能仿真圖如圖424所示圖62460進制計數(shù)器功能仿真圖(2)24進制計數(shù)器模塊構(gòu)成時計數(shù)器,clr清零計數(shù)器。 end process。 end if。 if num2 0101 then num2 = num2 +1。) then cout = 39。039。039。end。 clr : in std_logic。60進制計數(shù)器代碼library ieee。60進制計數(shù)器模塊符號圖如圖423所示圖423 60進制計數(shù)器模塊符號圖端口說明:Clk_1: 計數(shù)時鐘輸入端。Set_hour: 時鐘