所以我的任务是在 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;
有什么想法吗?我是这门语言的初学者,所以我不太了解到底发生了什么。
提前致谢!