procesador de 4 bits para operaciones aritmeticologicas
bases de la implementacion, en codigo vhdl se realizo las diferenjtes etapas del procesador como una maquina de estados un memoria rom y un selector para poder ejecutar la operacion
apartes del codigo
entity ALU_4BITs is
Port ( A,B : in STD_LOGIC_vector (3 downto 0);
operacion : in std_logic_vector (3 downto 0);
acarreosalida : out STD_LOGIC;
bandera : out STD_LOGIC;
resultado : out STD_LOGIC_VECTOR (3 downto 0)
);
end ALU_4BITs;
architecture Behavioral of ALU_4BITs is
signal temporal : STD_LOGIC_VECTOR(4 downto 0);
begin
process(A,B,operacion,temporal) is
begin
bandera <= '0';
case operacion is
when "0000" => temporal <= std_logic_vector(unsigned( "0" & A) +unsigned(B));
resultado <= temporal(3 downto 0);
acarreosalida <= temporal(4);
when "0001" =>
if (A >= B) then
resultado <= std_logic_vector(unsigned (A) - unsigned(B));
bandera <= '0';
else
resultado <= std_logic_vector(unsigned (B) - unsigned(A));
bandera <='1';
end if;
when "0010"=> resultado <= A and B;
when "0011"=> resultado <= A or B;
when "0100"=> resultado <= A xor B;
when "0101"=> resultado <= not B;
when "0110"=>
Port ( A,B : in STD_LOGIC_vector (3 downto 0);
operacion : in std_logic_vector (3 downto 0);
acarreosalida : out STD_LOGIC;
bandera : out STD_LOGIC;
resultado : out STD_LOGIC_VECTOR (3 downto 0)
);
end ALU_4BITs;
architecture Behavioral of ALU_4BITs is
signal temporal : STD_LOGIC_VECTOR(4 downto 0);
begin
process(A,B,operacion,temporal) is
begin
bandera <= '0';
case operacion is
when "0000" => temporal <= std_logic_vector(unsigned( "0" & A) +unsigned(B));
resultado <= temporal(3 downto 0);
acarreosalida <= temporal(4);
when "0001" =>
if (A >= B) then
resultado <= std_logic_vector(unsigned (A) - unsigned(B));
bandera <= '0';
else
resultado <= std_logic_vector(unsigned (B) - unsigned(A));
bandera <='1';
end if;
when "0010"=> resultado <= A and B;
when "0011"=> resultado <= A or B;
when "0100"=> resultado <= A xor B;
when "0101"=> resultado <= not B;
when "0110"=>
shematic
implemantacion en clase