我有这段代码可以计算 2 个数字的模
library IEEE;
use ieee.numeric_bit.all;
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
variable dividendovar : integer range 0 to 15;
begin
process(clock, reset) is
begin
if reset = '1' then
fim <= '0';
resto <= "0000000000000000";
elsif clock'event and clock = '1' and inicio = '1' then
dividendovar <= to_integer(unsigned(dividendo));
if (divisor = "0000000000000000") then
-- report "zero";
resto <= dividendo;
fim <= '1';
elsif (dividendovar = to_integer(unsigned(divisor))) then
-- report "menor";
-- report "dividendoaux vale "& integer'image(to_integer(unsigned(dividendoaux))) ;
resto <= "0000000000000000";
fim <= '1';
elsif (to_integer(unsigned(dividendo)) < to_integer(unsigned(divisor))) then
resto <= dividendo;
fim <= '1';
else -- comeca a subtrair
while (dividendovar > to_integer(unsigned(divisor))) loop
dividendovar := dividendovar - to_integer(unsigned(divisor));
end loop ;
resto <= bit_vector(to_unsigned(dividendovar, resto'length));
fim <= '1';
end if;
end if;
end process;
end architecture;
但是上线了
variable dividendovar : integer range 0 to 15;
我收到此错误"Non-shared variable declaration not allowed here"。
我做错了什么或失踪的任何线索?
提前致谢!