不理解numeric_std to_unsigned函数调用、所选信号分配的错误消息



我设计了一个简单的移位器,但我得到了一个错误,我应用了不同的很多东西来解决,然后它还没有被修复。

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
--use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;
--use ieee.std_logic_unsigned.all;

entity shifter is
Port ( inp          : in STD_LOGIC_VECTOR(7 downto 0);
shift_cntrl  : in STD_LOGIC_VECTOR(1 downto 0);
shift_out    : out STD_LOGIC_VECTOR(15 downto 0));
end shifter;
architecture Behavioral of shifter is
begin
process(shift_cntrl, inp) begin
with shift_cntrl select  
shift_out <= STD_LOGIC_VECTOR(to_unsigned(inp, shift_out'LENGTH) sll 4) when "01", 
STD_LOGIC_VECTOR(to_unsigned(inp, shift_out'LENGTH) sll 8) when "10",  
inp when others;

end process;
end Behavioral;

VHDL错误信息:

[Synth 8-2778] type error near inp ; expected type natural [shifter.vhd:18]
[Synth 8-2778] type error near inp ; expected type natural [shifter.vhd:19]
[Synth 8-2757] this construct is only supported in VHDL 1076-2008 [shifter.vhd:20]

with..select仅在文件模式设置为VHDL 2008时在进程内被支持。要么将Vivado中的文件模式设置为2008,要么简单地删除with..select语句周围的进程,因为它不需要。

std_logic_vector不存在to_unsigned函数。因为它是类似的类型,所以可以进行类型转换:

STD_LOGIC_VECTOR(unsigned(inp) sll 4);

最新更新