【文章內(nèi)容簡(jiǎn)介】
十四進(jìn)制計(jì)數(shù)器電路組成。在整個(gè)時(shí)鐘中最關(guān)鍵的是如何獲得一個(gè)精確的 1HZ計(jì)時(shí)脈沖, 數(shù)字時(shí)鐘顯示由時(shí)( 24 進(jìn)制)、分( 60 進(jìn)制)、秒( 60 進(jìn)制)組成,利用掃描顯示譯碼電路在八個(gè)數(shù)碼管顯示。 數(shù)字時(shí)鐘組成及功能: 分頻率器:用來(lái)產(chǎn)生 1HZ計(jì)時(shí)脈沖; 二十四進(jìn)制計(jì)數(shù)器:對(duì)時(shí)進(jìn)行計(jì)數(shù) 六十進(jìn)制計(jì)數(shù)器:對(duì)分和秒進(jìn)行計(jì)數(shù); 掃描顯示譯碼器:完成對(duì) 7字段數(shù)碼管顯示的控制; 報(bào)時(shí)器:完成到時(shí)的提醒; 設(shè)計(jì)內(nèi) 容及步驟: 根據(jù)電路持點(diǎn),用層次設(shè)計(jì)概念。將此設(shè)計(jì)任務(wù)分成若干模塊,規(guī)定每一模塊的功能和各模塊之間的接口,同時(shí)加深層次化設(shè)計(jì)概念; 軟件的元件管理深層含義,以及模塊元件之間的連接概念,對(duì)于不同目錄下的同一設(shè)計(jì),如何熔合; 適配劃分前后的仿真內(nèi)容有何不同概念,仿真信號(hào)對(duì)象有何不同,有更深一步了解。熟悉了 CPLD/FPGA設(shè)計(jì)的調(diào)試過(guò)程中手段的多樣化; 按適配劃分后的管腳定位,同相關(guān)功能塊硬件電路接口連線; 所有模塊盡量采用 VHDL語(yǔ)言設(shè)計(jì)。 要求: 精確顯示時(shí)、分、秒。 數(shù)字時(shí)鐘要求:具有對(duì)時(shí)、分、秒置數(shù)功能(利用秒脈沖置數(shù)、鍵盤直接置數(shù)); 能夠完成整點(diǎn)報(bào)時(shí)功能。 二、數(shù)字時(shí)鐘設(shè)計(jì)方案 設(shè)計(jì)方案方框圖 功能設(shè)計(jì) 時(shí)鐘計(jì)數(shù):完成時(shí)、分、秒的正確計(jì)時(shí)并且顯示所計(jì)的數(shù)字;對(duì)秒、分 60進(jìn)制計(jì)數(shù),即從 0到 59循環(huán)計(jì)數(shù),對(duì)時(shí) 24進(jìn)制計(jì)數(shù),即從 0到 23 循環(huán)計(jì)數(shù)。 CLK 信號(hào)端 使能控制端 RESET 復(fù)位端 FPGA 芯片 時(shí)鐘程序 整點(diǎn)報(bào)時(shí) 數(shù)碼管顯示 秒顯示 分顯示 時(shí)顯示 時(shí)間設(shè)置:手動(dòng)調(diào)節(jié)分鐘( setfen)、小時(shí)( setshi),低電平時(shí)有效,可以對(duì)分、時(shí)進(jìn)行進(jìn)位調(diào)節(jié),高電平時(shí)正常計(jì)數(shù)。這樣可以對(duì)所設(shè)計(jì)的時(shí)鐘 的時(shí)間任意調(diào)。 清零功能: reset 為復(fù)位端,低電平時(shí)實(shí)現(xiàn)清零功能,高電平時(shí)正常計(jì)數(shù)。這樣可以對(duì)所設(shè)計(jì)的時(shí)鐘的時(shí)間進(jìn)行清零處理。 整點(diǎn)報(bào)時(shí)功能:當(dāng)分由 59 進(jìn)位時(shí),會(huì)在整點(diǎn)報(bào)時(shí)輸出端輸出高電平,此信號(hào)通過(guò)LED點(diǎn)亮檢驗(yàn)。 三、數(shù)字時(shí)鐘計(jì)數(shù)報(bào)時(shí) VHDL 程序設(shè)計(jì)仿真與分析 秒計(jì)數(shù)器( miao)設(shè)計(jì) 秒計(jì)數(shù)器( miao) VHDL 程序描述 library ieee。 use 。 use 。 entity miao is port( clk,reset,setfen:in std_logic。 enfen:out std_logic。 countmiao:out std_logic_vector(7 downto 0) )。 end miao。 architecture fun of miao is signal count:std_logic_vector(7 downto 0)。 signal enfen_1,enfen_2:std_logic。 begin countmiao=count。 enfen_2=((not setfen) and clk)。 enfen=(enfen_1 or enfen_2)。 process(clk,reset,setfen) begin if(reset=39。039。) then count=00000000。 enfen_1=39。039。 elsif(clk39。event and clk=39。139。) then if(count(3 downto 0)=1001) then if(count01100000) then if(count=01011001) then count=00000000。 enfen_1=39。139。 else count=count+7。 end if。 else count=00000000。 enfen_1=39。039。 end if。 elsif(count01100000) then count=count+1。 enfen_1=39。039。 else count=00000000。 end if。 end if。 end process。 end fun。 秒計(jì)數(shù)器( miao)仿真波形圖 秒計(jì)數(shù)器( miao)仿真分析 隨著 clk脈沖信號(hào)的不斷到來(lái), countmiao記錄出 clk的脈沖個(gè)數(shù),計(jì)數(shù)到 59時(shí),在下一個(gè) clk 脈沖信號(hào)到來(lái)時(shí),輸出端 enfen 輸出高定平,即向分進(jìn)位,同時(shí) countmiao清零。 reset為清零端,當(dāng) reset低電平時(shí), countmiao計(jì)數(shù)從零重新開始計(jì)數(shù)。 setfen為分的手動(dòng)進(jìn)位端,當(dāng) setfen低電平時(shí)且 clk 脈沖到來(lái)時(shí),輸出 enfen 高電平,向分進(jìn)位。 分計(jì)數(shù)器( fen)設(shè)計(jì) 分計(jì)數(shù)器( fen) VHDL 程序描述 library ieee。 use 。 use 。 entity fen is port( imiao,clk,reset,setshi:in std_logic。 enshi:out std_logic。 countfen:out std_logic_vector(7 downto 0) )。 end fen。 architecture fun of fen is signal enshi_1,enshi_2:std_logic。 signal count:std_logic_vector(7 downto 0)。 begin countfen=count。 enshi_2=((not setshi) and clk)。 enshi=(enshi_1 or enshi_2)。 process(imiao,reset,setshi) begin if(reset=39。039。) then count=00000000。 elsif(imiao39。event and imiao=39。139。) then if(count(3 downto 0)=1001) then if(count1660) then if(count=01011001) then count=00000000。 enshi_1=39。139。 else count=count+7。 end if。 else count=00000000。 end if。 elsif(count01100000) then count=count+1。 enshi_1=39。039。 else count=00000000。 end if。 end if。 end process。 end fun。 分計(jì)數(shù)器( fen)仿真波形圖 分計(jì)數(shù)器( fen)仿真分析 imiao 為秒計(jì)數(shù)器的 enfen進(jìn)位輸出端,當(dāng) enfen( imiao)高電平到來(lái)時(shí),且 clk高電平時(shí), countfen開始計(jì)數(shù)。 countfen計(jì)數(shù)到 59 時(shí),下一個(gè) enfen( imiao)、 clk到來(lái)時(shí), enshi高電平,即向時(shí)進(jìn)位,同時(shí) countfen清零。 reset為清零端,當(dāng) reset低電平時(shí), countfen計(jì)數(shù)從零重新開始計(jì)數(shù)。 setshi為時(shí)的手動(dòng)進(jìn)位端,當(dāng) setshi低電平時(shí)且 clk 脈沖到來(lái)時(shí),輸出 enshi 時(shí)高電平,向時(shí)進(jìn)位。 時(shí)計(jì)數(shù)器( shi)設(shè)計(jì) 時(shí)計(jì)數(shù)器( shi) vHDL 程序描述 library ieee。 use 。 use 。 entity shi is port( ifen,reset:in std_logic。 countshi:out std_logic_vector(7 downto 0) )。 end shi。 architecture fun of shi is signal count:std_logic_vector(7 downto 0)。 begin countshi=count。 process(ifen,reset) begin if(reset=39。039。) then count=00000000。 elsif(ifen39。event and ifen=39。139。) then if(count(3 downto 0)=1001) then if(count00100011) then count=count+7。 else count=00000000。 end if。 elsif(count00100011) then count=count+1。 else count=00000000。 end if。 end if。 end process。 end fun。 時(shí)計(jì)數(shù)器( shi)仿真波形圖 時(shí)計(jì)數(shù)器( shi)仿真分析 ifen為分計(jì)數(shù)器的 enshi進(jìn)位輸出端,當(dāng) enshi( ifen)為高電平時(shí), countshi計(jì)數(shù)。 countshi計(jì)數(shù)到 23時(shí),當(dāng)下一個(gè) enshi( ifen)、 clk到來(lái)時(shí), countshi會(huì)自動(dòng)清零。 reset為清零端,當(dāng) reset低電平時(shí), countfen計(jì)數(shù)從零重新開始計(jì)數(shù)。 整點(diǎn)報(bào)時(shí)器( baoshi)設(shè)計(jì) 整點(diǎn)報(bào)時(shí)器( baoshi) VHDL 程序描述 library ieee。 use 。 use 。 entity baoshi is port( clk:in std_logic。 inputmiao,inputfen:in std_logic_vector(7 downto 0)。 output:out std_logic )。 end baoshi。 architecture fun of baoshi is signal temp:std_logic。 signal nummiao,numfen:std_logic_vector(7 downto 0)。 begin nummiao=inputmiao。 numfen=inputfen。 output=temp。 process(clk,temp) begin if(clk39。event and clk=39。139。) then if(numfen=01011001) then case nummiao is when01011001=temp=39。139。 when others=temp=39。039。 end case。 end if。 if(numfen=00000000) then case nummiao is when00000000=temp=39。139。 when others=temp=39。039。 end case。 end if。 end if。 end process。 end fun。 整點(diǎn)報(bào)時(shí)器( baoshi)仿真波形圖 整點(diǎn)報(bào)時(shí)器( baoshi)仿真分析 input為分計(jì)數(shù)器的輸出端,當(dāng)輸出 59和 00(十六進(jìn)制)時(shí),整點(diǎn)報(bào)時(shí)器( baoshi)的輸出端 output為高電平,點(diǎn)亮 LED燈。其他情況時(shí), LED燈均不發(fā)光。 四、數(shù)字時(shí)鐘的驅(qū)動(dòng)與顯示設(shè)計(jì) 分 頻器( fenpin)設(shè)計(jì) 分頻器( fenpin)原理 由于 EDA 實(shí)驗(yàn)箱中的脈沖信號(hào)源為 10kHz,要得到需要脈沖可以通過(guò)定義count std_logic_vector(13 downto 0),使 count 在 “ 00000000000000”和“ 10011100001111”之間的轉(zhuǎn)換實(shí)現(xiàn)。 在實(shí)驗(yàn)中,時(shí)鐘脈沖 clk 為 1Hz,用于對(duì)時(shí)鐘的記數(shù);掃描顯示譯碼器的脈 沖 clk,用來(lái)驅(qū)動(dòng) 8個(gè) 7段掃描共陰級(jí)數(shù)碼顯示管。掃描顯示譯碼器的脈