library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity leftshift is
Port ( Din : in STD_LOGIC_VECTOR (31 downto 0);
Dout : out STD_LOGIC_VECTOR (31 downto 0));
end leftshift;
architecture Behavioral of leftshift is
signal t1: std_logic_vector (33 downto 0);
begin
t1 <= Din sll 2;
Dout <= t1(33 downto 2)
end Behavioral;,这是我的代码,但我不知道为什么会出错。
找到运算符"sll“的”0“定义,无法确定"sll”的确切重载匹配定义
我也试过使用<= Din 2,但是它仍然不起作用。请帮帮我,
发布于 2015-07-17 13:17:44
另一种向左移动的方法(例如,在16位单词上):
VECT <= VECT(14 DOWNTO 0) & '0';发布于 2014-02-21 17:55:32
正如瑞克在他的回答中指出的那样,直到2008年VHDL才能在std_logic_vector上实现std_logic_vector,而这在许多现有的现代FPGA和ASIC工具链中并不是很好的支持(很遗憾的是,可能永远也不会)。
一个简单的解决方法是从unsigned转换到标准的ieee.numeric_std类型,然后执行转换,然后转换回std_logic_vector
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
-- use IEEE.STD_LOGIC_UNSIGNED.ALL; -- remove this non-standard package
...
t1 <= std_logic_vector(unsigned(Din) sll 2);发布于 2013-11-17 14:51:59
移位操作符(包括sll)是在std_logic_vectors中定义的。如果您想使用它们,只需告诉您的编译器您正在使用此版本的VHDL。
除此之外,您的代码中还有一个错误:您试图将32位值分配给34位信号(在line t1 <= Din sll 2;上)。可以通过将违规行更改为t1 <= (Din sll 2) & "00";来解决这一问题。
除此之外,您的代码没有任何问题。我通过Modelsim Altera SE 10.1b运行它,它编译并正确工作。你能告诉我们你使用的是什么工具版本吗?
最后,这里是您的代码的一个更干净的版本,没有任何辅助信号。
library ieee;
use ieee.std_logic_1164.all;
entity shift_left_by_two is
port (
Din: in std_logic_vector(31 downto 0);
Dout: out std_logic_vector(31 downto 0)
);
end;
architecture behavioral of shift_left_by_two is
begin
Dout <= Din sll 2;
end behavioral;https://stackoverflow.com/questions/20024887
复制相似问题