32ビットの入力と7ビットの制御入力を取り込む部品を作っています。このコンポーネントが行うことは、S の最後の 2 ビットを調べて、
- S = 00、inp を左に論理シフトします
- S = 01、inp を右に論理シフトします
- S = 10、inp で算術シフトを行います
- S = 11、inp 上で右回転します
シフトの量/数は、S の最初の 5 ビットによって決定されます。たとえば、 の場合S=0001001
、入力は論理的に右に 2 桁シフトする必要があります。以下は私のコードです。次のエラーが表示される「sra」で問題が発生しています。
演算子「sra」の「0」定義が見つかりました。「sra」の正確なオーバーロードされた一致する定義を特定できません。私のコードは次のとおりです。
library IEEE;
use IEEE.STD_LOGIC_1164.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 barrelshifter is
port(
clk : in std_logic;
inp : in unsigned (31 downto 0):= (others => '0');
s : in unsigned (6 downto 0);
outp : out unsigned (31 downto 0)
);
end barrelshifter;
architecture Behavioral of barrelshifter is
signal samt : unsigned (4 downto 0);
signal stype : unsigned (1 downto 0);
signal inp1 : unsigned (31 downto 0);
begin
samt <= s(6 downto 2);
stype <= s(1 downto 0);
inp1 <= inp;
process(clk)
begin
if stype = "00" then
outp <= inp sll to_integer(samt);
end if;
if stype = "01" then
outp <= inp srl to_integer(samt);
end if;
if stype = "10" then
outp <= inp sra to_integer(samt);
end if;
if stype = "11" then
outp <= inp ror to_integer(samt);
end if;
end process;
end Behavioral;