目錄
一、 設(shè)計(jì)任務(wù)與要求 3
二、設(shè)計(jì)思路 4
1.1設(shè)計(jì)方案 4
1.2設(shè)計(jì)要點(diǎn) 4
1.3工作原理 4
三、程序運(yùn)行及結(jié)果 5
(1)分頻模塊 5
(2)秒模塊 6
(3)分模塊(minute) 8
(4)時(shí)模塊(hour) 10
(5)數(shù)碼顯示驅(qū)動(dòng)模塊 12
(6)片選模塊(sell) 13
(7)譯碼顯示模塊(display) 14
(8)報(bào)時(shí)模塊(alart) 15
(9)六進(jìn)制計(jì)數(shù)器模塊(cnt6) 16
(10)兩輸入與模塊(and2a) 17
(11)兩輸入或模塊(or2a) 18
四、頂層電路設(shè)計(jì)及仿真結(jié)果與分析 19
五、心得體會(huì) 22
六、參考文獻(xiàn) 23
七、 源程序 23
摘要:近年來隨著數(shù)字技術(shù)的迅速發(fā)展,各種中、大規(guī)模集成電路在數(shù)字系統(tǒng)、控制系統(tǒng)、信號(hào)處理等方面都得到了廣泛的應(yīng)用。這就迫切要求理工科大學(xué)生熟悉和掌握常用中、大規(guī)模集成電路功能及其在實(shí)際中的應(yīng)用方法,除通過實(shí)驗(yàn)教學(xué)培養(yǎng)數(shù)字電路的基本實(shí)驗(yàn)方法、分析問題和故障檢查方法以及雙蹤示波器等常用儀器使用方法等基本電路的基本實(shí)驗(yàn)技能外,還必須培養(yǎng)大學(xué)生工程設(shè)計(jì)和組織實(shí)驗(yàn)?zāi)芰Α?/font>
本次設(shè)計(jì)的目的在于培養(yǎng)學(xué)生對基本電路的應(yīng)用和掌握,使學(xué)生在實(shí)驗(yàn)原理的指導(dǎo)下,初步具備基本電路的分析和設(shè)計(jì)能力,并掌握其應(yīng)用方法;自行擬定實(shí)驗(yàn)步驟,檢查和排除故障 、分析和處理實(shí)驗(yàn)結(jié)果及撰寫實(shí)驗(yàn)報(bào)告的能力。綜合實(shí)驗(yàn)的設(shè)計(jì)目的是培養(yǎng)學(xué)生初步掌握小型數(shù)字系統(tǒng)的設(shè)計(jì)能力,包括選擇設(shè)計(jì)方案,進(jìn)行電路設(shè)計(jì)、安裝、調(diào)試等環(huán)節(jié),運(yùn)用所學(xué)知識(shí)進(jìn)行工程設(shè)計(jì)、提高實(shí)驗(yàn)技能的實(shí)踐。數(shù)字電子鐘是一種計(jì)時(shí)裝置,它具有時(shí)、分、秒計(jì)時(shí)功能和顯示時(shí)間功能;具有整點(diǎn)報(bào)時(shí)功能。 本次設(shè)計(jì)我查閱了大量的文獻(xiàn)資料,學(xué)到了很多關(guān)于數(shù)字電路方面的知識(shí),并且更加鞏固和掌握了課堂上所學(xué)的課本知識(shí),使自己對數(shù)字電子技術(shù)有了更進(jìn)一步的認(rèn)識(shí)和了解。 基本功能:能進(jìn)行正常的時(shí)、分、秒計(jì)時(shí)功能,分別由6個(gè)數(shù)碼管顯示24小時(shí),60分鐘,60秒鐘的計(jì)數(shù)器顯示。 附加功能:1)能利用硬件部分按鍵實(shí)現(xiàn)“校時(shí)”“校分”“清零”功能; 2)能利用蜂鳴器做整點(diǎn)報(bào)時(shí):當(dāng)計(jì)時(shí)到達(dá)59’59’’時(shí)開始報(bào)時(shí),鳴叫時(shí)間1秒鐘; 3)定時(shí)鬧鈴:本設(shè)計(jì)中設(shè)置的是在七點(diǎn)時(shí)進(jìn)行鬧鐘功能,鳴叫過程中,能夠進(jìn)行中斷鬧鈴工作。 二、設(shè)計(jì)思路 1.1設(shè)計(jì)方案 1、時(shí)鐘功能,具有顯示時(shí)、分、秒的功能; 2、具有整點(diǎn)報(bào)時(shí)功能,在整點(diǎn)時(shí)使用蜂鳴器進(jìn)行報(bào)時(shí),具有鬧鐘功能,鳴叫過程中,具有中斷鬧鈴功能。 1.2設(shè)計(jì)要點(diǎn) 數(shù)字鐘一般是由振蕩器、分頻器、計(jì)數(shù)器、譯碼器、顯示器等幾部分組成。這些都是數(shù)字電路中應(yīng)用最廣泛的基本電路,本設(shè)計(jì)分模塊設(shè)計(jì)實(shí)現(xiàn)各部分功能,采用軟件編程控制FPGA芯片內(nèi)部產(chǎn)生振動(dòng)周期為1s的脈沖。并將信號(hào)送入計(jì)數(shù)器進(jìn)行計(jì)算,并把累加的結(jié)果以“時(shí)”、“分”、“秒”的數(shù)字顯示出來!懊搿钡娘@示由兩級(jí)計(jì)數(shù)器和譯碼器組成的六十進(jìn)制計(jì)數(shù)電路實(shí)現(xiàn);“分”的顯示電路“秒”相同,“時(shí)”的顯示由兩級(jí)計(jì)數(shù)器和譯碼器組成的二十四進(jìn)制電路來實(shí)現(xiàn)。所有計(jì)時(shí)結(jié)果由六位數(shù)碼管顯示。 1.3工作原理 數(shù)字電子鐘由振蕩器、分頻器 計(jì)數(shù)器、譯碼顯示、報(bào)時(shí)等電路組成。振蕩器產(chǎn)生穩(wěn)定的高頻脈沖信號(hào),作為數(shù)字鐘的時(shí)間基準(zhǔn),然后經(jīng)過分頻器輸出標(biāo)準(zhǔn)秒脈沖。秒計(jì)數(shù)器滿60后向分計(jì)數(shù)器進(jìn)位,分計(jì)數(shù)器滿60后向小時(shí)計(jì)數(shù)器進(jìn)位,小時(shí)計(jì)數(shù)器按照“24翻1”規(guī)律計(jì)數(shù)。計(jì)滿后各計(jì)數(shù)器清零,重新計(jì)數(shù)。計(jì)數(shù)器的輸出分別經(jīng)譯碼器送數(shù)碼管顯示,計(jì)時(shí)出現(xiàn)誤差時(shí),可以用校時(shí)電路“校時(shí)”“校分”“清零”。秒脈沖可以通過分頻電路得到。通過報(bào)時(shí)設(shè)計(jì)模塊可以實(shí)現(xiàn)整點(diǎn)報(bào)時(shí)及定時(shí)鬧鈴,譯碼顯示由七段譯碼器完成,顯示由數(shù)碼管構(gòu)成,采用的是動(dòng)態(tài)顯示方式。數(shù)碼管動(dòng)態(tài)顯示:動(dòng)態(tài)掃描電路將計(jì)數(shù)器輸出的8421BGD碼轉(zhuǎn)換為數(shù)碼管需要的邏輯狀態(tài),并且輸出數(shù)碼管的片選信號(hào)和為選信號(hào)。所謂動(dòng)態(tài)掃描顯示方式是在顯示某一位LED 顯示塊的數(shù)據(jù)的時(shí)候,讓其它位不顯示,然后再顯示下一位的數(shù)據(jù)。只要保證每一位顯示的時(shí)間間隔不要太大,利用人眼的視覺暫留的現(xiàn)象,就可以造成各位數(shù)據(jù)同時(shí)顯示的假象。一般每一位的顯示時(shí)間為1~10ms。 三、程序運(yùn)行及結(jié)果 (1)分頻模塊(fenpin) 1)程序: library ieee; use ieee.std_logic_1164.all; entity fenpin is port(clk6:in std_logic; q1000,q5,q1:out std_logic); end fenpin; architecture ccc_arc of fenpin is signal x:std_logic; begin process(clk6) variable cnt:integer range 0 to 24999; begin if clk6'event and clk6='1' then if cnt<24999 then cnt:=cnt+1; else cnt:=0; x<=not x; end if; end if; end process; q1000<=x; process(x) variable cnt2:integer range 0 to 999; variable y:std_logic; begin if x'event and x='1' then if cnt2<999 then cnt2:=cnt2+1; q1<='0'; else cnt2:=0; q1<='1'; end if; end if; if x'event and x='1' then y:=not y; end if; q5<=y; end process; end ccc_arc; 2)仿真波形: 
- 仿真結(jié)果分析:產(chǎn)生用于計(jì)時(shí),掃描輸入,掃描顯示,以及蜂鳴器所需的各個(gè)頻率的信號(hào)。
(2)秒模塊(second) 1)程序: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity second is port (clk1,en1:in std_logic; qa:out std_logic_vector(3 downto 0); co1:out std_logic; qb:out std_logic_vector(3 downto 0)); end second; architecture cc of second is signal cout2,cout1:std_logic_vector(3 downto 0); signal mm: std_logic; begin process(clk1,en1) begin if en1='1' then cout2<="0000";cout1<="0000"; elsif (clk1'event and clk1='1')then if (cout2=5 and cout1=8) then cout2<=cout2;cout1<=cout1+1;mm<='1'; elsif (cout2=5 and cout1=9) then cout2<="0000";cout1<="0000";mm<='0'; else if (cout1=9) then cout2<=cout2+1;cout1<="0000";mm<='0'; else cout2<=cout2;cout1<=cout1+1;mm<='0'; end if; end if; end if; end process; co1<=mm; qa<=cout2; qb<=cout1; end cc; 2)仿真波形: 

- 仿真結(jié)果分析:該模塊實(shí)際是一個(gè)六十進(jìn)制計(jì)數(shù)器,而六十秒為一分鐘,故用此模塊可以作為秒部分設(shè)計(jì),通過觀察可知,仿真波形是正確可行的。
(3)分模塊(minute) 1)程序: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity minute is port (clk2,en2:in std_logic; qc:out std_logic_vector(3 downto 0); co2:out std_logic; qd:out std_logic_vector(3 downto 0)); end minute; architecture bb of minute is signal cout2,cout1:std_logic_vector(3 downto 0); signal cc:std_logic; begin process(clk2,en2) begin if en2='1' then if (clk2'event and clk2='1')then if (cout2=5 and cout1=8) then cout2<=cout2;cout1<=cout1+1;cc<='1'; elsif (cout2=5 and cout1=9) then cout2<="0000";cout1<="0000";cc<='0'; else if (cout1=9) then cout2<=cout2+1;cout1<="0000";cc<='0'; else cout2<=cout2;cout1<=cout1+1;cc<='0'; end if; end if; end if; end if; end process; co2<=cc; qc<=cout2; qd<=cout1; end bb 2)仿真波形: 

- 仿真結(jié)果分析:此模塊實(shí)際也是一個(gè)六十進(jìn)制的計(jì)數(shù)器模塊,六十分鐘即為一個(gè)小時(shí),用此模塊就成功解決了分設(shè)計(jì)模塊這個(gè)難題。從仿真波形可知,該設(shè)計(jì)時(shí)正確的。
(4)時(shí)模塊(hour) 1)程序: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity hour is port (clk3,en3:in std_logic; qe:out std_logic_vector(3 downto 0); qf:out std_logic_vector(3 downto 0)); end hour; architecture aa of hour is signal cout2,cout1:std_logic_vector(3 downto 0); begin process(clk3,en3) begin if en3='1' then if (clk3'event and clk3='1')then if (cout2=2 and cout1=3) then cout2<="0000";cout1<="0000"; else if (cout1=9) then cout2<=cout2+1;cout1<="0000"; else cout2<=cout2;cout1<=cout1+1; end if; end if; end if; end if; end process; qe<=cout2; qf<=cout1; end aa; 2)仿真波形: 

- 仿真結(jié)果分析:這是一個(gè)24計(jì)數(shù)器,用來表示24小時(shí),通過波形可知,程序設(shè)計(jì)正確,正常計(jì)時(shí)是每次清零后從00:00:00開始計(jì)時(shí)的,若要從預(yù)置時(shí)間開始,可以通過“校時(shí)”“校分”“清零”三個(gè)按鍵調(diào)整時(shí)間。
(5)數(shù)碼顯示驅(qū)動(dòng)模塊 1)程序: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity hhh is port(n1,n2,n3,n4,n5,n6:in std_logic_vector(3 downto 0); a:in std_logic_vector(2 downto 0); qqq:out std_logic_vector(3 downto 0)); end hhh; architecture dd of hhh is begin with a select qqq<=n1 when "000", n2 when "001", n3 when "010", n4 when "011", n5 when "100", n6 when "101", "0000" when others; end dd; 2)仿真波形: 
- 仿真結(jié)果分析:其實(shí)這是一個(gè)選擇器,從波形圖可以很容易看出來。它是用來選擇需要顯示的數(shù)字,比如秒的十位,就會(huì)選擇n1到譯碼顯示器顯示出來,具備驅(qū)動(dòng)數(shù)碼管的作用!
(6)片選模塊(sell) 1)程序: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity ggg is port(m:in std_logic_vector(2 downto 0); b:out std_logic_vector(5 downto 0)); end ggg; architecture ee of ggg is begin with m select b<="100000" when "000", "010000" when "001", "001000" when "010", "000100" when "011", "000010" when "100", "000001" when "101", "000000" when others; end ee; 2)仿真波形: 
- 仿真結(jié)果分析:設(shè)置時(shí)間時(shí)將所需的數(shù)據(jù)傳給顯示模塊,當(dāng)設(shè)置鬧鈴時(shí)將數(shù)據(jù)傳給鬧鐘和顯示模塊。
(7)譯碼顯示模塊(display) 1)程序: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity decoder is port(x:in std_logic_vector(3 downto 0); y:out std_logic_vector(6 downto 0)); end decoder; architecture one of decoder is begin with x select y<="1111110" when "0000", "0110000" when "0001", "1101101" when "0010", "1111001" when "0011", "0110011" when "0100", "1011011" when "0101", "1011111" when "0110", "1110000" when "0111", "1111111" when "1000", "1111011" when "1001", "0000000" when others; end one; 2)仿真波形: 

- 仿真結(jié)果分析:此模塊是用來顯示時(shí)間的,采用動(dòng)態(tài)顯示方式。
(8)報(bào)時(shí)模塊(alart) 1) 程序: library ieee; use ieee.std_logic_1164.all; entity sst is port(h1,h0,m1,m0,s1,s0:in std_logic_vector(3 downto 0); clk4:in std_logic; q500:out std_logic); end sst; architecture sss of sst is begin process(clk4,m1,m0,s1,s0) begin if (clk4'event and clk4='1') then if ((h1="0000" and h0="0111" and m1="0000" and m0="0000") or (m1="0101" and m0="1001" and s1="0101" and s0="1001"))then q500<='1'; else q500<='0'; end if; end if; end process; end sss; 2) 仿真波形: 
- 仿真結(jié)果分析:通過觀察波形可知,當(dāng)時(shí)鐘時(shí)間與整點(diǎn)或鬧鈴預(yù)設(shè)時(shí)間相同時(shí),給出一個(gè)脈沖信號(hào),使蜂鳴器鳴叫,實(shí)現(xiàn)整點(diǎn)報(bào)時(shí)和定時(shí)鬧鈴功能。
(9)六進(jìn)制計(jì)數(shù)器模塊(cnt6) 1)程序: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity cnt6 is port (clk5:in std_logic; n:out std_logic_vector(2 downto 0)); end cnt6; architecture behav of cnt6 is signal q1:std_logic_vector(2 downto 0); begin process(clk5) begin if clk5'event and clk5='1' then if q1<5 then q1<=q1+1; else q1<=(others=>'0'); end if; end if; end process; n<=q1; end behav; 2)仿真波形: 
- 仿真結(jié)果分析:很明顯可以看出這是一個(gè)簡單的六進(jìn)制計(jì)數(shù)器。它與3-6譯碼器配合作用產(chǎn)生片選信號(hào)。
(10)兩輸入與模塊(and2a) 1)程序: library ieee; use ieee.std_logic_1164.all; entity anda is port (a1,b1:in std_logic; y:out std_logic); end anda; architecture an of anda is begin y<=a1 and b1; end an; 2)仿真波形: 
3) 仿真結(jié)果分析:經(jīng)觀察波形,程序正確。該與門的兩個(gè)輸入端分別為秒模塊和分模塊的進(jìn)位輸出信號(hào),當(dāng)它們均為高電平時(shí),時(shí)模塊使能端即為高電平,時(shí)模塊工作。 (11)兩輸入或模塊(or2a) 1)程序: library ieee; use ieee.std_logic_1164.all; entity or_1 is port (a1,b1:in std_logic; y:out std_logic); end or_1; architecture oo of or_1 is begin y<=a1 or b1; end oo; 2)仿真波形: 
3) 仿真結(jié)果分析:在整個(gè)數(shù)字鐘程序設(shè)計(jì)中,兩處用到兩輸入或門。一處是分模塊,或門兩輸入分別是秒模塊的進(jìn)位輸出信號(hào)和外部校分信號(hào),任一一個(gè)信號(hào)為高電平,分模塊使能端就為高電平,分模塊工作。另一處是在時(shí)模塊的使能端,它受分模塊進(jìn)位輸出和外部校時(shí)信號(hào)輸入的控制,只要其一位高電平,時(shí)模塊都將工作。 四、頂層電路設(shè)計(jì)及仿真結(jié)果與分析 - library ieee;
- use ieee.std_logic_1164.all;
- entity digital_clock is
- port(clk,sa,sb,sc:in std_logic;
- q1:out std_logic;
- r:out std_logic_vector(5 downto 0);
- q0:out std_logic_vector(6 downto 0));
- end digital_clock;
- architecture main of digital_clock is
- component anda
- port(a1,b1:in std_logic;
- y:out std_logic);
- end component;
- component or_1
- port(a1,b1:in std_logic;
- y:out std_logic);
- end component;
- component fenpin
- port(clk6:in std_logic;
- q1000,q1,q5:out std_logic);
- end component;
- component hour
- port (clk3,en3:in std_logic;
- qe:out std_logic_vector(3 downto 0);
- qf:out std_logic_vector(3 downto 0));
- end component;
- component minute
- port (clk2,en2:in std_logic;
- qc:out std_logic_vector(3 downto 0);
- co2:out std_logic;
- qd:out std_logic_vector(3 downto 0));
- end component;
- component second
- port (clk1,en1:in std_logic;
- qa:out std_logic_vector(3 downto 0);
- co1:out std_logic;
- qb:out std_logic_vector(3 downto 0));
- end component;
- component sst is
- port(h1,h0,m1,m0,s1,s0:in std_logic_vector(3 downto 0);
- clk4:in std_logic;
- q500:out std_logic);
- end component;
- component hhh
- port(n1,n2,n3,n4,n5,n6:in std_logic_vector(3 downto 0);
- a:in std_logic_vector(2 downto 0);
- qqq:out std_logic_vector(3 downto 0));
- end component;
- component ggg
- port(m:in std_logic_vector(2 downto 0);
- b:out std_logic_vector(5 downto 0));
- end component;
- component cnt6 is
- port (clk5:in std_logic;
- n:out std_logic_vector(2 downto 0));
- end component;
- component decoder
- port(x:in std_logic_vector(3 downto 0);
- y:out std_logic_vector(6 downto 0));
- end component;
- signal a,b,c,h, i,j,z:std_logic;
- signal k,l,e,f,u,v,t:std_logic_vector(3 downto 0);
- signal s: std_logic_vector(2 downto 0);
- begin
- u1:fenpin port map(clk6=>clk,q1=>h,q1000=>z);
- u2:second port map(clk1=>h,en1=>sc,qa=>k,qb=>l,co1=>I);
- u0:or_1 port map(a1=>i,b1=>sb,y=>a);
- u3:minute port map(clk2=>h,en2=>a,qc=>e,qd=>f,co2=>j);
- u30:anda port map(a1=>i,b1=>j,y=>b);
- u31:or_1 port map(a1=>b,b1=>sa,y=>c);
- u4:hour port map(clk3=>h,en3=>c,qe=>u,qf=>v);
- u5:sst port map(h1=>u,h0=>v,m1=>e,m0=>f,s1=>k,s0=>l,clk4=>h,q500=>q1);
- u6:hhh port map(n1=>k,n2=>l,n3=>e,n4=>f,n5=>u,n6=>v,qqq=>t,a=>s);
- u7:ggg port map(b=>r,m=>s);
- u8:cnt6 port map(n=>s,clk5=>z);
- u9:decoder port map(x=>t,y=>q0);
- end architecture main;
復(fù)制代碼

3)仿真結(jié)果分析:本次試驗(yàn)給出的頻率是50MHZ,用QUARTUS-2軟件把數(shù)字鐘的全部工作過程記錄下來不容易,故這幅圖只是其工作的一小部分。將程序下載到FPGA芯片中,并與硬件部分對應(yīng)連接好,可以驗(yàn)證到我們所預(yù)期的所有功能,故可知該頂層文件是正確的,每一個(gè)模塊的功能也都是正確的,模塊之間的連接也都是正確的。 在軟件調(diào)試仿真過程中,我們以參考資料上的程序?yàn)槟0,依?jù)個(gè)人的需要添加修改各個(gè)功能模塊,盡管有模板作為參考,仿真過程中還是出了很多的問題,例如在做數(shù)碼管動(dòng)態(tài)顯示中,我們采用了NPN型9013晶體三極管作為數(shù)碼管的接地驅(qū)動(dòng),這里的片選信號(hào)應(yīng)該是高電平有效,我們原程序是低電平,經(jīng)過多次的和其他組的學(xué)習(xí)交流中,找到了這個(gè)錯(cuò)誤。解決分頻問題中,我們也在分頻模塊中做了修改,得到我們所需要的頻率。 五、心得體會(huì) 經(jīng)過這次的數(shù)字電路課程設(shè)計(jì),我個(gè)人得到了不少的收獲,一方面加深了我對課本理論的認(rèn)識(shí),另一方面也提高了實(shí)驗(yàn)操作能力,F(xiàn)在我總結(jié)了以下的體會(huì)和經(jīng)驗(yàn)。 這次的課程設(shè)計(jì)跟我們以前做的不同,因?yàn)槲矣X得這次我是真真正正的自己親自去完成。所以是我覺得這次實(shí)驗(yàn)最寶貴,最深刻的。就是設(shè)計(jì)的過程全是我們學(xué)生自己動(dòng)手來完成的,這樣,我們就必須要弄懂一個(gè)電路的原理。在這里我深深體會(huì)到哲學(xué)上理論對實(shí)踐的指導(dǎo)作用:弄懂實(shí)驗(yàn)原理,而且體會(huì)到了實(shí)驗(yàn)的操作能力是靠自己親自動(dòng)手,親自開動(dòng)腦筋,親自去請教別人才能得到提高的。 我們做實(shí)驗(yàn)絕對不能人云亦云,要有自己的看法,這樣我們就要有充分的準(zhǔn)備,若是做了也不知道是個(gè)什么實(shí)驗(yàn),那么做了也是白做。實(shí)驗(yàn)總是與課本知識(shí)相關(guān)的,有了課本的知識(shí),我們才能編寫出自己需要的程序,實(shí)現(xiàn)自己預(yù)期的功能。 我們做實(shí)驗(yàn)不要一成不變和墨守成規(guī),應(yīng)該有改良創(chuàng)新的精神。實(shí)際上,在弄懂了實(shí)驗(yàn)原理的基礎(chǔ)上,我們的時(shí)間是充分的,做實(shí)驗(yàn)應(yīng)該是游刃有余的,如果說創(chuàng)新對于我們來說是件難事,那改良總是有可能的。數(shù)字時(shí)鐘大體看上去很簡單,但其中的可變的地方還是有很多的,譬如說整點(diǎn)報(bào)時(shí)功能,報(bào)時(shí)持續(xù)的時(shí)間長短就是一個(gè)可變的地方。 在實(shí)驗(yàn)的過程中我們要培養(yǎng)自己的獨(dú)立分析問題,和解決問題的能力。在編程過程中,我們也遇到了很多的問題,就之前提到的動(dòng)態(tài)掃描驅(qū)動(dòng)問題,如果一味的去遵循資料上的程序的話,那整個(gè)設(shè)計(jì)將會(huì)失敗,只有不斷的學(xué)習(xí)研究,才能解決問題。 這次的課程設(shè)計(jì),我的收獲很多,就我本身來說,不但對理論知識(shí)有了更加深的理解,對于實(shí)際的操作和也有了質(zhì)的飛躍。經(jīng)過這次的實(shí)驗(yàn),我們整體對各個(gè)方面都得到了不少的提高,團(tuán)隊(duì)的合作意識(shí)也增強(qiáng)了很多。 六、參考資料: 付家才 .《 EDA工程實(shí)踐技術(shù) 》.化學(xué)工業(yè)出版社.2004年12月 陳忠平 .《 基于Quartus II的FPGA/CPLD設(shè)計(jì)與實(shí)踐 》.北京電子工業(yè)出版社.2010年4月 - library ieee;
- use ieee.std_logic_1164.all;
- entity fenpin is
- port(clk6:in std_logic;
- q1000,q5,q1:out std_logic);
- end fenpin;
- architecture ccc_arc of fenpin is
- signal x:std_logic;
- begin
- process(clk6)
- variable cnt:integer range 0 to 24999;
- begin
- if clk6'event and clk6='1' then
- if cnt<24999 then
- cnt:=cnt+1;
- else
- cnt:=0;
- x<=not x;
- end if;
- end if;
- end process;
- q1000<=x;
- process(x)
- variable cnt2:integer range 0 to 999;
- variable y:std_logic;
- begin
- if x'event and x='1' then
- if cnt2<999 then
- cnt2:=cnt2+1;
- q1<='0';
- else
- cnt2:=0;
- q1<='1';
- end if;
- end if;
- if x'event and x='1' then
- y:=not y;
- end if;
- q5<=y;
- end process;
- end ccc_arc;
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.std_logic_unsigned.all;
- entity second is
- port (clk1,en1:in std_logic;
- qa:out std_logic_vector(3 downto 0);
- co1:out std_logic;
- qb:out std_logic_vector(3 downto 0));
- end second;
- architecture cc of second is
- signal cout2,cout1:std_logic_vector(3 downto 0);
- signal mm: std_logic;
- begin
- process(clk1,en1)
- begin
- if en1='1' then
- cout2<="0000";cout1<="0000";
- elsif (clk1'event and clk1='1')then
- if (cout2=5 and cout1=8) then cout2<=cout2;cout1<=cout1+1;mm<='1';
- elsif (cout2=5 and cout1=9) then cout2<="0000";cout1<="0000";mm<='0';
- else if (cout1=9) then cout2<=cout2+1;cout1<="0000";mm<='0';
- else cout2<=cout2;cout1<=cout1+1;mm<='0';
- end if;
- end if;
- end if;
- end process;
- co1<=mm;
- qa<=cout2;
- qb<=cout1;
- end cc;
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.std_logic_unsigned.all;
- entity minute is
- port (clk2,en2:in std_logic;
- qc:out std_logic_vector(3 downto 0);
- co2:out std_logic;
- qd:out std_logic_vector(3 downto 0));
- end minute;
- architecture bb of minute is
- signal cout2,cout1:std_logic_vector(3 downto 0);
- signal cc:std_logic;
- begin
- process(clk2,en2)
- begin
- if en2='1' then
- if (clk2'event and clk2='1')then
- if (cout2=5 and cout1=8) then cout2<=cout2;cout1<=cout1+1;cc<='1';
- elsif (cout2=5 and cout1=9) then cout2<="0000";cout1<="0000";cc<='0';
- else if (cout1=9) then cout2<=cout2+1;cout1<="0000";cc<='0';
- else cout2<=cout2;cout1<=cout1+1;cc<='0';
- end if;
- end if;
- end if;
- end if;
- end process;
- co2<=cc;
- qc<=cout2;
- qd<=cout1;
- end bb
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.std_logic_unsigned.all;
- entity hour is
- port (clk3,en3:in std_logic;
- qe:out std_logic_vector(3 downto 0);
- qf:out std_logic_vector(3 downto 0));
- end hour;
- architecture aa of hour is
- signal cout2,cout1:std_logic_vector(3 downto 0);
- begin
- process(clk3,en3)
- begin
- if en3='1' then
- if (clk3'event and clk3='1')then
- if (cout2=2 and cout1=3) then cout2<="0000";cout1<="0000";
- else if (cout1=9) then cout2<=cout2+1;cout1<="0000";
- else cout2<=cout2;cout1<=cout1+1;
- end if;
- end if;
- end if;
- end if;
- end process;
- qe<=cout2;
- qf<=cout1;
- end aa;
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.std_logic_unsigned.all;
- entity hhh is
- port(n1,n2,n3,n4,n5,n6:in std_logic_vector(3 downto 0);
- a:in std_logic_vector(2 downto 0);
- qqq:out std_logic_vector(3 downto 0));
- end hhh;
- architecture dd of hhh is
- begin
- with a select
- qqq<=n1 when "000",
- n2 when "001",
- n3 when "010",
- n4 when "011",
- n5 when "100",
- n6 when "101",
- "0000" when others;
- end dd;
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.std_logic_unsigned.all;
- entity ggg is
- port(m:in std_logic_vector(2 downto 0);
- b:out std_logic_vector(5 downto 0));
- end ggg;
- architecture ee of ggg is
- begin
- with m select
- b<="100000" when "000",
- "010000" when "001",
- "001000" when "010",
- "000100" when "011",
- "000010" when "100",
- "000001" when "101",
- "000000" when others;
- end ee;
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.std_logic_unsigned.all;
- entity decoder is
- port(x:in std_logic_vector(3 downto 0);
- y:out std_logic_vector(6 downto 0));
- end decoder;
- architecture one of decoder is
- begin
- with x select
- y<="1111110" when "0000",
- "0110000" when "0001",
- "1101101" when "0010",
- "1111001" when "0011",
- "0110011" when "0100",
- "1011011" when "0101",
- "1011111" when "0110",
- "1110000" when "0111",
- "1111111" when "1000",
- "1111011" when "1001",
- "0000000" when others;
- end one;
- library ieee;
- use ieee.std_logic_1164.all;
- entity sst is
- port(h1,h0,m1,m0,s1,s0:in std_logic_vector(3 downto 0);
- clk4:in std_logic;
- q500:out std_logic);
- end sst;
- architecture sss of sst is
- begin
- process(clk4,m1,m0,s1,s0)
- begin
- if (clk4'event and clk4='1') then
- if ((h1="0000" and h0="0111" and m1="0000" and m0="0000")
- or (m1="0101" and m0="1001" and s1="0101" and s0="1001"))then
- q500<='1';
- else
- q500<='0';
- end if;
- end if;
- end process;
- end sss;
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.std_logic_unsigned.all;
- entity cnt6 is
- port (clk5:in std_logic;
- n:out std_logic_vector(2 downto 0));
- end cnt6;
- architecture behav of cnt6 is
- signal q1:std_logic_vector(2 downto 0);
- begin
- process(clk5)
- begin
- if clk5'event and clk5='1' then
- if q1<5 then q1<=q1+1;
- else q1<=(others=>'0');
- end if;
- end if;
- end process;
- n<=q1;
- end behav;
- library ieee;
- use ieee.std_logic_1164.all;
- entity anda is
- port (a1,b1:in std_logic;
- y:out std_logic);
- end anda;
- architecture an of anda is
- begin
- y<=a1 and b1;
- end an;
- library ieee;
- use ieee.std_logic_1164.all;
- entity or_1 is
- port (a1,b1:in std_logic;
- y:out std_logic);
- end or_1;
- architecture oo of or_1 is
- begin
- y<=a1 or b1;
- end oo;
- library ieee;
- use ieee.std_logic_1164.all;
- entity digital_clock is
- port(clk,sa,sb,sc:in std_logic;
- q1:out std_logic;
- r:out std_logic_vector(5 downto 0);
- q0:out std_logic_vector(6 downto 0));
- end digital_clock;
- architecture main of digital_clock is
- component anda
- port(a1,b1:in std_logic;
- y:out std_logic);
- end component;
- component or_1
- port(a1,b1:in std_logic;
- y:out std_logic);
- end component;
- component fenpin
- port(clk6:in std_logic;
- q1000,q1,q5:out std_logic);
- end component;
- component hour
- port (clk3,en3:in std_logic;
- qe:out std_logic_vector(3 downto 0);
- qf:out std_logic_vector(3 downto 0));
- end component;
- component minute
- port (clk2,en2:in std_logic;
- qc:out std_logic_vector(3 downto 0);
- co2:out std_logic;
- qd:out std_logic_vector(3 downto 0));
- end component;
- component second
- port (clk1,en1:in std_logic;
- qa:out std_logic_vector(3 downto 0);
- co1:out std_logic;
- qb:out std_logic_vector(3 downto 0));
- end component;
- component sst is
- port(h1,h0,m1,m0,s1,s0:in std_logic_vector(3 downto 0);
- clk4:in std_logic;
- q500:out std_logic);
- end component;
- component hhh
- port(n1,n2,n3,n4,n5,n6:in std_logic_vector(3 downto 0);
- a:in std_logic_vector(2 downto 0);
- qqq:out std_logic_vector(3 downto 0));
- end component;
- component ggg
- port(m:in std_logic_vector(2 downto 0);
- b:out std_logic_vector(5 downto 0));
- end component;
- component cnt6 is
- port (clk5:in std_logic;
- n:out std_logic_vector(2 downto 0));
- end component;
- component decoder
- port(x:in std_logic_vector(3 downto 0);
- y:out std_logic_vector(6 downto 0));
- end component;
- signal a,b,c,h, i,j,z:std_logic;
- signal k,l,e,f,u,v,t:std_logic_vector(3 downto 0);
- signal s: std_logic_vector(2 downto 0);
- begin
- u1:fenpin port map(clk6=>clk,q1=>h,q1000=>z);
- u2:second port map(clk1=>h,en1=>sc,qa=>k,qb=>l,co1=>I);
- u0:or_1 port map(a1=>i,b1=>sb,y=>a);
- u3:minute port map(clk2=>h,en2=>a,qc=>e,qd=>f,co2=>j);
- u30:anda port map(a1=>i,b1=>j,y=>b);
- u31:or_1 port map(a1=>b,b1=>sa,y=>c);
- u4:hour port map(clk3=>h,en3=>c,qe=>u,qf=>v);
- u5:sst port map(h1=>u,h0=>v,m1=>e,m0=>f,s1=>k,s0=>l,clk4=>h,q500=>q1);
- u6:hhh port map(n1=>k,n2=>l,n3=>e,n4=>f,n5=>u,n6=>v,qqq=>t,a=>s);
- u7:ggg port map(b=>r,m=>s);
- u8:cnt6 port map(n=>s,clk5=>z);
- u9:decoder port map(x=>t,y=>q0);
- end architecture main;
復(fù)制代碼
以上的Word格式文檔51黑下載地址:
數(shù)電課程設(shè)計(jì)——基于fpga的數(shù)字時(shí)鐘的設(shè)計(jì).doc
(364.62 KB, 下載次數(shù): 81)
2019-1-10 13:57 上傳
點(diǎn)擊文件名下載附件
|