Presentation is loading. Please wait.

Presentation is loading. Please wait.

使用VHDL設計—4位元減法器 通訊一甲 B09622048 楊穎穆.

Similar presentations


Presentation on theme: "使用VHDL設計—4位元減法器 通訊一甲 B09622048 楊穎穆."— Presentation transcript:

1 使用VHDL設計—4位元減法器 通訊一甲 B 楊穎穆

2 目錄 目的 設計原理 程式 實驗結果 參考資料

3 目的 1. 使用VHDL設計一個4位元減法器電路 此電路有A與B輸入各4位元 前一進位Ci 輸出有差S與借位Cy 2. 將電路加以模擬
2. 將電路加以模擬 3. 將程式燒錄到IC執行 4. 將以上原理撰寫成PPT格式報告交出 5. 將以上原理與操作過程講述一便並錄製成影音檔交出

4 設計原理 a3 b3’ a2 b2’ a1 b1’ a0 b0’ cy ci s3 s2 s1 s0 1001 1000
-) ) 1 0010 主要由四個全加器(FA)所組成。 a3 b3’ a2 b2’ a1 b1’ a0 b0’ FA FA FA FA cy ci s3 s2 s1 s0

5 程式 library ieee; use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity sub is 電路內部要做的電路名稱 port( 接腳 a,b : in std_logic_vector(3 downto 0); --輸入腳a,b,且內部各有四個位元數 ci : in std_logic; 輸入腳 ci,代表前一進位 s : out std_logic_vector(3 downto 0); --輸出腳 s,內部有四個位元數 cy : out std_logic 輸出腳 cy,代表補位 ); end;

6 architecture behav of sub is --電路內部結構
signal sum : std_logic_vector(4 downto 0); --表示sum內部有五個位元數 begin process(a,b,ci) 處理影響內部的輸入訊號 a,b,ci s<=sum(3 downto 0); --將sum的前四個位元,搬入到輸出s cy<=sum(4); 將sum第五個位元,搬入到cy sum<=('0'& a)-('0'& b)-("0000"& ci); --將a,b輸入值前各串一個'0',ci前串上"0000",相減的值搬入到sum end process; 結束process程式 end behav; 程式結束

7 實驗結果(1) 當我輸入a為“1001”,b輸入“0111”,兩者相減得到的值為“0010”。
當我輸入a為“1100”,b輸入“0111”,ci輸入為‘1’,三者相減得到的值為“0100”。

8 實驗結果(2) 當我輸入a為“1101”,b輸入“0011”,兩者相減得到的值為“1010”。

9 參考資料 主要的資料內容是參考王志湖老師上課所教授的內容及“數位邏輯”這本書。

10 END


Download ppt "使用VHDL設計—4位元減法器 通訊一甲 B09622048 楊穎穆."

Similar presentations


Ads by Google