这里发生了什么?为什么我得到一个’运算符参数类型不匹配’,我该怎么办来解决它?
-- -- 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;
谢谢
解决方法
您不能直接递增std_logic,您需要使用numeric_std包将其转换为unsigned,并将结果返回到std_logic_vector.
use ieee.numeric_std.all ... nextvalue <= std_logic_vector( unsigned(value) + 1 );
例如见How Do Perform STD_LOGIC_VECTOR Addition Using IEEE.NUMERIC_STD.