版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、深 圳 大 學(xué) 實(shí) 驗(yàn) 報(bào) 告 課程名稱: 數(shù)字系統(tǒng)設(shè)計(jì) 實(shí)驗(yàn)項(xiàng)目名稱: 32位串行加法器 學(xué)院: 信息工程學(xué)院 專業(yè): 電子信息工程 指導(dǎo)教師: 報(bào)告人: 學(xué)號(hào):20091000000 班級(jí): 1班 實(shí)驗(yàn)時(shí)間: 2011-12-4 實(shí)驗(yàn)報(bào)告提交時(shí)間: 2011-12-10 教務(wù)處制一、實(shí)驗(yàn)?zāi)康呐c要求:實(shí)驗(yàn)?zāi)康模?、 掌握串行加法器的原理和設(shè)計(jì)。2、 熟悉VHDL狀態(tài)機(jī)的設(shè)計(jì)。3、 學(xué)會(huì)分析波形圖。實(shí)驗(yàn)要求:設(shè)計(jì)一個(gè)用一個(gè)1位加法器構(gòu)建的一個(gè)32位串行加法器。重點(diǎn)是算法狀態(tài)機(jī)的實(shí)現(xiàn)還有系統(tǒng)的時(shí)序分析;輸出和整理VHDL源代碼;輸出和整理電路結(jié)構(gòu)圖;輸出和整理仿真波形圖二、實(shí)驗(yàn)原理1、設(shè)計(jì)原理圖
2、:本圖參考課本2、流程圖:針對(duì)以上流程圖,其中,Sh為控制移位寄存器的使能信號(hào),k為工作狀態(tài)指示信號(hào),load為加載信號(hào),counter為運(yùn)算計(jì)數(shù)器,N為系統(tǒng)工作控制信號(hào)。從流程圖中可以看出加法器的整個(gè)工作流程是怎么樣子的,具體工作情況如下面的設(shè)計(jì)。三、實(shí)驗(yàn)內(nèi)容與步驟1、VHDL代碼的編寫:-控制器-library IEEE;use IEEE.STD_LOGIC_1164.ALL;use ieee.std_logic_unsigned.all;entity controller is Port ( clk : in STD_LOGIC; N : in STD_LOGIC; K,Sh,load
3、: out STD_LOGIC);end controller;architecture Behavioral of controller issignal state,nextstate:integer range 0 to 2; -設(shè)置狀態(tài)signal counter:std_logic_vector(4 downto 0);beginprocess(clk)beginif(clk'event and clk='1') thenstate<=nextstate; -上升沿觸發(fā)啟動(dòng)end if;end process;process(clk,N)beginif(
4、clk'event and clk='1') thencase state is -設(shè)置各狀態(tài)when 0 =>sh<='0'K<='0'load<='0'counter<="00000"if N='1' thenload<='1'nextstate<=1;else nextstate<=0;end if;when 1 =>sh<='1'K<='0'load<='
5、;0'if counter="11110" thencounter<=counter+1;nextstate<=2;else counter<=counter+1;nextstate<=1;end if;when 2 =>sh<='0'K<='1'load<='0'if N='0' thennextstate<=0;elsenextstate<=2;end if;end case;end if;end process;end Behaviora
6、l;-加數(shù)寄存器-library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity registers_jiashu is Port ( input : in STD_LOGIC_vector(31 downto 0); Sh,load,clk: in STD_LOGIC; SO : out STD_LOGIC);end registers_jiashu;architecture Behavioral of registers_jiashu issignal x:std_logic_vector(31 downto 0);beginprocess(clk)begi
7、nif(clk'event and clk='1') thenif (load='1') then x<=input; -輸入放入寄存器elsif (sh='1') then -移位x(30 downto 0)<=x(31 downto 1);end if;end if;end process;so<=x(0);end Behavioral;-累加器-library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity registers_add is Port ( input : in STD
8、_LOGIC_vector(31 downto 0); clk : in STD_LOGIC; load,Sh,Si: in STD_LOGIC; SO : out STD_LOGIC; output:out std_logic_vector(31 downto 0);end registers_add;architecture Behavioral of registers_add issignal x:std_logic_vector(31 downto 0);beginprocess(clk)beginif(clk'event and clk='1') theni
9、f(load='1') thenx<=input;elsif(Sh='1') thenx(30 downto 0)<=x(31 downto 1); -移位x(31)<=Si;end if;end if;end process;So<=x(0);output<=x; -把最后值輸出來end Behavioral;-全加器-library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity full_adder is Port ( a : in STD_LOGIC; b : in STD_LOGIC; ci
10、n : in STD_LOGIC; s : out STD_LOGIC; cout : out STD_LOGIC);end full_adder;architecture Behavioral of full_adder isbegins<=a xor b xor cin;cout<=(a and b)or(a and cin) or (b and cin);end Behavioral;-D觸發(fā)器-library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity DFF is Port ( D : in STD_LOGIC; clk : in ST
11、D_LOGIC; rst,CE : in STD_LOGIC; Q: out STD_LOGIC);end DFF;architecture Behavioral of DFF isbeginprocess(rst,clk,CE)beginif(rst='1') thenQ<='0'elsif CE='1' and (clk'event and clk='1') thenQ<=D;end if;end process;end Behavioral;-主函數(shù)-library IEEE;use IEEE.STD_L
12、OGIC_1164.ALL;entity adder_32 isport(inputA,inputB:in std_logic_vector(31 downto 0);clk,N :in std_logic;outputA:out std_logic_vector(31 downto 0);K:out std_logic);end adder_32;architecture Behavioral of adder_32 is -對(duì)各個(gè)元件進(jìn)行例化- component controller is -控制器Port ( clk : in STD_LOGIC; N : in STD_LOGIC;
13、K,Sh,load : out STD_LOGIC);end component;component registers_jiashu is -加數(shù)寄存器 Port ( input : in STD_LOGIC_vector(31 downto 0); Sh,load,clk: in STD_LOGIC; SO : out STD_LOGIC);end component;component registers_add is - 累加器 Port ( input : in STD_LOGIC_vector(31 downto 0); clk : in STD_LOGIC; load,Sh,Si
14、: in STD_LOGIC; SO : out STD_LOGIC; output:out std_logic_vector(31 downto 0);end component;component full_adder is -全加器 Port ( a : in STD_LOGIC; b : in STD_LOGIC; cin : in STD_LOGIC; s : out STD_LOGIC; cout : out STD_LOGIC);end component;component DFF is -D觸發(fā)器 Port ( D : in STD_LOGIC; clk : in STD_L
15、OGIC; rst,CE : in STD_LOGIC; Q: out STD_LOGIC);end component;signal Sh,load,Xi,Yi,Si,cin,sum,cout:std_logic; -中間變量beginA1: controller port map(clk,n,k,Sh,load);A2: registers_jiashu port map(inputB,Sh,load,clk,Yi);A3: registers_add port map(inputA,clk,load,Sh,sum,Xi,outputA);A4: full_adder port map(X
16、i,Yi,cin,sum,cout);A5: DFF port map (cout,clk,load,Sh,cin);end Behavioral;2、仿真代碼的編寫:LIBRARY ieee;USE ieee.std_logic_1164.ALL; ENTITY adder_32_testbench ISEND adder_32_testbench; ARCHITECTURE behavior OF adder_32_testbench IS - Component Declaration for the Unit Under Test (UUT) COMPONENT adder_32 PO
17、RT( inputA : IN std_logic_vector(31 downto 0); inputB : IN std_logic_vector(31 downto 0); clk : IN std_logic; N : IN std_logic; outputA : OUT std_logic_vector(31 downto 0); K : OUT std_logic ); END COMPONENT; -Inputs signal inputA : std_logic_vector(31 downto 0) := (others => '0'); signal
18、 inputB : std_logic_vector(31 downto 0) := (others => '0'); signal clk : std_logic := '0' signal N : std_logic := '0' -Outputs signal outputA : std_logic_vector(31 downto 0); signal K : std_logic; - Clock period definitions constant clk_period : time := 10 ns; BEGIN - Inst
19、antiate the Unit Under Test (UUT) uut: adder_32 PORT MAP ( inputA => inputA, inputB => inputB, clk => clk, N => N, outputA => outputA, K => K ); - Clock process definitions clk_process :process beginclk <= '0'wait for clk_period/2;clk <= '1'wait for clk_period
20、/2; end process; stim_proc: process begin-進(jìn)行輸入仿真 inputA<="00000000000000000000000001001001" - inputa= 73,inputB<="00000000000000000000000010001010" - inputb= 138,N<='1' -N=1時(shí)開始計(jì)時(shí),并開始下載數(shù)據(jù)wait for 32*clk_period;-32個(gè)時(shí)鐘周期之后N<='0' -N=0,停止數(shù)據(jù)下載,得出相加后的結(jié)果wait for 10*clk_period; - 延時(shí)10個(gè)時(shí)鐘周期,進(jìn)入下一輪仿真調(diào)試inputA<="01010101010101010101010101010101" - inputa= 1431655765,inputB<="00110000000000000000000010101000" -
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度棉紗行業(yè)質(zhì)量標(biāo)準(zhǔn)制定與實(shí)施合同4篇
- 2025版年會(huì)現(xiàn)場攝影攝像服務(wù)合同范本4篇
- 二零二五年度棉花病蟲害防治與防治藥物供應(yīng)合同4篇
- 二零二五年度新能源汽車動(dòng)力電池研發(fā)合作合同
- 2025年度農(nóng)家樂景區(qū)旅游咨詢與導(dǎo)覽服務(wù)合同協(xié)議
- 二零二五年度美容院美容設(shè)備維護(hù)保養(yǎng)及備件供應(yīng)合同4篇
- 二零二五年度美甲店互聯(lián)網(wǎng)營銷與電商平臺(tái)合作合同4篇
- 二零二五年度南寧市體育場館設(shè)施租賃合同及賽事組織協(xié)議3篇
- 2025年度個(gè)人二手車居間銷售合同示范文本2篇
- 二零二五年帳篷租賃及活動(dòng)策劃服務(wù)合同3篇
- 完整版秸稈炭化成型綜合利用項(xiàng)目可行性研究報(bào)告
- 油氣行業(yè)人才需求預(yù)測-洞察分析
- 《數(shù)據(jù)采集技術(shù)》課件-Scrapy 框架的基本操作
- (2024)河南省公務(wù)員考試《行測》真題及答案解析
- 2025年河北省單招語文模擬測試二(原卷版)
- 工作計(jì)劃 2025年度醫(yī)院工作計(jì)劃
- 高一化學(xué)《活潑的金屬單質(zhì)-鈉》分層練習(xí)含答案解析
- DB34∕T 4010-2021 水利工程外觀質(zhì)量評(píng)定規(guī)程
- 2024年內(nèi)蒙古中考英語試卷五套合卷附答案
- 2024年電工(高級(jí))證考試題庫及答案
- 2024年全國各地中考試題分類匯編:古詩詞閱讀
評(píng)論
0/150
提交評(píng)論