VHDL-實驗重點講義_第1頁
VHDL-實驗重點講義_第2頁
VHDL-實驗重點講義_第3頁
VHDL-實驗重點講義_第4頁
VHDL-實驗重點講義_第5頁
已閱讀5頁,還剩11頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、計算機科學與技術學院實 驗 報 告 (學年度 第學期 )課程名稱 EDA技術實驗姓名學號專業計算機班級地點教師實驗一:八位二進制補碼一實驗目的1 熟悉Max+PlusII和GW48EDA開發系統的使用;2 掌握八位二進制補碼的VHDL設計;3 元件例化語句的使用。二實驗原理 若原碼為正,則補碼等于原碼;若原碼為負,則補碼為(2+原碼)mod2。 三八位二進制補碼程序LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY JACKAN IS PORT(rst:IN STD_LOGIC; din

2、:IN STD_LOGIC_VECTOR(7 DOWNTO 0); dout:OUT STD_LOGIC_VECTOR(7 DOWNTO 0);END ENTITY JACKAN; ARCHITECTURE HAIXIA OF JACKAN ISSIGNAL tmp:STD_LOGIC_VECTOR(6 DOWNTO 0);BEGIN PROCESS(din,rst) BEGIN IF rst='0' THEN dout <=(OTHERS=>'0'); ELSIF din(7) ='1' THEN FOR i IN 0 TO 6 L

3、OOP tmp(i)<=NOT din(i); END LOOP; dout(6 DOWNTO 0) <= tmp+1; dout(7) <= din(7); ELSE dout <= din; END IF; END PROCESS;END ARCHITECTURE HAIXIA;四實驗結果 五總結 8位二進制補碼:寄存器主要用來存儲8位二進制數據。高8位為符號位,不進行求反運算。余下7位根據高8位的數據狀態進行相應操作。實驗二.一位全減器的VHDL設計一. 實驗目的1. 熟悉Max+PlusII和GW48EDA開發系統的使用;2. 掌握一位半減器的VHDL設計;3.

4、 掌握一位半減器構建一位全減器的方法;二實驗原理 由兩個半減器和一個或門構成一個全減器。首先,一位半減器的邏輯表達式: 其次,一位全減器的邏輯表達式: 三程序半減器的VHDL的程序如下:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL; entity Jackan is port( x,y : in std_logic; diff,s_out : out std_logic );end Jackan;architecture Haixia of Jackan isbeginprocess(x,y)

5、begin diff<=x xor y; s_out<=(not x) and y;end process;end architecture Haixia;描述或門的VHDL程序如下:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity haixia is port( x,y,sub_in : in std_logic; diffr,sub_out : out std_logic );end entity haixia;architecture Yaty of haixia i

6、scomponent Jackan port( x , y : in std_logic; diff,s_out : out std_logic );end component;signal t0,t1,t2:std_logic;beginu1:Jackan port map(x=>x,y=>y,diff=>t0,s_out=>t1);u2:Jackan port map(x=>t0,y=>sub_in,diff=>diffr,s_out=>t2);sub_out<=t1 or t2;END ARCHITECTURE Yaty; 四實驗結果

7、 五總結一位全減器主要有:半減器,用來對輸入數據取單個相異輸出;異或門,對輸入的數據進行異或運算。實驗三.八位二進制乘法一實驗目的1熟悉Max+PlusII和GW48EDA開發系統的使用;2掌握八位二進制乘法的VHDL設計;3元件例化語句的使用。二實驗原理八位二進制乘法器是有由8位加法器構成的以時序方式設計的8位乘法器,采用逐項移位相加的方法來實現相乘。用乘數的各位數碼,從低位開始依次與被乘數相乘,每相乘一次得到的積稱為部分積,將第一次(由乘數最低位與被乘數相乘)得到的部分積右移一位并與第二次得到的部分積相加,將加得的和右移一位再與第三次得到的部分積相加,再將相加的結果右移一位與第四次得到的部

8、分積相加。直到所有的部分積都被加過一次。層次模塊8位乘法器的層次結構,分為以下4個模塊:右移寄存器模塊:這是一個8位右移寄存器,可將乘法運算中的被乘數加載于其中,同時進行乘法運算的移位操作。加法器模塊:這是一個8位加法器,進行操作數的加法運算。1位乘法器模塊:完成8位與1位的乘法運算。鎖存器模塊:這是一個16位鎖存器,同時也是一個右移寄存器,在時鐘信號的控制下完成輸入數值的鎖存與移位。 簡單流程圖。 八位寄存器Haixia存放乘數a,從a的最低位開始,每次從Haixia中移出一位,送至1×8位乘法器Yaty中,同時將被乘數加至Yaty中,進行乘法運算,運算的結果再送至8位加法器Qua

9、nge中,同時取出16位移位寄存器Jackan的高8位與之進行相加,相加后結果即部分積存入Jackan中,進行移位后并保存。這樣經過8次對乘數a的移位操作,所以的部分積已全加至Jackan中,此時鎖存器Jackan存放的值即所要求的積。 輸出結果(B)簡單流程圖16位移位寄存器Jackan8位加法器adder_8時鐘、清零、移位控制信號,控制移位、清零或鎖存1×8位乘法器Yaty被乘數b乘數a8位移位寄存器Haixia開始開始信號到來,置newstart為1寄存器Jackan置0時鐘上升沿到來,寄存器Haixia置乘數a時鐘下降沿,置newstart為零Haixia移出1位后與被乘數

10、放入Yaty中進行乘法運算,結果送至QuangeJackan取出高8位送Quange中,與Yaty得到結果進行加法運算,結果送至Jackan右移后并進行鎖存輸出每一步的運算結果,即輸出Jackan的值,其中第八個值即為求得的積結束三程序 8位移位寄存器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity haixia is -實體描述port(haixia _clk, haixia _load:in std_logic; haixi

11、a _in:in std_logic_vector(7 downto 0); haixia _out:out std_logic);end haixia;architecture arc_ haixia of haixia is -結構體描述 signal xiaoxia:std_logic_vector(7 downto 0); -定義信號變量begin process(haixia _clk, haixia _load) begin if haixia _clk'event and haixia _clk='1' then -時鐘上升沿到來 if haixia _l

12、oad='1' then -鎖存新數據 xiaoxia<=r8_in; else xiaoxia(6 downto 0)<=xiaoxia(7 downto 1); -數據右移 end if; end if; end process; haixia _out<=xiaoxia(0); -輸出最低位end arc_ haixia;8位加法器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all; entity add

13、er_4 is -實體描述 port(a4_in :in std_logic; a4_a,a4_b:in std_logic_vector(3 downto 0); a4_s:out std_logic_vector(3 downto 0); a4_out:out std_logic); end adder_4; architecture arc_adder_4 of adder_4 is -結構體描述 signal ss:std_logic_vector(4 downto 0); -定義信號變量 signal aa,bb:std_logic_vector(4 downto 0); begin

14、 aa<='0'&a4_a; -為避免溢出,將0與a4_a連接 bb<='0'&a4_b; -將0與a4_b連接 ss<=aa+bb+a4_in; -執行加法運算 a4_s<=ss(3 downto 0); -輸出結果 a4_out<=ss(4); -進位位 end arc_adder_4;adder_8library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity

15、 adder_8 is -實體描述port(a8_in :in std_logic; a8_a,a8_b:in std_logic_vector(7 downto 0); a8_s:out std_logic_vector(7 downto 0); a8_out:out std_logic);end adder_8;architecture arc_adder_8 of adder_8 is -結構體描述 component adder_4 -元件例化,調用4位加法器聲明 port(a4_in :in std_logic; a4_a,a4_b:in std_logic_vector(3 dow

16、nto 0); a4_s:out std_logic_vector(3 downto 0); a4_out:out std_logic); end component; signal carry_out:std_logic; -定義信號變量begin u1:adder_4 -例化語句 port map(a8_in,a8_a(3 downto 0),a8_b(3 downto 0),a8_s(3 downto 0),carry_out); u2:adder_4 port map(carry_out,a8_a(7 downto 4),a8_b(7 downto 4),a8_s(7 downto 4

17、),a8_out);end arc_adder_8; 1位乘法器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity yaty is -實體描述port(yaty _x:in std_logic; yaty _y:in std_logic_vector(7 downto 0); yaty _out:out std_logic_vector(7 downto 0);end yaty;architecture arc_ yaty of

18、yaty is -結構體描述begin process(yaty _x, yaty _y) begin for i in 0 to 7 loop -循環完成8位與1位的乘法運算 yaty _out(i)<= yaty _y(i)and yaty _x; end loop; end process;end arc_ yaty16位移位寄存器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity jackan is -實體描述por

19、t(jackan _clk, jackan _clr:in std_logic; jackan _in:in std_logic_vector(8 downto 0); jackan _out:out std_logic_vector(15 downto 0);end jackan;architecture arc_ jackan of jackan is -結構體描述 signal yaty:std_logic_vector(15 downto 0); -定義信號變量 begin process(jackan _clk, jackan _clr) begin if jackan _clr=&

20、#39;1' then -clr為高電平,清零 yaty<="0000000000000000" elsif jackan _clk'event and jackan _clk='1' then -時鐘上升沿到來 yaty(6 downto 0)<=yaty(7 downto 1); -右移,并鎖存低八位 yaty(15 downto 7)<= jackan _in; -將輸入鎖存到高8位 end if; end process; jackan _out<=yaty; -數據輸出end arc_ jackan;8位乘法

21、器library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity jackanandhaixia is -實體描述port(clk,start:in std_logic; jackan,haixia:in std_logic_vector(7 downto 0); result:out std_logic_vector(15 downto 0);end jackanandhaixia;architecture arc_ jackanandha

22、ixia of jackanandhaixia is -結構體描述component yaty -調用1位乘法器聲明port(yaty_x:in std_logic; yaty_y:in std_logic_vector(7 downto 0); yaty_out:out std_logic_vector(7 downto 0);end component;component adder_8 -調用8位加法器聲明port(a8_in :in std_logic; a8_a,a8_b:in std_logic_vector(7 downto 0); a8_s:out std_logic_vect

23、or(7 downto 0); a8_out:out std_logic);end component;component haixia -調用8位寄存器聲明port(haixia_clk,r8_load:in std_logic; haixia_in:in std_logic_vector(7 downto 0); haixia_out:out std_logic);end component;component jackan -調用16位寄存器聲明port(jackan _clk, jackan _clr:in std_logic; jackan _in:in std_logic_vect

24、or(8 downto 0); jackan _out:out std_logic_vector(15 downto 0);end component;signal gndint,newstart,qb:std_logic; -定義信號變量signal andsd:std_logic_vector(7 downto 0);signal dtbin:std_logic_vector(8 downto 0);signal dtbout:std_logic_vector(15 downto 0);begin result<=dtbout; gndint<='0'process(clk,start) begin if start='1

溫馨提示

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

評論

0/150

提交評論