Я реализую алгоритм Бута для умножения двух чисел (в форме дополнения без знака 2) в VHDL. К сожалению, я очень плохо разбираюсь в VHDL и не могу понять, где я ошибаюсь.
Проблема: При прохождении имитации я заметил, что когда я присвоил значение «1011» на y, сигнал mult получил «0UUU». Я не понимаю, почему это происходит. Вот мой код:Назначение сигнала VHDL приводит к неинициализированному состоянию
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
-- x, y are the n bit numbers to be multiplied.
-- The Algorithm :
-- U = 0, prev_bit = 0;
-- for i = 1 to n do
-- if start of a string of 1's in Y then U = U - X
-- if end of a string of 1's in Y then U = U + X
-- Arithmetic right shift UV
-- Circular right shift Y and copy Y(0) to prev_bit
entity booth is
generic(N : natural := 4);
port(
x, y : in std_logic_vector(N-1 downto 0);
result : out std_logic_vector(2*N-1 downto 0);
clk : in std_logic
);
end booth;
architecture booth_arch of booth is
--temp is equivalent to UV where UV is the result.
signal temp : std_logic_vector(2*N-1 downto 0) := (others => '0');
--prev_bit to compare for starting and ending of strings of 1's.
signal prev_bit : std_logic := '0';
signal mult : std_logic_vector(N-1 downto 0);
begin
process(x, y)
begin
mult <= y;
prev_bit <= '0';
for i in 0 to N-1 loop
if(mult(0) = '1' and prev_bit = '0') then --start of a string of 1's
temp(2*N-1 downto N) <= std_logic_vector(unsigned(temp(2*N-1 downto N)) + unsigned(not(x)) + 1);
elsif(mult(0) = '0' and prev_bit = '1') then --end of a string of 1's
temp(2*N-1 downto N) <= std_logic_vector(unsigned(temp(2*N-1 downto N)) + unsigned(x));
end if;
prev_bit <= mult(0);
mult(N-2 downto 0) <= mult(N-1 downto 1); --circular right shift y.
mult(N-1) <= prev_bit;
temp(2*N-2 downto 0) <= temp(2*N-1 downto 1); --arithmetic right shift temp.
end loop;
result <= temp;
end process;
end booth_arch;
P.S: Сигнал clk избыточен здесь. Я еще не использовал его.