Estoy intentando crear una ALU parametrizable que maneja datos firmados de N-Bit. Sin embargo, los métodos que conozco de desplazamiento a la izquierda / derecha tampoco funcionarán porque los valores se definen como STD_LOGIC_VECTOR:
--Declaration
A, B, X : in STD_LOGIC_VECTOR(N downto 0);
--Usage
OUTPUT <= (A sra X) WHEN OPERATION = "0000" ELSE
O porque está dentro de una instrucción WHEN:
OUTPUT <= (A <= X(N) & X(N downto 1)) WHEN OPERATION = "1001" ELSE
--This causes Type of OUTPUT is incompatible with type of <= error
Para reiterar, necesito desplazar A / X bits de izquierda / derecha. ¿Podría alguien apuntarme en la dirección correcta?
Código completo:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use work.DigEng.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity core is
Generic (
N : INTEGER);
Port ( CLK : in STD_LOGIC;
A, B, X : in STD_LOGIC_VECTOR(N downto 0);
OPERATION : in STD_LOGIC_VECTOR(3 downto 0); --Allows us up to 16 operations
FLAGS : in STD_LOGIC_VECTOR(7 downto 0);
ALU_OUTPUT : out STD_LOGIC_VECTOR(N downto 0));
end core;
architecture Behavioral of core is
signal TEMP_OUTPUT : STD_LOGIC_VECTOR(N downto 0);
begin
TEMP_OUTPUT <= (A) WHEN OPERATION = "0000" ELSE
--Bit-wise Logic
(A AND B) WHEN OPERATION = "0001" ELSE
(A OR B) WHEN OPERATION = "0010" ELSE
(A XOR B) WHEN OPERATION = "0011" ELSE
(NOT A) WHEN OPERATION = "0100" ELSE
--Arithmetic
STD_LOGIC_VECTOR(SIGNED(A) + 1) WHEN OPERATION = "0101" ELSE
STD_LOGIC_VECTOR(SIGNED(A) - 1) WHEN OPERATION = "0110" ELSE
STD_LOGIC_VECTOR(SIGNED(A) + SIGNED(B)) WHEN OPERATION = "0111" ELSE
STD_LOGIC_VECTOR(SIGNED(A) - SIGNED(B)) WHEN OPERATION = "1000" ELSE
--Shift
--(A <= X(N) & X(N downto 1)) WHEN OPERATION = "1001" ELSE
"1111";
end Behavioral;