VHDL Suma Con Carry
VHDL Suma Con Carry
No se que parte del procesador es esta. Si es parte de la ALU, no entiendo por qué utilizan
flip-flop. La ALU es un circuito combinatorio.
Si son dos bloques, el sumador y un registro, me preocupa porque no se como se conecta
con el resto de bloques.
Y finalmente, es preferible usar una entidad full adder y hacer 16 instancias.
--******************************************************--
-- ORGANIZACIÓN DE COMPUTADORES --
-- Título: --
-- Fecha: --
--******************************************************--
library IEEE;
use IEEE.std_logic_1164.all;
library ALTERA;
use ALTERA.altera_primitives_components.all;
--******************************************************--
-- Comentarios --
-- --
-- --
--******************************************************--
entity Jmmm is
port(
enable: in std_logic;
Clk: in std_logic;
Reset: in std_logic;
Carry_in: in std_logic;
);
component dffe is
port(
q : out std_logic
);
begin
Sum(0)<= ((not Reg_a(0) and (Reg_b(0) xor Carry_in)) or (Reg_a(0) and not (Reg_b(0) xor Carry_in))) and
enable;
Carry(0)<= ((Carry_in and (Reg_a(0) xor Reg_b(0))) or (Reg_a(0) and Reg_b(0))) and enable;
Sum(1)<= ((not Reg_a(1) and (Reg_b(1) xor Carry(0))) or (Reg_a(1) and not (Reg_b(1) xor Carry(0)))) and
enable;
Carry(1)<= ((Carry(0) and (Reg_a(1) xor Reg_b(1))) or (Reg_a(1) and Reg_b(1))) and enable;
Sum(2)<= ((not Reg_a(2) and (Reg_b(2) xor Carry(1))) or (Reg_a(2) and not (Reg_b(2) xor Carry(1)))) and
enable;
Carry(2)<= ((Carry(1) and (Reg_a(2) xor Reg_b(2))) or (Reg_a(2) and Reg_b(2))) and enable;
Sum(3)<= ((not Reg_a(3) and (Reg_b(3) xor Carry(2))) or (Reg_a(3) and not (Reg_b(3) xor Carry(2)))) and
enable;
Carry(3)<= ((Carry(2) and (Reg_a(3) xor Reg_b(3))) or (Reg_a(3) and Reg_b(3))) and enable;
Sum(4)<= ((not Reg_a(4) and (Reg_b(4) xor Carry(3))) or (Reg_a(4) and not (Reg_b(4) xor Carry(3)))) and
enable;
Carry(4)<= ((Carry(3) and (Reg_a(4) xor Reg_b(4))) or (Reg_a(4) and Reg_b(4))) and enable;
Sum(5)<= ((not Reg_a(5) and (Reg_b(5) xor Carry(4))) or (Reg_a(5) and not (Reg_b(5) xor Carry(4)))) and
enable;
Carry(5)<= ((Carry(4) and (Reg_a(5) xor Reg_b(5))) or (Reg_a(5) and Reg_b(5))) and enable;
Sum(6)<= ((not Reg_a(6) and (Reg_b(6) xor Carry(5))) or (Reg_a(6) and not (Reg_b(6) xor Carry(5)))) and
enable;
Sum(7)<= ((not Reg_a(7) and (Reg_b(7) xor Carry(6))) or (Reg_a(7) and not (Reg_b(7) xor Carry(6)))) and
enable;
Carry(7)<= ((Carry(6) and (Reg_a(7) xor Reg_b(7))) or (Reg_a(7) and Reg_b(7))) and enable;
Sum(8)<= ((not Reg_a(8) and (Reg_b(8) xor Carry(7))) or (Reg_a(8) and not (Reg_b(8) xor Carry(7)))) and
enable;
Carry(8)<= ((Carry(7) and (Reg_a(8) xor Reg_b(8))) or (Reg_a(8) and Reg_b(8))) and enable;
Sum(9)<= ((not Reg_a(9) and (Reg_b(9) xor Carry(8))) or (Reg_a(9) and not (Reg_b(9) xor Carry(8)))) and
enable;
Carry(9)<= ((Carry(8) and (Reg_a(9) xor Reg_b(9))) or (Reg_a(9) and Reg_b(9))) and enable;
Sum(10)<= ((not Reg_a(10) and (Reg_b(10) xor Carry(9))) or (Reg_a(10) and not (Reg_b(10) xor Carry(9))))
and enable;
Carry(10)<= ((Carry(9) and (Reg_a(10) xor Reg_b(10))) or (Reg_a(10) and Reg_b(10))) and enable;
Sum(11)<= ((not Reg_a(11) and (Reg_b(11) xor Carry(10))) or (Reg_a(11) and not (Reg_b(11) xor
Carry(10)))) and enable;
Carry(11)<= ((Carry(10) and (Reg_a(11) xor Reg_b(11))) or (Reg_a(11) and Reg_b(11))) and enable;
Sum(12)<= ((not Reg_a(12) and (Reg_b(12) xor Carry(11))) or (Reg_a(12) and not (Reg_b(12) xor
Carry(11)))) and enable;
Carry(12)<= ((Carry(11) and (Reg_a(12) xor Reg_b(12))) or (Reg_a(12) and Reg_b(12))) and enable;
Sum(13)<= ((not Reg_a(13) and (Reg_b(13) xor Carry(12))) or (Reg_a(13) and not (Reg_b(13) xor
Carry(12)))) and enable;
Carry(13)<= ((Carry(12) and (Reg_a(13) xor Reg_b(13))) or (Reg_a(13) and Reg_b(13))) and enable;
Sum(14)<= ((not Reg_a(14) and (Reg_b(14) xor Carry(13))) or (Reg_a(14) and not (Reg_b(14) xor
Carry(13)))) and enable;
Carry(14)<= ((Carry(13) and (Reg_a(14) xor Reg_b(14))) or (Reg_a(14) and Reg_b(14))) and enable;
Sum(15)<= ((not Reg_a(15) and (Reg_b(15) xor Carry(14))) or (Reg_a(15) and not (Reg_b(15) xor
Carry(14)))) and enable;
Carry(15)<= ((Carry(14) and (Reg_a(15) xor Reg_b(15))) or (Reg_a(15) and Reg_b(15))) and enable;
A<=Q;
Carry_out<=Carry(15);
End JmmmArch;
--******************--
-- PONTIFICIA UNIVERSIDAD JAVERIANA --
-- ORGANIZACIÓN DE COMPUTADORES --
--******************--
--Definicion de las bibliotecas
library IEEE;
use IEEE.std_logic_1164.all;
library ALTERA;
use ALTERA.altera_primitives_components.all;
--******************--
-- Comentarios --
-- --
-- --
--******************--
entity Suma is
port(
--DECLARACION DE ENTRADAS Y SALIDAS DEL BLOQUE
Reg_a: in std_logic;
Reg_b: in std_logic;
Carry_in: in std_logic;
Sum: out std_logic;
Carry: out std_logic
);
end Entity Suma;
begin
Sum<= ((not Reg_a and (Reg_b xor Carry_in)) or (Reg_a and not (Reg_b xor Carry_in)));
Carry<= ((Carry_in and (Reg_a xor Reg_b)) or (Reg_a and Reg_b));
End SumaArch;
--******************--
-- PONTIFICIA UNIVERSIDAD JAVERIANA --
-- ORGANIZACIÓN DE COMPUTADORES --
--******************--
--Definicion de las bibliotecas
library IEEE;
use IEEE.std_logic_1164.all;
library ALTERA;
use ALTERA.altera_primitives_components.all;
--******************--
-- Comentarios --
-- --
-- --
--******************--
entity Suma is
port(
--DECLARACION DE ENTRADAS Y SALIDAS DEL BLOQUE
Reg_a: in std_logic;
Reg_b: in std_logic;
Carry_in: in std_logic;
Sum: out std_logic;
Carry: out std_logic
);
end Entity Suma;
begin
Sum<= ((not Reg_a and (Reg_b xor Carry_in)) or (Reg_a and not (Reg_b xor Carry_in)));
Carry<= ((Carry_in and (Reg_a xor Reg_b)) or (Reg_a and Reg_b));
End SumaArch;
JESSICA LORENA CASTILLO
CAMILO HERNANDEZ TABET
NATALIA MORALES VARÓN
Fecha: 07/05/2020
--******************--
-- Comentarios --
-- --
-- --
--******************--
entity Jmmm is
port(
--DECLARACION DE ENTRADAS Y SALIDAS DEL BLOQUE
Reg_a: in std_logic_vector (15 downto 0);
Reg_b: in std_logic_vector (15 downto 0);
Resta: in std_logic;
A: out std_logic_vector (15 downto 0);
Carry_out: out std_logic
);
end Entity Jmmm;
begin
A<=Sum;
Carry_out<=Carry(15);
End JmmmArch;
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.numeric_std.all;
ENTITY A2COMPLEMENT IS
PORT ( a : in
std_logic_vector(15 DOWNTO 0);
INVERT : out
std_logic_vector(15 DOWNTO 0));
END ENTITY A2COMPLEMENT;
ARCHITECTURE generic_arch OF A2COMPLEMENT IS
BEGIN
Tiene una señal llamada resta, que identifica si se quiere sumar o restar.
Si la señal resta esta en 0 suma y si la señal resta esta en 1 resta, como se puede apreciar en
la simulacion anterior.