Hola!!
Siento el retraso en contestar, estoy muy liada....
A ver, revisando mis papelotes aparece un modelo de ALU que debí hacer hace un tiempo. Te lo pongo por aquí por si te puede ayudar y darte pistas de cómo hacer la tuya. Ya verás que no es complicado, anda, anímate, que lo que te puso el profesor está "escondido", pero no es muy oscuro...
Codigo:
;DEFINICIÓN DE LA ENTIDAD
library ieee;
use ieee.std_logic_1164.all;
use work.alu_types.all;
entity alu is
port ( a1, a2 : in std_ulogic_vector;
resultado : out std_ulogic_vector;
funcion : in alu_func;
cero, negativa, overflow : out std_ulogic );
end entity alu;
;PAQUETE CON LOS COMPONENTES
library ieee;
use ieee.std_logic_1164.all;
package alu_types is
subtype alu_func is std_ulogic_vector(3 downto 0);
constant alu_add : alu_func := "0000";
constant alu_addu : alu_func := "0001";
constant alu_sub : alu_func := "0010";
constant alu_subu : alu_func := "0011";
end package alu_types;
; Y POR ULTIMO EL COMPORTAMIENTO
architecture behavior of alu is
begin
alu_op: process (a1, a2, func) is
constant Tpd : delay_length := 10 ns;
variable bv_s1 : bit_vector(s1"range);
variable bv_s2 : bit_vector(s2"range);
variable temp_result : bit_vector(result"range);
constant cero_result : bit_vector(result"range) := (others => "0");
variable temp_overflow : boolean;
type boolean_to_X01_table is array (boolean) of X01;
constant boolean_to_X01 : boolean_to_X01_table
:= ( false => "0", true => "1" );
begin
bv_s1 := To_bitvector(s1);
bv_s2 := To_bitvector(s2);
case funcion is
when alu_add =>
bv_add(bv_s1, bv_s2, temp_result, temp_overflow);
when alu_addu =>
bv_addu(bv_s1, bv_s2, temp_result, temp_overflow);
when alu_sub =>
bv_sub(bv_s1, bv_s2, temp_result, temp_overflow);
when alu_subu =>
bv_subu(bv_s1, bv_s2, temp_result, temp_overflow);
when others =>
report "alu: funcionamient erroneo" severity error;
temp_result := (others => "0"); temp_overflow := false;
end case;
resultado <= To_X01(temp_result) after Tpd;
cero <= boolean_to_X01(temp_result = zero_result) after Tpd;
negativa <= To_X01(temp_result(temp_result"left)) after Tpd;
overflow <= boolean_to_X01(temp_overflow) after Tpd;
end process alu_op;
end architecture behavior;