這里說(shuō)得很詳細(xì): 參考資料:
給你發(fā)一段
數(shù)碼管的掃描顯示:LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL; -字模輸出模塊
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY SEL IS PORT(CLK:IN STD_LOGIC; Q:OUT STD_LOGIC_VECTOR(2 DOWNTO 0)); --輸入選通信號(hào)END SEL;ARCHITECTURE SELA OF SEL ISBEGIN PROCESS(CLK) VARIABLE CNT:STD_LOGIC_VECTOR(2 DOWNTO 0); BEGIN IF CLK'EVENT AND CLK='1' THEN CNT:=CNT+1; END IF; Q
2. 微秒模塊 采用VHDL語(yǔ)言輸入方式,以時(shí)鐘clk,清零信號(hào)clr以及暫停信號(hào)STOP為進(jìn)程敏感變量,程序如下:library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity MINSECONDb is port(clk,clrm,stop:in std_logic;----時(shí)鐘/清零信號(hào) secm1,secm0:out std_logic_vector(3 downto 0);----秒高位/低位 co:out std_logic);-------輸出/進(jìn)位信號(hào) end MINSECONDb; architecture SEC of MINSECONDb is signal clk1,DOUT2:std_logic; begin process(clk,clrm) variable cnt1,cnt0:std_logic_vector(3 downto 0);---計(jì)數(shù) VARIABLE COUNT2 :INTEGER RANGE 0 TO 10 ; begin IF CLK'EVENT AND CLK='1'THEN IF COUNT2>=0 AND COUNT2<10 THEN COUNT2:=COUNT2+1; ELSE COUNT2:=0; DOUT2<= NOT DOUT2; END IF; END IF; if clrm='1' then----當(dāng)clr為1時(shí),高低位均為0 cnt1:="0000"; cnt0:="0000"; elsif clk'event and clk='1' then if stop='1' then cnt0:=cnt0; cnt1:=cnt1; end if; if cnt1="1001" and cnt0="1000" then----當(dāng)記數(shù)為98(實(shí)際是經(jīng)過(guò)59個(gè)記時(shí)脈沖) co<='1';----進(jìn)位 cnt0:="1001";----低位為9 elsif cnt0<"1001" then----小于9時(shí) cnt0:=cnt0+1;----計(jì)數(shù)--elsif cnt0="1001" then--clk1<=not clk1; else cnt0:="0000"; if cnt1<"1001" then----高位小于9時(shí) cnt1:=cnt1+1; else cnt1:="0000"; co<='0'; end if; end if; end if; secm1<=cnt1; secm0<=cnt0; end process; end SEC;3. 秒模塊程序清單 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity SECOND is port(clk,clr:in std_logic;----時(shí)鐘/清零信號(hào) sec1,sec0:out std_logic_vector(3 downto 0);----秒高位/低位 co:out std_logic);-------輸出/進(jìn)位信號(hào) end SECOND; architecture SEC of SECOND is begin process(clk,clr) variable cnt1,cnt0:std_logic_vector(3 downto 0);---計(jì)數(shù) begin if clr='1' then----當(dāng)ckr為1時(shí),高低位均為0 cnt1:="0000"; cnt0:="0000"; elsif clk'event and clk='1' then if cnt1="0101" and cnt0="1000" then----當(dāng)記數(shù)為58(實(shí)際是經(jīng)過(guò)59個(gè)記時(shí)脈沖) co<='1';----進(jìn)位 cnt0:="1001";----低位為9 elsif cnt0<"1001" then----小于9時(shí) cnt0:=cnt0+1;----計(jì)數(shù) else cnt0:="0000"; if cnt1<"0101" then----高位小于5時(shí) cnt1:=cnt1+1; else cnt1:="0000"; co<='0'; end if; end if; end if; sec1<=cnt1; sec0<=cnt0; end process; end SEC;4. 分模塊程序清單 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity MINUTE is port(clk,en:in std_logic; min1,min0:out std_logic_vector(3 downto 0); co:out std_logic); end MINUTE; architecture MIN of MINUTE is begin process(clk) variable cnt1,cnt0:std_logic_vector(3 downto 0); begin if clk'event and clk='1' then if en='1' then if cnt1="0101" and cnt0="1000" then co<='1'; cnt0:="1001"; elsif cnt0<"1001" then cnt0:=cnt0+1; else cnt0:="0000"; if cnt1<"0101" then cnt1:=cnt1+1; else cnt1:="0000"; co<='0'; end if; end if; end if; end if; min1<=cnt1; min0<=cnt0; end process; end MIN;5. 時(shí)模塊程序清單 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity HOUR is port(clk,en:in std_logic;----輸入時(shí)鐘/高電平有效的使能信號(hào) h1,h0:out std_logic_vector(3 downto 0));----時(shí)高位/低位 end HOUR; architecture hour_arc of HOUR is begin process(clk) variable cnt1,cnt0:std_logic_vector(3 downto 0);----記數(shù) begin if clk'event and clk='1' then---上升沿觸發(fā) if en='1' then---同時(shí)“使能”為1 if cnt1="0010" and cnt0="0011" then cnt1:="0000";----高位/低位同時(shí)為0時(shí) cnt0:="0000"; elsif cnt0<"1001" then----低位小于9時(shí),低位記數(shù)累加 cnt0:=cnt0+1; else cnt0:="0000"; cnt1:=cnt1+1;-----高位記數(shù)累加 end if; end if; end if; h1<=cnt1; h0<=cnt0; end process; end hour_arc; 6. 動(dòng)態(tài)掃描模塊 library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity SELTIME is port( clk:in std_logic;------掃描時(shí)鐘 secm1,secm0,sec1,sec0,min1,min0,h1,h0:in std_logic_vector(3 downto 0);-----分別為秒個(gè)位/時(shí)位;分個(gè)位/ daout:out std_logic_vector(3 downto 0);----------------輸出 sel:out std_logic_vector(2 downto 0));-----位選信號(hào) end SELTIME; architecture fun of SELTIME is signal count:std_logic_vector(2 downto 0);----計(jì)數(shù)信號(hào) begin sel="111") then count<="000"; else countdaoutdaoutdaoutdaoutdaoutdaoutdaoutdaout<=h1; end case; end process; end fun;7. 報(bào)時(shí)模塊 library ieee; use ieee.std_logic_1164.all; 。
我不是學(xué)姐,答案我就不幫你做了,給你一些提示,希望你能獨(dú)立完成。
1:先選對(duì)計(jì)數(shù)器,根據(jù)需要選擇4位,8位,32位(如果沒(méi)有32位的計(jì)數(shù)器可以用2個(gè)16位的計(jì)數(shù)器級(jí)聯(lián)起來(lái),第一級(jí)的計(jì)數(shù)器的高位輸出驅(qū)動(dòng)第二級(jí)的計(jì)數(shù)器始終)2:10進(jìn)制,12進(jìn)制,60進(jìn)制的計(jì)數(shù)器怎么做?你需要一個(gè)比較器,比較器輸入端比較counter的值和一個(gè)preset value,如果兩個(gè)值相等,則輸出一,否則輸出0,用這個(gè)比較信號(hào)來(lái)控制counter的復(fù)位信號(hào),注意有些復(fù)位是低電平有效3:有了上面的這些計(jì)數(shù)器以后怎么做時(shí)鐘?用級(jí)聯(lián)的方式把上面這些計(jì)數(shù)器串聯(lián)起來(lái),也就是說(shuō)用function generator 產(chǎn)生一個(gè)10Hz的頻率分秒的比較器輸出當(dāng)作秒的時(shí)鐘輸入(enable也可以),同樣的道理,秒的計(jì)數(shù)器的比較器出入做分的計(jì)數(shù)器的十種輸入。
我不是學(xué)姐,答案我就不幫你做了,給你一些提示,希望你能獨(dú)立完成。
1:先選對(duì)計(jì)數(shù)器,根據(jù)需要選擇4位,8位,32位(如果沒(méi)有32位的計(jì)數(shù)器可以用2個(gè)16位的計(jì)數(shù)器級(jí)聯(lián)起來(lái),第一級(jí)的計(jì)數(shù)器的高位輸出驅(qū)動(dòng)第二級(jí)的計(jì)數(shù)器始終)
2:10進(jìn)制,12進(jìn)制,60進(jìn)制的計(jì)數(shù)器怎么做?
你需要一個(gè)比較器,比較器輸入端比較counter的值和一個(gè)preset value,如果兩個(gè)值相等,則輸出一,否則輸出0,用這個(gè)比較信號(hào)來(lái)控制counter的復(fù)位信號(hào),注意有些復(fù)位是低電平有效
3:有了上面的這些計(jì)數(shù)器以后怎么做時(shí)鐘?
用級(jí)聯(lián)的方式把上面這些計(jì)數(shù)器串聯(lián)起來(lái),也就是說(shuō)
用function generator 產(chǎn)生一個(gè)10Hz的頻率分秒的比較器輸出當(dāng)作秒的時(shí)鐘輸入(enable也可以),同樣的道理,秒的計(jì)數(shù)器的比較器出入做分的計(jì)數(shù)器的十種輸入。
聲明:本網(wǎng)站尊重并保護(hù)知識(shí)產(chǎn)權(quán),根據(jù)《信息網(wǎng)絡(luò)傳播權(quán)保護(hù)條例》,如果我們轉(zhuǎn)載的作品侵犯了您的權(quán)利,請(qǐng)?jiān)谝粋€(gè)月內(nèi)通知我們,我們會(huì)及時(shí)刪除。
蜀ICP備2020033479號(hào)-4 Copyright ? 2016 學(xué)習(xí)鳥(niǎo). 頁(yè)面生成時(shí)間:2.555秒