1 / 7
文档名称:

VHDL四位加法器实验报告.doc

格式:doc   大小:171KB   页数:7页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

VHDL四位加法器实验报告.doc

上传人:qiang19840906 2020/12/20 文件大小:171 KB

下载得到文件列表

VHDL四位加法器实验报告.doc

文档介绍

文档介绍:硬件描述语言实验:四位加法器实验
实验人姓名: 王 昭
学号:
实验地点: B3-216
实验三:
-- Quartus II VHDL Template
-- Basic Shift Register
library ieee;
use ;
entity adder4 is
port
(
a ,b : in std_logic_vector (3 downto 0);
ci : in std_logic;
s : out std_logic_vector (3 downto 0);
co :out std_logic
);
end entity;
architecture rtl of adder4 is
signal c0,c1,c2 : std_logic;
begin

s(0) <= a (0) xor b(0) xor ci;
c0<= (a(0) and b(0)) or (a(0) and ci) or (b(0) and ci);
s(1)<=a(1) xor b(1) xor c0;
c1<=(a(1) and b(1)) or (a(1) and c0) or (b(1) and c0);
s(2)<=a(2) xor b(2) xor c1;
c2<= (a(2) and b(2)) or (a(2) and c1) or (b(2) and c1);
s(3)<=a(3) xor b(3) xor c2;

co<= (a(3) and b(3)) or (a(3) and c2) or (b(3) and c2);
end rtl;
实验原理:
a和b为两个四位的数,定义三个信号量,c0,c1,c2;低位进位si=0;
s(0)=a(0)+b(0)+si;进位为c0;
s(1)=a(1)+b(1)+c0;进位为c1;
s(2)=a(2)+b(2)+c1;进位为c2;
s(3)=a(3)+b(3)+c2;进位为co;
低位进位si都为0;
如果a+b的值大于15时,则co为1,s=a+b-16;
如果不是大于15,则相加时则s=a+b的值,co=0;经仿真可以验证此四位加法器正确。
实验四:
-- Quartus II VHDL Template
-- Basic Shift Register
library ieee;
use ;
use ;
entity adder4_2 is
port
(
a,b : std_logic_vector(3 downto 0);
ci : in std_logic;
s :out std_logic_vector(3 downto 0);
co : out std_logic
);
end entity;
ar