|
发表于 2009-12-12 16:24:51
|
显示全部楼层
--能通过,结果没仿真,没打键所以大小写有点乱
------------------------1位加法器
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
ENTITY madd1 IS
PORT
(A: IN STD_LOGIC;
B: in STD_LOGIC;
c: IN STD_LOGIC;
Carry: inout STD_LOGIC;
SuM: out STD_LOGIC);
END madd1;
architecture MAXCPLD of madd1 is
BEGIN
Sum <= A XOR B XOR C;
Carry<=(a and b)or(a and c)or(b and c);
end MAXCPLD;
--------------4个madd1组成4位
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
ENTITY madd4 IS
PORT (A,B: IN STD_LOGIC_VECTOR(3 DOWNTO 0);
S: OUT STD_LOGIC_VECTOR(3 DOWNTO 0);
C: INOUT STD_LOGIC_VECTOR(4 DOWNTO 0)
);
END madd4;
--------------------------------
architecture MAXCPLD of madd4 is
COMPONENT madd1
PORT (a: IN STD_LOGIC;
b: in STD_LOGIC;
c: IN STD_LOGIC;
carry: inout STD_LOGIC;
suM: out STD_LOGIC);
end COMPONENT;
BEGIN
u0:madd1 port map (A(0),B(0),C(0),C(1),S(0));
u1:madd1 port map (A(1),B(1),C(1),C(2),S(1));
u2:madd1 port map (A(2),B(2),C(2),C(3),S(2));
u3:madd1 port map (A(3),B(3),C(3),C(4),S(3));
C(0)<='0';
end MAXCPLD; |
|