硬件描述语言实验三:四位加法器实验

1、实验目的:进一步练习VHDL语言设计工程的建立与仿真的步骤和方法、熟悉VHDL语言RTL描述方式的编写方法。

2、实验环境:PC个人计算机、Windows操作系统、Quartus II集成开发环境软件。

3、实验要求:设计一个四位加法器,实体名称为“adder4”,其引脚与功能如下表。

端口模式

端口名

数据类型

功能逻辑表达式

说明

in

输入

a

std_logic_vector

(3 downto 0)

加数

b

加数

ci

std_logic

来自低位进位

out

输出

s

std_logic_vector

(3 downto 0)

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)

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;”。

a、b、s等信号为std_logic_vector(3 downto 0)数据类型,是逻辑矢量,可以理解为一组信号,其中每一个信号用“信号名(位标)”表示,如“a(0)”。

library ieee;
use ieee.std_logic_1164.all;

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 ci;
c1<=(a(1) and b(1)) or (a(1) and ci) or (b(1) and ci);
s(2)<= a(2) xor b(2) xor ci;
c2<=(a(2) and b(2)) or (a(2) and ci) or (b(2) and ci);
co<=(a(3) and b(3)) or (a(3) and c2) or (b(3) and c2);
end rtl;

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值