VHDL实现四位加法器

1、实验目的:进一步练习VHDL语言设计工程的建立与仿真的步骤和方法、熟悉VHDL语言RTL描述方式的编写方法。
2、实验环境:PC个人计算机、Windows操作系统、Quartus II集成开发环境软件。
3、实验要求:设计一个四位加法器,实体名称为“adder4”,其引脚与功能如下表。

端口模式端口名数据类型功能逻辑表达式说明
in输入astd_logic_vector(3 downto 0)加数
in输入bstd_logic_vector(3 downto 0)加数
in输入cistd_logic来自低位进位
out输出sstd_logic_vector(3 downto 0)s(0) <= a (0) xor b(0) xor cic0<= (a(0) and b(0)) or (a(0) and ci) or (b(0) and ci)加数
out输出costd_logicco<= (a(3) and b(3)) or (a(3) and c2) or (b(3) and c2)加数

4、实验步骤:①建立工程、②编辑代码、③编译及修改错误、④建立仿真波形并仿真、⑤根据仿真结果分析设计是否正确。
提示:模块内部(构造体说明部分)需要定义三个连接线,定义语句为:
signal c0,c1,c2 : std_logic

说明:xzfc是我的工程名,有需要替换即可


LIBRARY IEEE;
use ieee.std_logic_1164.all;entity xzfc 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 aqjq of xzfc isSIGNAL 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 architecture aqjq;


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部