【正文】
低位 miao_bian2=0000。 architecture one of miao is signal miao_bian1,miao_bian2:std_logic_vector(3 downto 0)。 entity miao is port(clk,rest:in std_logic。 end four。 6 end if。139。 architecture four of fenpin is signal D:std_logic。 5 use 。秒位達(dá) 59 時(shí)進(jìn)位分位,分位達(dá) 59 時(shí)進(jìn)位到時(shí)位,時(shí)位到 23 時(shí)則自動(dòng)清零,用了兩個(gè)按鍵對時(shí)間的時(shí)位和分位進(jìn)行了預(yù)置(即校時(shí)校分),一個(gè)按鍵( rest)可清零,且各個(gè)計(jì)數(shù)器的計(jì)數(shù)都通過數(shù)碼管顯示出來。 本文使用 VHDL 硬件描述語言設(shè)計(jì)了一個(gè)電子鐘系統(tǒng),該系統(tǒng)在開發(fā)軟件 Quartus Ⅱ 環(huán)境中設(shè)計(jì)完成,并下載到 EP1K30TC1443FPGA 的實(shí)驗(yàn)箱并成功,本文給出了設(shè)計(jì)該數(shù)字系統(tǒng)的流程。 關(guān)鍵詞 : EDA 電子鐘 校時(shí) 分頻 VHDL 語言 一:設(shè)計(jì)功能要求: 用 65536HZ 的頻率作為系統(tǒng)的時(shí)鐘,對其進(jìn)行分頻產(chǎn)生秒信號,再對秒信號進(jìn)行計(jì)數(shù),產(chǎn)生分、時(shí),并顯示小時(shí)、分鐘和秒的實(shí)際值。 4 三、 設(shè)計(jì)總體 RTL 圖 四、程序設(shè)計(jì) 本設(shè)計(jì)采用模塊化設(shè)計(jì),共六個(gè)模塊,分為:分頻器模塊、秒位計(jì)數(shù)器模塊、分位計(jì)數(shù)器模塊、時(shí)位計(jì)數(shù)器模塊、校準(zhǔn)模塊(預(yù)置時(shí)和分)、頂層文件模塊。 entity fenpin is 數(shù)控分頻器 port(clk:in std_logic。 begin process(clk) variable bianliang:std_logic_vector(15 downto 0)。 then if bianliang=1000000000000000 65536/2 then bianliang:=0000000000000000。 end if。 分頻器仿真波形圖如圖 12 圖 12 分頻器仿真波形圖 秒計(jì)數(shù)器模塊 圖 21 秒計(jì)數(shù)器實(shí)體圖 7 library ieee。 時(shí)鐘、復(fù)位 miao_diwei,miao_gaowei:out std_logic_vector(3 downto 0)。 定義兩個(gè)信號 begin process(clk,rest) begin if rest=39。 高位 elsif clk39。 if miao_bian2=0101then 秒高位到 5 時(shí)清零 miao_bian2=0000。 秒低位沒到 9 時(shí)加 1 end if。039。 miao_diwei=miao_bian1。 原理同秒計(jì)數(shù)器的一樣 use 。 fen_out:out std_logic)。039。event and clk=39。 else fen_bian2=fen_bian2+1。 if fen_bian1=1001 and fen_bian2=0101then fen_out=39。 end if。 fen_gaowei=fen_bian2。 use 。 architecture three of