VHDL实现四位加法器
1、实验目的:进一步练习VHDL语言设计工程的建立与仿真的步骤和方法、熟悉VHDL语言RTL描述方式的编写方法。
2、实验环境:PC个人计算机、Windows操作系统、Quartus II集成开发环境软件。
3、实验要求:设计一个四位加法器,实体名称为“adder4”,其引脚与功能如下表。
| 端口模式 | 端口名 | 数据类型 | 功能逻辑表达式 | 说明 |
|---|---|---|---|---|
| in输入 | a | std_logic_vector(3 downto 0) | 加数 | |
| in输入 | b | std_logic_vector(3 downto 0) | 加数 | |
| in输入 | ci | std_logic | 来自低位进位 | |
| out输出 | s | std_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输出 | co | std_logic | co<= (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;
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
