VHDL No Function declaration for operator “-”

六眼飞鱼酱① 提交于 2020-08-10 23:42:34

问题


So i have a task to do the mod operation between 2 vectors(called here dividendo and divisor), so what i need is dividendo mod divisor. We have some restrictions on this code, that is, we cant use iee_std_logic_1164, textio, etc. I think the only libraries allowed are IEEE and IEEE.numeric_bit

The algorithm to this operation tells me to:

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

And then i wrote this vhdl file:

 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;   

But i keep getting this error: No Function declaration for operator "-" on line

dividendo_n <= dividendo_n - divisor_n;

Any thoughts? I'm a beginner on this language so I don't know much about what is really going on.

Thanks in advance!


回答1:


You can only use mathematical operations on numerical data types like integer, unsigned and signed in VHDL. The bit_vector type isn't a numerical type so you can't use the subtraction operation.

If you are limited to only using bit or bit_vector types then you will have to implement a binary subtractor circuit to perform this operation.



来源:https://stackoverflow.com/questions/62383489/vhdl-no-function-declaration-for-operator

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!