加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

vhdl – 为什么我不能增加这个`std_logic_vector`

发布时间:2020-12-14 17:48:27 所属栏目:Java 来源:网络整理
导读:这里发生了什么?为什么我得到一个’运算符参数类型不匹配’,我该怎么办来解决它? ---- 32-bit counter with enable and async reset--architecture synthesis1 of counter_32bit is signal nextvalue : std_logic_vector ( 31 downto 0 ); begin -- -- com
这里发生了什么?为什么我得到一个’运算符参数类型不匹配’,我该怎么办来解决它?
--
-- 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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读