Guest
I have a problem to build a multiplier. But it seems something wrong with my code that the output did not update. Anyone can help me?
My code is as followed
--multiplier
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity Multiplier_VHDL is
GENERIC (WIDTH:INTEGER);
PORT(a:IN STD_LOGIC_VECTOR(WIDTH-1 DOWNTO 0);
b:IN STD_LOGIC_VECTOR(WIDTH-1 DOWNTO 0);
y:OUT STD_LOGIC_VECTOR(2*WIDTH-1 DOWNTO 0));
end entity Multiplier_VHDL;
architecture Behavioral of Multiplier_VHDL is
signal a_temp:std_logic_vector(width-1 downto 0);
signal b_temp:std_logic_vector(width-1 downto 0);
signal mid:std_logic_vector(2*width-1 downto 0):=(others=>'0');
signal mid_temp:std_logic_vector(2*width-1 downto 0):=(others=>'0');
signal cout_mid:std_logic_vector(2*width downto 0):=(others=>'0');
signal y_temp:std_logic_vector(2*width-1 downto 0);
begin
proc_multiplier1:
process(a_temp,b_temp)
begin
a_temp<=a;
b_temp<=b;
calculation_out:
for i in 0 to width-1 loop
if b_temp(i)='1' then
mid(width-1+i downto i)<=a_temp;
end if;
calculation_in:
for j in 0 to 2*width-1 loop
y_temp(j)<=mid_temp(j) xor mid(j) xor cout_mid(j);
cout_mid(j+1)<=(mid_temp(j) and mid(j)) or (mid_temp(j) and cout_mid(j)) or (cout_mid(j) and mid(j));
end loop calculation_in;
mid_temp<=y_temp;
cout_mid<=(others=>'0');
mid<=(others=>'0');
end loop calculation_out;
end process;
y<=y_temp;
end architecture Behavioral;
There is a warning message
Warning: (vsim-WLF-5000) WLF file currently in use: vsim.wlf
My code is as followed
--multiplier
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity Multiplier_VHDL is
GENERIC (WIDTH:INTEGER);
PORT(a:IN STD_LOGIC_VECTOR(WIDTH-1 DOWNTO 0);
b:IN STD_LOGIC_VECTOR(WIDTH-1 DOWNTO 0);
y:OUT STD_LOGIC_VECTOR(2*WIDTH-1 DOWNTO 0));
end entity Multiplier_VHDL;
architecture Behavioral of Multiplier_VHDL is
signal a_temp:std_logic_vector(width-1 downto 0);
signal b_temp:std_logic_vector(width-1 downto 0);
signal mid:std_logic_vector(2*width-1 downto 0):=(others=>'0');
signal mid_temp:std_logic_vector(2*width-1 downto 0):=(others=>'0');
signal cout_mid:std_logic_vector(2*width downto 0):=(others=>'0');
signal y_temp:std_logic_vector(2*width-1 downto 0);
begin
proc_multiplier1:
process(a_temp,b_temp)
begin
a_temp<=a;
b_temp<=b;
calculation_out:
for i in 0 to width-1 loop
if b_temp(i)='1' then
mid(width-1+i downto i)<=a_temp;
end if;
calculation_in:
for j in 0 to 2*width-1 loop
y_temp(j)<=mid_temp(j) xor mid(j) xor cout_mid(j);
cout_mid(j+1)<=(mid_temp(j) and mid(j)) or (mid_temp(j) and cout_mid(j)) or (cout_mid(j) and mid(j));
end loop calculation_in;
mid_temp<=y_temp;
cout_mid<=(others=>'0');
mid<=(others=>'0');
end loop calculation_out;
end process;
y<=y_temp;
end architecture Behavioral;
There is a warning message
Warning: (vsim-WLF-5000) WLF file currently in use: vsim.wlf