我正在制作一个接收 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;