資源描述:
《加法器、減法器的設(shè)計(jì)vhdl》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫(kù)。
1、實(shí)驗(yàn)報(bào)告課程名稱電子設(shè)計(jì)自動(dòng)化實(shí)驗(yàn)(基于FPGA)實(shí)驗(yàn)項(xiàng)目加法器、減法器的設(shè)計(jì)實(shí)驗(yàn)儀器計(jì)算機(jī)+QuartusⅡ9.1系別信息與通信工程學(xué)院專業(yè)通信工程班級(jí)/學(xué)號(hào)學(xué)生姓名實(shí)驗(yàn)日期2012、5成績(jī)_______________________指導(dǎo)教師_______________________4HigashiQ83831295加法器、減法器的設(shè)計(jì)完成一個(gè)8位二進(jìn)制帶符號(hào)數(shù)的加減電路設(shè)計(jì)。設(shè)計(jì)要求如下:通過(guò)撥碼開(kāi)關(guān)輸入兩組8位二進(jìn)制數(shù),最高位為符號(hào)位,0表示正數(shù),1表示負(fù)數(shù),其余位表示二進(jìn)制數(shù)值。用一按鍵對(duì)加、減方式進(jìn)行控制,0表示加,1表示減。輸
2、出用四位LED數(shù)碼管顯示BCD碼。其中LED顯示器最高位為符號(hào)位。VHDL代碼LIBRARYIEEE;USEIEEE.std_logic_1164.all;USEIEEE.std_logic_arith.all;USEIEEE.std_logic_unsigned.all;ENTITYaddISPORT(a:instd_logic_vector(7downto0);b:instd_logic_vector(7downto0);ctrl:instd_logic;bcd:outstd_logic_vector(15downto0));ENDENTI
3、TY;ARCHITECTUREfuncOFaddISSIGNALx:std_logic_vector(9downto0);SIGNALy:std_logic_vector(9downto0);SIGNALz:std_logic_vector(9downto0);SIGNALc:std_logic_vector(8downto0);SIGNALdec:integer;BEGINyunsuan:BLOCK--運(yùn)算模塊BEGINPROCESS(a)BEGINIF(a(7)='0')THEN--判斷正負(fù)x<='0'&'0'&a;ELSEx(9downt
4、o8)<='1'&'1';x(7downto0)<=NOT('0'&a(6downto0))+1;ENDIF;ENDPROCESS;PROCESS(a,ctrl)BEGIN4HigashiQ83831295IF(ctrl='0')THEN--控制鍵為0,則做加法IF(b(7)='0')THENy<='0'&'0'&b;ELSEy<='1'&'1'&(NOT('0'&b(6downto0))+1);ENDIF;ELSEIF(b(7)='1')THENy<='0'&'0'&'0'&b(6downto0);ELSEy<='1'&'1'&(NOT('0
5、'&b(6downto0))+1);ENDIF;ENDIF;ENDPROCESS;PROCESS(a,b)BEGINIF(a(6downto0)=0)THENz<=y;ELSEIF(b(6downto0)=0)THENz<=x;ELSEz<=x+y;ENDIF;ENDIF;ENDPROCESS;PROCESS(z)BEGINIF(z(9)='1')THEN--判斷結(jié)果的正負(fù)c(7downto0)<=NOTz(7downto0)+1;c(8)<='1';ELSEc(8downto0)<='0'&z(7downto0);ENDIF;ENDPROCE
6、SS;ENDBLOCK;bcdout:BLOCKBEGINdec<=CONV_INTEGER(c);--二進(jìn)制轉(zhuǎn)十進(jìn)制PROCESS(c)BEGIN4HigashiQ83831295CASEc(8)IS--判斷最高位正負(fù)WHEN'0'=>bcd(15downto12)<="0000";WHEN'1'=>bcd(15downto12)<="0001";WHENOTHERS=>bcd(15downto12)<=NULL;ENDCASE;CASEdec/100IS--判斷百位數(shù)字WHEN0=>bcd(11downto8)<="0000";WHEN1=
7、>bcd(11downto8)<="0001";WHENOTHERS=>bcd(11downto8)<=NULL;ENDCASE;CASE(decREM100)/10ISWHEN0=>bcd(7downto4)<="0000";WHEN1=>bcd(7downto4)<="0001";WHEN2=>bcd(7downto4)<="0010";WHEN3=>bcd(7downto4)<="0011";WHEN4=>bcd(7downto4)<="0100";WHEN5=>bcd(7downto4)<="0101";WHEN6=>bcd(7down
8、to4)<="0110";WHEN7=>bcd(7downto4)<="0111";WHEN8=>bcd(7downto4)<="1000";WHEN