8 BITS, ADDER Y SUBTRACTOR
La implementación de un circuito sumador restador sin restricción de 8bits, en el cual no intereso el la operación que se pida, si esta es suma, este sumador va a realizar la suma de A y B. Si se selecciona resta, este sumador va a realizar el calculo del complemento A1 para el numero B que se ingrese, realizara la suma y si A es mayor a B, el resultado que se obtenga va a ser correcto. Pero si se selecciona resta y el numero B es mayor a A, al resultado que de el sumador se tendrá que calcular el complemento A2 para que de el resultado correcto de la resta, pero en este caso tendrá un bit de salida activo que indicara que el resultado es negativo.
PROGAMA EN XILINX
XILINX
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity adderandsubstractor is
Port ( x1 : in STD_LOGIC;
x2 : in STD_LOGIC;
x3 : in STD_LOGIC;
x4 : in STD_LOGIC;
x5 : in STD_LOGIC;
x6 : in STD_LOGIC;
x7 : in STD_LOGIC;
x8 : in STD_LOGIC;
x9 : in STD_LOGIC;
x10 : in STD_LOGIC;
x11 : in STD_LOGIC;
x12 : in STD_LOGIC;
x13 : in STD_LOGIC;
x14 : in STD_LOGIC;
x15 : in STD_LOGIC;
x16 : in STD_LOGIC;
PM : in STD_LOGIC;
s1 : out STD_LOGIC;
s2 : out STD_LOGIC;
s3 : out STD_LOGIC;
s4 : out STD_LOGIC;
s5 : out STD_LOGIC;
s6 : out STD_LOGIC;
s7 : out STD_LOGIC;
s8 : out STD_LOGIC;
cout : out STD_LOGIC);
end adderandsubstractor;
architecture Behavioral of adderandsubstractor is
component bits8adderandsubtractor is
Port ( x1 : in STD_LOGIC;
x2 : in STD_LOGIC;
x3 : in STD_LOGIC;
x4 : in STD_LOGIC;
x5 : in STD_LOGIC;
x6 : in STD_LOGIC;
x7 : in STD_LOGIC;
x8 : in STD_LOGIC;
x9 : in STD_LOGIC;
x10 : in STD_LOGIC;
x11 : in STD_LOGIC;
x12 : in STD_LOGIC;
x13 : in STD_LOGIC;
x14 : in STD_LOGIC;
x15 : in STD_LOGIC;
x16 : in STD_LOGIC;
PM : in STD_LOGIC;
y1 : out STD_LOGIC;
y2 : out STD_LOGIC;
y3 : out STD_LOGIC;
y4 : out STD_LOGIC;
y5 : out STD_LOGIC;
y6 : out STD_LOGIC;
y7 : out STD_LOGIC;
y8 : out STD_LOGIC;
y9 : out STD_LOGIC;
y10 : out STD_LOGIC;
y11 : out STD_LOGIC;
y12 : out STD_LOGIC;
y13 : out STD_LOGIC;
y14 : out STD_LOGIC;
y15 : out STD_LOGIC;
y16 : out STD_LOGIC);
end component;
component sumadorde4bits is
Port ( a1 : in STD_LOGIC;
a2 : in STD_LOGIC;
a3 : in STD_LOGIC;
a4 : in STD_LOGIC;
b1 : in STD_LOGIC;
b2 : in STD_LOGIC;
b3 : in STD_LOGIC;
b4 : in STD_LOGIC;
s1 : out STD_LOGIC;
s2 : out STD_LOGIC;
s3 : out STD_LOGIC;
s4 : out STD_LOGIC;
ci : out STD_LOGIC);
end component;
component sumadores4bitscompletos is
Port ( a1 : in STD_LOGIC;
a2 : in STD_LOGIC;
a3 : in STD_LOGIC;
a4 : in STD_LOGIC;
b1 : in STD_LOGIC;
b2 : in STD_LOGIC;
b3 : in STD_LOGIC;
b4 : in STD_LOGIC;
cin : in STD_LOGIC;
s1 : out STD_LOGIC;
s2 : out STD_LOGIC;
s3 : out STD_LOGIC;
s4 : out STD_LOGIC;
cout : out STD_LOGIC);
end component;
SIGNAL c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17 :STD_LOGIC;
begin
U0: bits8adderandsubtractor PORT MAP (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, PM, c1,
c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16);
U1: sumadorde4bits PORT MAP (c1, c2, c3, c4, c5, c6, c7, c8, s1, s2, s3, s4 ,c17);
U2: sumadores4bitscompletos PORT MAP (c9, c10, c11, c12, c13, c14, c15, c16, c17, s5, s6, s7, s8, cout);
end Behavioral;
Comentarios
Publicar un comentario