Estoy diseñando una ALU simple para mi propia que usa 2 bits para las operaciones select
. Supongamos que mis operaciones son las siguientes:
00 C <= A & B
01 C <= A + B
10 C <= NOT (A)
11 C <= '0' & A (7 DOWNTO 1)
Y mi ALU
contiene dos registros para la entrada con carga habilitada LE
y un registro de salida con carga habilitada LE
y control de salida OC
. En primer lugar, diseño un registro de entrada usando VHDL Module
como se muestra a continuación:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity RegIn is
PORT (
LE: IN STD_LOGIC;
INPUT: IN STD_LOGIC_VECTOR (7 DOWNTO 0);
OUTPUT: OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
);
end RegIn;
architecture Behavioral of RegIn is
begin
PROCESS (LE)
BEGIN
IF (LE = '1') THEN
OUTPUT <= INPUT;
END IF;
END PROCESS;
end Behavioral;
Cuando, LE
es alto, se colocará INPUT en lugar del valor de SALIDA. Tengo dos nombres de registro de entrada TEMP1
y TEMP2
. Diseño el registro de salida utilizando el registro de entrada, excepto que contiene OC
señal como control de búfer. Se muestra en continuar:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity RegOut is
PORT (
LE, OC: IN STD_LOGIC;
INPUT: IN STD_LOGIC_VECTOR (7 DOWNTO 0);
OUTPUT: OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
);
end RegOut;
architecture Behavioral of RegOut is
SIGNAL INPUT_OUTPUT: STD_LOGIC_VECTOR (7 DOWNTO 0);
COMPONENT RegIn
PORT (
INPUT: IN STD_LOGIC_VECTOR (7 DOWNTO 0);
OUTPUT: OUT STD_LOGIC_VECTOR (7 DOWNTO 0);
LE: IN STD_LOGIC
);
END COMPONENT;
begin
RPM:
RegIn PORT MAP (
INPUT => INPUT,
OUTPUT => INPUT_OUTPUT,
LE => LE
);
PROCESS (OC)
BEGIN
IF (OC = '1') THEN
OUTPUT <= INPUT_OUTPUT;
ELSE
OUTPUT <= "ZZZZZZZZ";
END IF;
END PROCESS;
end Behavioral;
Ahora, quiero implementar mi ALU
usando el código siguiente:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity ALU is
Port (
TEMP_1_LE: IN STD_LOGIC;
TEMP_2_LE: IN STD_LOGIC;
TEMP_3_LE: IN STD_LOGIC;
TEMP_3_OC: IN STD_LOGIC;
TEMP_1_IN: IN STD_LOGIC_VECTOR (7 DOWNTO 0);
TEMP_2_IN: IN STD_LOGIC_VECTOR (7 DOWNTO 0);
C: IN STD_LOGIC_VECTOR (1 DOWNTO 0);
CF: OUT STD_LOGIC;
ZF: OUT STD_LOGIC;
SF: OUT STD_LOGIC;
TEMP_3_OUT: OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
);
end ALU;
architecture Behavioral of ALU is
COMPONENT RegIn IS
PORT (
LE: IN STD_LOGIC;
INPUT: IN STD_LOGIC_VECTOR (7 DOWNTO 0);
OUTPUT: OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
);
END COMPONENT;
COMPONENT RegOut IS
PORT (
LE, OC: IN STD_LOGIC;
INPUT: IN STD_LOGIC_VECTOR (7 DOWNTO 0);
OUTPUT: OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
);
END COMPONENT;
SIGNAL TEMP_1_OUT, TEMP_2_OUT, TEMP_3_IN: STD_LOGIC_VECTOR (7 DOWNTO 0);
SIGNAL TEMP: STD_LOGIC_VECTOR (8 DOWNTO 0);
begin
RTEMP1:
RegIn PORT MAP (
LE => TEMP_1_LE,
INPUT => TEMP_1_IN,
OUTPUT => TEMP_1_OUT
);
RTEMP2:
RegIn PORT MAP (
LE => TEMP_2_LE,
INPUT => TEMP_2_IN,
OUTPUT => TEMP_2_OUT
);
RTEMP3:
RegOut PORT MAP (
LE => TEMP_3_LE,
OC => TEMP_3_OC,
INPUT => TEMP_3_IN,
OUTPUT => TEMP_3_OUT
);
PROCESS(TEMP_3_OC)
BEGIN
IF (TEMP_3_OC = '1') THEN
TEMP_3_IN <= TEMP_1_OUT + TEMP_2_OUT;
...
END IF;
END PROCESS;
end Behavioral;
En mi banco de pruebas, fuerzo TEMP_3_OC a '1' pero no cambia a '1' y sigue siendo '0'.
¿Qué estaba mal? ¿Cómo puedo corregirlo?
Gracias de antemano :)