从整数
减去std_logic_vector我减去从整数STD_LOGIC_VECTOR问题。从整数
这是我现在所拥有的代码:
entity ROM is
Port ( hcount: in STD_LOGIC_VECTOR(9 downto 0);
vcount: in STD_LOGIC_VECTOR(9 downto 0);
hpos: in integer;
vpos: in integer;
clk25: in STD_LOGIC;
Pixeldata: out std_logic);
end ROM;
architecture Behavioral of ROM is
signal romtemp : std_logic_vector(9 downto 0);
shared variable yas : integer range 0 to 9 := 0;
shared variable xas : integer range 0 to 9 := 0;
Type RomType is array (9 downto 0) of std_logic_vector(9 downto 0);
Constant Rom: RomType :=
("0001111000", "0111111110", "0111111110", "1111111111", "1111111111"
, "1111111111", "1111111111", "0111111110", "0111111110", "0001111000");
begin
process(clk25)
begin
if(hpos > hcount - 10) and (hpos <= hcount) and (vpos > vcount - 10) and (vpos <= vcount) then
xas := hpos - to_integer(unsigned(hcount));
end if;
end process;
end Behavioral;
的问题是下面一行代码:
xas := hpos - to_integer(unsigned(hcount));
我试图把在整数名为XAS减法。该行发生
以下错误:
Error: Multiple declarations of unsigned included via multiple use clauses; none are made directly visible
Error: Expecting type unsigned for < unsigned(hcount) >.
Error: Formal < arg > has no actual or default value.
Error: Type integer is not an array type and cannot be indexed
Error: found '0' definitions of operator "=", cannot determine exact overload matching definition for "-"
有人可以帮助我这个错误? (我在VHDL初学者)
您没有在文件的顶部包含您的use
条款,但这个错误是什么的意思是,从use
条款,它发现的unsigned
两个不同的定义。因此,该工具忽略了这两个定义,产生了一个错误并迫使您处理该问题。
最可能的解释是,你必须:
use ieee.numeric_std.all;
use ieee.std_logic_arith.all;
std_logic_arith
是非标准的,你应该实现在使用仅numeric_std
可用的类型和功能设计。删除std_logic_arith
行。
在一般情况下,如果事情是一个数字,使用数字类型来代表它。例如,您的hcount
和vcount
投入显然是柜台,并且可以使用类型unsigned
。如果您在第一时间使用更为合适的类型,你避免了尴尬的寻找类型转换的需要,例如:
xas := hpos - to_integer(unsigned(hcount));
将成为
xas := hpos - hcount;
代码中的其他问题:
- 您的进程敏感性列表仅包含
clk25
,但该进程实际上并不是同步进程ocess,并且因此所有的使用应该是在列表中(或者可以使用保留的all
关键字来生成自动列表,即process(all)
)的输入信号。 - 除非这是一些特殊的情况下,你最好进入编写同步过程的习惯。这些看起来是这样的:
process(clk)
begin
if (rising_edge(clk)) then
-- Do things
end if;
end process;
-
xas
是一个共享变量,这意味着你可能在其他进程进行分配的。这可能不会如你所期望的那样工作。你应该避免共享变量完全,直到你有他们究竟是如何工作的一个很好的了解,当它可能是适当的使用它们。
最后一项非常重要。尽量不要使用共享变量,除非你知道你在做什么。在流程范围中使用变量,或者在体系结构范围内使用信号。如果这不符合你想要达到的目标,那么我希望你来自不同的编程语言。 VHDL是一种硬件设计语言:代码中可能存在很多,但最终还是需要将其视为寄存器和逻辑。并非一切都可能存在,例如零传播延迟。 – JHBonarius