并行加法器

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
--并行加法器
--  Uncomment the following lines to use the declarations that are
--  provided for instantiating Xilinx primitive components.
--library UNISIM;
--use UNISIM.VComponents.all;

entity bingxingjiafaqi is
    Port ( a : in std_logic_vector(3 downto 0);
           b : in std_logic_vector(3 downto 0);
           cin : in std_logic;
           s : out std_logic_vector(3 downto 0);
           cout : out std_logic);
end bingxingjiafaqi;

--这个实验中使用信号和变量有什么区别  ?????????
architecture Behavioral of bingxingjiafaqi is
signal c :std_logic_vector(4 downto 0);
signal d :std_logic_vector(3 downto 0);
signal t :std_logic_vector(3 downto 0);
begin
 
 g1:for i in 0 to 3 generate
  d(i) <= a(i) and b(i);
  t(i) <= a(i) or b(i);
  s(i) <= a(i) xor b(i) xor c(i);
 end generate;

 c(0) <= cin;
 c(1) <= d(0) or (t(0) and c(0));
 c(2) <= d(1) or (t(1) and d(0)) or (t(1) and t(0) and c(0));
 c(3) <= d(2) or (t(2) and d(1)) or (t(2) and t(1) and d(0)) or (t(2) and t(1) and t(0) and c(0));
 c(4) <= d(3) or (t(3) and d(2)) or (t(3) and t(2) and d(1)) or (t(3) and t(2) and t(1) and d(0)) or (t(3) and t(2) and t(1) and t(0) and c(0));
 cout <= c(4);

end Behavioral;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值