这里发生了什么?为什么我得到'运算符参数类型不匹配',我该怎么做才能修复它?
--
-- 32-bit counter with enable and async reset
--
architecture synthesis1 of counter_32bit is
signal nextvalue : std_logic_vector ( 31 downto 0 );
begin
--
-- combo
--
nextvalue <= value + 1; -- here
--
-- sequential
--
ff:process( clk, rst )
begin
if( rst = '1' ) then
value <= 0; -- and here...
elsif( clk'event and ( clk ='1' ) ) then
if( ena = '1' ) then
value <= nextvalue;
end if;
end if;
end process ff;
end synthesis1;
Run Code Online (Sandbox Code Playgroud)
谢谢
dan*_*poe 24
你不能直接增加std_logic,你需要将其转换unsigned为结果并返回std_logic_vector使用numeric_std包.
use ieee.numeric_std.all
...
nextvalue <= std_logic_vector( unsigned(value) + 1 );
Run Code Online (Sandbox Code Playgroud)
例如,参见如何使用IEEE.NUMERIC_STD执行STD_LOGIC_VECTOR添加.
试试这个代码:
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
...
nextvalue <= value + "1";
Run Code Online (Sandbox Code Playgroud)
在我的情况下,这个解决方案是有效的!