【问题标题】:VHDL No Function declaration for operator "-"VHDL 无运算符“-”的函数声明
【发布时间】:2020-06-15 07:37:51
【问题描述】:

所以我的任务是在 2 个向量(这里称为除数和除数)之间进行模运算,所以我需要的是除数模除数。 我们对这段代码有一些限制,就是不能使用iee_std_logic_1164、textio等。我认为唯一允许的库是IEEE和IEEE.numeric_bit

这个操作的算法告诉我:

while(dividendo >= divisor){
  dividendo = dividendo - divisor
 }
return dividendo

然后我写了这个 vhdl 文件:

 library IEEE;

entity resto is
port (clock , reset : in bit ;
    inicio : in bit ;
    fim : out bit ;
    dividendo , divisor : in bit_vector (15 downto 0) ;
    resto : out bit_vector (15 downto 0)
) ;
end resto;

architecture processo of resto is
  signal dividendo_n : bit_vector (15 downto 0) := dividendo;
  signal divisor_n : bit_vector (15 downto 0) := divisor;
  begin

        process (clock, reset)
        begin
            if reset = '1' then
                fim <= '0';
                resto <= "0000000000000000";
            elsif clock'event and clock = '1' and inicio = '1'  then
              if divisor = "0000000000000000" then
                fim <= '1';
                resto <= dividendo;
              else
                while ( dividendo_n >= divisor_n) loop
                  dividendo_n <= dividendo_n - divisor_n;
                  end loop;,

                resto <= dividendo_n;
            end if;
            end if;
            end process;
end processo;   

但我不断收到此错误:没有在线操作符“-”的函数声明

dividendo_n <= dividendo_n - divisor_n;

有什么想法吗?我是这门语言的初学者,所以我不太了解到底发生了什么。

提前致谢!

【问题讨论】:

  • 如果你想使用 ieee.numeric_bit,你应该使用(提示)它。然后查看它提供的功能(源代码可在 Internet 上获得,也可在您使用的任何工具集的本地安装中获得)。而且 - 由于您是初学者 - 建议从头开始:阅读一本关于 VHDL 的好书并首先学习基础知识。

标签: vhdl ghdl


【解决方案1】:

您只能在 VHDL 中对数字数据类型(如整数、无符号和有符号)使用数学运算。 bit_vector 类型不是数值类型,所以不能使用减法运算。

如果您仅限于使用 bit 或 bit_vector 类型,那么您将必须实现二进制减法器电路来执行此操作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-22
    • 1970-01-01
    相关资源
    最近更新 更多