为什么我不能增加这个 `std_logic_vector` [英] Why can't I increment this `std_logic_vector`

查看:30
本文介绍了为什么我不能增加这个 `std_logic_vector`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是怎么回事?为什么我会收到运算符参数类型不匹配",我该怎么做才能解决这个问题?

What's going on here? Why am I getting an 'operator argument type mismatch', and what can I do to fix it?

--
-- 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 不能直接自增,需要将其转换为 unsigned 并返回到 std_logic_vectorcode> 使用 numeric_std 包.

you can't increment std_logic directly, you need to convert it to unsigned and the result back to std_logic_vector using the numeric_std package.

use ieee.numeric_std.all
...
nextvalue <= std_logic_vector( unsigned(value) + 1 );

例如如何使用 IEEE.NUMERIC_STD 执行 STD_LOGIC_VECTOR 加法.

这篇关于为什么我不能增加这个 `std_logic_vector`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆