数字系统设计实验---32位串行加法器实验_第1页
数字系统设计实验---32位串行加法器实验_第2页
数字系统设计实验---32位串行加法器实验_第3页
数字系统设计实验---32位串行加法器实验_第4页
数字系统设计实验---32位串行加法器实验_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、深 圳 大 学 实 验 报 告 课程名称: 数字系统设计 实验项目名称: 32位串行加法器 学院: 信息工程学院 专业: 电子信息工程 指导教师: 报告人: 学号: 班级: 1班 实验时间: 2011-12-4 实验报告提交时间: 2011-12-10 教务处制一、实验目的与要求:实验目的:1、 掌握串行加法器的原理和设计。2、 熟悉VHDL状态机的设计。3、 学会分析波形图。实验要求:设计一个用一个1位加法器构建的一个32位串行加法器。重点是算法状态机的实现还有系统的时序分析;输出和整理VHDL源代码;输出和整理电路结构图;输出和整理仿真波形图二、实验原理1、设计原理图:本图参考课本2、流程

2、图:针对以上流程图,其中,Sh为控制移位寄存器的使能信号,k为工作状态指示信号,load为加载信号,counter为运算计数器,N为系统工作控制信号。从流程图中可以看出加法器的整个工作流程是怎么样子的,具体工作情况如下面的设计。三、实验内容与步骤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 : out STD_L

3、OGIC);end controller;architecture Behavioral of controller issignal state,nextstate:integer range 0 to 2; -设置状态signal counter:std_logic_vector(4 downto 0);beginprocess(clk)beginif(clkevent and clk=1) thenstatesh=0;K=0;load=0;counter=00000;if N=1 thenload=1;nextstate=1;else nextstatesh=1;K=0;load=0;i

4、f counter=11110 thencounter=counter+1;nextstate=2;else counter=counter+1;nextstatesh=0;K=1;load=0;if N=0 thennextstate=0;elsenextstate=2;end if;end case;end if;end process;end Behavioral;-加数寄存器-library IEEE;use IEEE.STD_LOGIC_1164.ALL;entity registers_jiashu is Port ( input : in STD_LOGIC_vector(31

5、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)beginif(clkevent and clk=1) thenif (load=1) then x=input; -输入放入寄存器elsif (sh=1) then -移位x(30 downto 0)=x(31 downto 1);en

6、d 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_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;architect

7、ure Behavioral of registers_add issignal x:std_logic_vector(31 downto 0);beginprocess(clk)beginif(clkevent and clk=1) thenif(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.ST

8、D_LOGIC_1164.ALL;entity 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 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触发器-library IEEE;use

9、 IEEE.STD_LOGIC_1164.ALL;entity DFF is Port ( D : in STD_LOGIC; clk : in STD_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 (clkevent and clk=1) thenQ 0); signal inputB : std_logic_vector(31 downt

10、o 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 - Instantiate the Unit Under Test (UUT) uut: adder_32 PORT MAP ( inputA =

11、 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/2; end process; stim_proc: process begin-进行输入仿真 inputA=; - inputa= 73,inputB=; - inputb= 138,N=1; -N=1时开始计时,并开始下载数据w

12、ait for 32*clk_period;-32个时钟周期之后N=0; -N=0,停止数据下载,得出相加后的结果wait for 10*clk_period; - 延时10个时钟周期,进入下一轮仿真调试inputA=; - inputa= ,inputB=; - inputb= ,N=1; -N=1时开始计时,并开始下载数据wait for 32*clk_period;-32个时钟周期之后N=0; -N=0,停止数据下载,得出相加后的结果wait for 10*clk_period; - 延时10个时钟周期,进入下一轮仿真调试 wait; end process;END;四、实验数据与分析1、综合的电路: 设计图外观1:设计图外观2:1、控制器:2、全加器:3、移位寄存器: 4、累加器 2、仿真的波形图如下:情况一:inputa= 73,inputb= 138,outputa=211情况二:inputa= ,inputb= ,outputa=数据处理分析:每次从N=1开始,加法器进行数据下载,32个时钟周期之后,当N=0时,输出k=1,表示串行累加的过程结束,此时输出的结果即为加法器的最后结果。通过以上的波形可知,每次当k=1是,即输出一个结果,仿真波形验证了设计的正确性。五、实验结论

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论