EDA考試題目和答案_第1頁
EDA考試題目和答案_第2頁
EDA考試題目和答案_第3頁
EDA考試題目和答案_第4頁
EDA考試題目和答案_第5頁
已閱讀5頁,還剩35頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、設(shè)計實驗與考核1、 設(shè)計一個帶計數(shù)使能、異步復位、帶進位輸出的增1六位二進制計數(shù)器,計數(shù)結(jié)果由共陰極七段數(shù)碼管顯示。答:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity counter is port(clk,clk1,en,clr:in std_logic; ledout:out std_logic_vector(6 downto 0); scanout,scanout1,co:out std_logic);end counter;architecture a of counter

2、issignal cnt:std_logic_vector(7 downto 0);signal led:std_logic_vector(6 downto 0);signal scan:std_logic;signal hex:std_logic_vector(3 downto 0);begin process(clk) begin if(clkevent and clk=1)then if en=1then if clr=1then cnt0); else if cnt=then cnt=; co=1; else cnt=cnt+1; co=0; end if; end if; end i

3、f; end if; end process;process(clk1) begin if clk1event and clk1=1then scan=not scan; end if;Scanout=scan;Scanout1=not scan;end process;ledout=not led;hex=cnt(7 downto 4) when scan=1else cnt(3 downto 0);with hex selectled=when0001, when0010, when0011, when0100, when0101, when0110, when0111, when1000

4、, when1001, when1010, when1011, when1100, when1101, when1110, when1111, when others;end a;2、 設(shè)計一個帶計數(shù)使能、同步復位、帶進位輸出的增1二十進制計數(shù)器,計數(shù)結(jié)果由共陰極七段數(shù)碼管顯示。答:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity counter isport(clk,clk1,en,clr:in std_logic; co,scanout:out std_logic; ledout:

5、out std_logic_vector(6 downto 0);end counter;architecture rtl of counter is signal cnt:std_logic_vector(7 downto 0); signal led:std_logic_vector(6 downto 0); signal scan:std_logic; signal hex:std_logic_vector(3 downto 0);begin process(clk,clr) begin if clr=1then cnt0); elsif clkevent and clk=1 then

6、if en=1then if cnt=then cnt=; co=0; elsif cnt=then -注意此處,前面跳過了A到F的計數(shù),所以計數(shù)到11001 cnt=; co=1; else cnt=cnt+1; co=0; end if; end if; end if; end process; process(clk1) begin if clk1event and clk1=1then scan=not scan; end if; end process; ledout=not led; scanout=scan; hex=cnt(7 downto 4) when scan=1else

7、 cnt(3 downto 0); with hex select led=when0001, when0010, when0011, when0100, when0101, when0110, when0111, when1000, when1001, when0000, when others;end rtl;3、 設(shè)計一個帶計數(shù)使能、異步復位、同步裝載的可逆七位二進制計數(shù)器,計數(shù)結(jié)果由共陰極七段數(shù)碼管顯示。答:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity counter is

8、port(clk,clks,clr,en,stdl,dir:in std_logic; din:in std_logic_vector(6 downto 0); ledout:out std_logic_vector(6 downto 0); scanout:out std_logic);end counter;architecture a of counter is signal cnt:std_logic_vector(6 downto 0); signal hex:std_logic_vector(3 downto 0); signal led:std_logic_vector(6 do

9、wnto 0); signal scan:std_logic;begin process(clk) begin if(clkevent and clk=1)then if clr=1then cnt0); elsif stdl=0then cnt=din; elsif en=1then if dir=1then cnt=cnt+1; else cnt=cnt-1; end if; end if; end if; end process; process(clks) begin if(clksevent and clks=1)then scan=not scan; end if; end pro

10、cess; scanout=scan; ledout=not led; hex=0&cnt(6 downto 4)when scan=1 else cnt(3 downto 0); with hex select led=when0001, when0010, when0011, when0100, when0101, when0110, when0111, when1000, when1001, when1010, when1011, when1100, when1101, when1110, when1111, when others;end a;4、 設(shè)計一個帶計數(shù)使能、同步復位、異步裝

11、載、可逆計數(shù)的通用計數(shù)器。計數(shù)結(jié)果由共陰極七段數(shù)碼管顯示。答:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY counter IS GENERIC (count_value:INTEGER:=9);PORT(clk,clr,en,load,dir:IN STD_LOGIC; data_in:IN INTEGER RANGE 0 TO count_value; ledout:OUT STD_LOGIC_VECTOR(6 DOWNTO 0);END counter;ARCHITECTUR

12、E a OF counter IS SIGNAL cnt:INTEGER RANGE 0 TO count_value; SIGNAL led:STD_LOGIC_VECTOR(6 DOWNTO 0);BEGIN PROCESS(load,clk) BEGIN IF load=1 THEN cnt=data_in; elsif clr=1 THEN cnt=0; ELSIF (clkEVENT AND clk=1)THEN IF en=1 THEN IF dir=1 THEN IF cnt=count_value THEN cnt=0; ELSE cnt=cnt+1; end if; else

13、 IF cnt=0 THEN cnt=count_value; else cnt=cnt-1; end if; end if; end if; end if; END PROCESS; ledout=NOT led; WITH cnt SELECT led=WHEN 1, WHEN 2, WHEN 3, WHEN 4, WHEN 5, WHEN 6, WHEN 7, WHEN 8, WHEN 9, WHEN 0, WHEN others;END a;5、 設(shè)計一個具有16分頻、8分頻、4分頻和2分頻功能的多用分頻器。答:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.

14、ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY div4 ISPORT(clk:IN STD_LOGIC; din:IN STD_LOGIC_VECTOR(3 DOWNTO 0); fout:OUT std_LOGIC);END div4;ARCHITECTURE a OF div4 ISbegin process(clk) variable cnt:std_logic_vector(3 downto 0); begin if(clkevent and clk=1) then if cnt=1111 then cnt:=0000; else cnt:=cn

15、t+1; end if; if din=0000 then fout=cnt(3); elsif din=1000 then fout=cnt(2); elsif din=1100 then fout=cnt(1); elsif din=1110 then fout=cnt(0); else fout=1; end if; end if; end process;end a;6、 設(shè)計一個正負脈寬相等的通用分頻器。答:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY div ISGEN

16、ERIC (num:INTEGER:=2);PORT (clk:IN STD_LOGIC; co:OUT STD_LOGIC);END div;ARCHITECTURE rtl OF div ISBEGIN PROCESS(clk) VARIABLE cnt:STD_LOGIC_VECTOR(num downto 0); BEGIN IF(clkevent and clk=1)THEN cnt:=cnt+1; END IF; co=0101)then cnt:=0000; else cnt:=cnt+1; end if; cout=1000)then cnt:=0000; cout=1; el

17、se cnt:=cnt+1; cout=1110)then cnt:=0000;cout=1; else cnt:=cnt+1;cout=1111)then cnt:=0000; else cnt:=cnt+1; end if; cout=cnt(3); end if;end if;end process; with en select led=when00, when01, when10, when11, when others;ledout=led;end dgnfenpin;8、 設(shè)計一個M序列發(fā)生器,M序列為“”library ieee;use ieee.std_logic_1164.

18、all;use ieee.std_logic_unsigned.all;entity xulie isport(clk:in std_logic; fout:out std_logic);end xulie;architecture fashengqi of xulie issignal cnt:std_logic_vector(2 downto 0);beginprocess(clk)beginif(clkevent AND clk=1)then if(cnt=111)then cnt=000; else cnt=cnt+1; end if;end if;end process;with c

19、nt select fout=1when000, 1when001, 1when010, 1when011, 0when100, 1when101, 0when “110”,1when”111”, 0when others;end fashengqi;9、 設(shè)計一個彩燈控制器,彩燈共有16個,每次順序點亮相鄰的四個彩燈,如此循環(huán)執(zhí)行,循環(huán)的方向可以控制。答:library ieee;use ieee.std_logic_1164.all;entity caideng isport( rl,clk:in std_logic;ledout:out std_logic_vector(15 downt

20、o 0);end caideng;architecture a of caideng issignal led:std_logic_vector(15 downto 0);signal k:std_logic;beginprocess(clk)beginif(clkevent and clk=1)then if(k=0)then led1,1=1,2=1,3=1,others=0); elsif(rl=1)then led=led(14 downto 0)&led(15); elsif(rl=0)then led=led(0)&led(15 downto 1); end if;end if;l

21、edout=led;end process;end a;10、 設(shè)計一個具有左移、右移控制,同步并行裝載和串行裝載的8位串行移位寄存器LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;ENTITY shifter1 ISPORT(clk,clr,ser,dir,stld:IN STD_LOGIC;din: IN STD_LOGIC_VECTOR(0 TO 7) ;qh:OUT STD_LOGIC);END shifter1;ARCHITECTURE rt1 OF shifter1 ISSIGNAL reg:STD_LOGIC_VECTOR(0 TO 7);beg

22、inprocess(clk,clr)beginif clr=1 thenreg0);elsif clkevent and clk=1then if stld=0then reg=din; else if(dir=0)then reg=reg(1 to 7)&ser;qh=reg(0); else reg=ser®(0 to 6);qh=”0101”and cnt=”1001”)then gree=1;red=”0000”and cnt=”0100”)thengree=0;red=1; end if;count=cnt;end process;ledout=not led;with cou

23、nt selectled=when0001,when0010,when0011,when0100,when0101,when0110,“”when”0111”,“”when”1000”,“”when”1001”,when others;end rtl;12、 設(shè)計一個同步復位,異步并行裝載的8位串行左移移位寄存器LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;Entity exam13 isPort(clk,clr,ser,stld:in std_logic;Din:in std_logic_vector(0 to 7);Qh:out std_logic);E

24、nd exam13;Architecture rtl of exam13 isSignal reg:std_logic_vector(0 to 7);BeginProcess(clk,stld)Begin If stld=1 thenReg=din; Elsif clkevent and clk=1 thenIf clr=1 then Reg=0);Elsif(stld=0)then Reg=reg(1 to 7)&ser;End if; End if;End process;Qh=reg(0);End rtl;13、 有16個開關(guān),編號為0到15,編號0的優(yōu)先級最高。當某一個撥碼開關(guān)為1時由

25、共陰極七段數(shù)碼管顯示其編號(可用16進制數(shù)顯示,亦可用十進制顯示)答:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY bhxs ISPORT(INPUT:IN STD_LOGIC_VECTOR(15 DOWNTO 0); LEDOUT: out STD_LOGIC_VECTOR(6 DOWNTO 0);END bhxs;ARCHITECTURE RT1 OF bhxs IS SIGNAL LED:STD_LOGIC_VECTOR(6 DOWNTO 0);BEGIN process(I

26、NPUT) begin LEDOUT=NOT LED; IF(INPUT(0)=1)then LED=; ELSIF(INPUT(1)=1)then LED=; ELSIF(INPUT(2)=1)then LED=; ELSIF(INPUT(3)=1)then LED=; ELSIF(INPUT(4)=1)then LED=; ELSIF(INPUT(5)=1)then LED=; ELSIF(INPUT(6)=1)then LED=; ELSIF(INPUT(7)=1)then LED=; ELSIF(INPUT(8)=1)then LED=; ELSIF(INPUT(9)=1)then L

27、ED=; ELSIF(INPUT(10)=1)then LED=; ELSIF(INPUT(11)=1)then LED=; ELSIF(INPUT(12)=1)then LED=; ELSIF(INPUT(13)=1)then LED=; ELSIF(INPUT(14)=1)then LED=; ELSIF(INPUT(15)=1)then LEDjiashui=0;qidong=1; If water_low=1then next_state=too_low; Elsif water_high=1then next_state=too_high; Else next_statejiashu

28、i=1;qidong=0; If water_low=1then next_state=too_low; Elsif water_high=1then next_state=too_high; Else next_statejiashui=0;qidong=1; If water_low=1then next_state=too_low; Elsif water_high=1then next_state=too_high; Else next_state=just_right; End if; End case, End process;Process(clk) Begin If(clkev

29、ent and clk=1)then Now_state=next_state; End if; End process;End style;15、 根據(jù)真值表設(shè)計一位全加器,然后用結(jié)構(gòu)的描述方法設(shè)計一個8位加法器。LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;ENTITY full_adder ISPORT(a,b,cin:IN STD_LOGIC; s,co:OUT STD_LOGIC);END full_adder;ARCHITECTURE full1 of full_adder isSIGNAL comb:STD_LOGIC_VECTOR(2 dow

30、nto 0);BEGIN comb=a&b&cin;PROCESS(comb)BEGINIF(comb=000)then s=0;co=0;elsif(comb=001)then s=1;co=0;elsif(comb=100)then s=1;co=0;elsif(comb=010)then s=1;co=0;elsif(comb=011)thens=0;co=1;elsif(comb=101)thens=0;co=1;elsif(comb=110)thens=0;co=1;elses=1;co=1;end if;end process;end full1;library ieee;use

31、ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;entity full_adder8 isport(clk,cin:in std_logic; x,y:in std_logic_vector(7 downto 0); ledout:out std_logic_vector(6 downto 0);scan_out:out std_logic_vector(1 downto o); co:out std_logic);end full_adder8;architecture

32、stru of full_adder8 iscomponent full_adderport(a,b,cin:in std_logic; s,co:out std_logic);end component; signal z:std_logic_vector(6 downto 0);signal sum:std_logic_vector(7 downto 0);signal scan:std_logic_vector(1 downto 0);signal hex:std_logic_vector(3 downto 0);signal led:std_logic_vector(6 downto

33、0);beginuo:full_adder port map(x(0),y(0),cin,sum(0),z(0);u1:full_adder port map(x(1),y(1),z(0),sum(1),z(1);u2:full_adder port map(x(2),y(2),z(1),sum(2),z(2);u3:full_adder port map(x(3),y(3),z(2),sum(3),z(3);u4:full_adder port map(x(4),y(4),z(3),sum(4),z(4);u5:full_adder port map(x(5),y(5),z(4),sum(5

34、),z(5);u6:full_adder port map(x(6),y(6),z(5),sum(6),z(6);u7:full_adder port map(x(7),y(7),z(6),sum(7),co);scan_out=scan;ledout=not led;process(clk)begin if(clkevent and clk=1)then if scan=”10” then scan=”01”; else scan=”10”; end if; end if;end process;hex=sum(7 downto 4)when scan=”10” else sum(3 dow

35、nto 0);with hex selectled=”when”0000”, “”when”0001”, “”when”0010”, “”when”0011”, “”when”0100”, “”when”0101”, “”when”0110”, “”when”0111”, “”when”1000”, “”when”1001”, “”when”1010”, “”when”1011”, “”when”1100”, “”when”1101”, “”when”1110”, “”when”1111”, “XXXXXXX”when others;End stru;16、 設(shè)計6位二進制數(shù)到BCD碼(842

36、1碼)的轉(zhuǎn)換器。結(jié)果由共陰極數(shù)碼管顯示。LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;use ieee.std_logic_unsigned.all;ENTITY trans ISPORT( scanclk:IN STD_LOGIC; shu:IN STD_LOGIC_VECTOR(5 DOWNTO 0); ledout:OUT STD_LOGIC_VECTOR(6 DOWNTO 0); scanout:out integer range 0 to 1);END trans;ARCHITECTURE rtl OF trans IS signal yh,yl:

37、integer range 0 to 9; signal scan:integer range 0 to 1; signal led:std_logic_vector(6 downto 0); signal y,hex:integer range 0 to 63;BEGIN y=conv_integer(shu); yh=10 and y=20 and y=30 and y=40 and y=50 and y=60 and y64 else 0; yl=0 and y=10 and y=20 and y=30 and y=40 and y=50 and y=60 and y70 else0;

38、process(scanclk) begin if(scanclkevent and scanclk=1)then if scan=1 then scan=0; else scan=1; end if; end if; end process; with scan select hex=yh when 1, yl when others; ledout=not led; scanout=scan; with hex select led=when 1, when 2, when 3, when 4, when 5, when 6, when 7, when 8, when 9, when 0,

39、“”when others;END rtl; 17、 設(shè)計一個跑馬燈控制器。一共有8個彩燈,編號為LED0LED7,點亮方式為:先從左往右順序點亮,然后從右往左,如此循環(huán)往復。答:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY lighten IS PORT( CLK:IN STD_LOGIC; ledout:OUT STD_LOGIC_VECTOR(7 DOWNTO 0);END lighten;ARCHITECTURE b OF lighten ISSIGNAL cnt:STD_LOGIC_VECTOR(3 DOWNTO 0);BEGIN PROCESS(CLK) BEGIN IF(CLKEVENT AND CLK=1)THEN IF (cnt=1110)THEN cnt=0000; ELSE cnt=cnt+1; END IF; END IF; END PROCESS;WITH cnt SELECTledout= WHEN0000, WHEN0001, WHEN0010, WHEN0011, WHEN0100, WHEN0101, WHEN0110, WHEN0111, WHEN1000, WHEN1001, WHEN1010, WHEN10

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論