Line 39... |
Line 39... |
use ieee.std_logic_unsigned.all;
|
use ieee.std_logic_unsigned.all;
|
use IEEE.std_logic_arith.all;
|
use IEEE.std_logic_arith.all;
|
use work.mlite_pack.all;
|
use work.mlite_pack.all;
|
|
|
entity mult is
|
entity mult is
|
generic(adder_type : string := "GENERIC";
|
generic(adder_type : string := "DEFAULT";
|
mult_type : string := "GENERIC");
|
mult_type : string := "DEFAULT");
|
port(clk : in std_logic;
|
port(clk : in std_logic;
|
reset_in : in std_logic;
|
reset_in : in std_logic;
|
a, b : in std_logic_vector(31 downto 0);
|
a, b : in std_logic_vector(31 downto 0);
|
mult_func : in mult_function_type;
|
mult_func : in mult_function_type;
|
c_mult : out std_logic_vector(31 downto 0);
|
c_mult : out std_logic_vector(31 downto 0);
|
Line 78... |
Line 78... |
signal answer_select : std_logic_vector(2 downto 0);
|
signal answer_select : std_logic_vector(2 downto 0);
|
|
|
begin
|
begin
|
|
|
--sum = aa + bb
|
--sum = aa + bb
|
generic_adder: if adder_type = "GENERIC" generate
|
generic_adder: if adder_type = "DEFAULT" generate
|
sum <= (aa + bb) when do_mult_reg = '1' else
|
sum <= (aa + bb) when do_mult_reg = '1' else
|
(aa - bb);
|
(aa - bb);
|
end generate; --generic_adder
|
end generate; --generic_adder
|
|
|
--For Altera: sum = aa + bb
|
--For Altera: sum = aa + bb
|
Line 111... |
Line 111... |
c_mult <= reg_b(31 downto 0) when mult_func = MULT_READ_LO else
|
c_mult <= reg_b(31 downto 0) when mult_func = MULT_READ_LO else
|
reg_b(63 downto 32) when mult_func = MULT_READ_HI else
|
reg_b(63 downto 32) when mult_func = MULT_READ_HI else
|
ZERO;
|
ZERO;
|
|
|
|
|
GENERIC_MULT: if MULT_TYPE = "GENERIC" generate
|
GENERIC_MULT: if MULT_TYPE = "DEFAULT" generate
|
|
|
--multiplication/division unit
|
--multiplication/division unit
|
mult_proc: process(clk, reset_in, a, b, mult_func,
|
mult_proc: process(clk, reset_in, a, b, mult_func,
|
do_mult_reg, do_signed_reg, count_reg,
|
do_mult_reg, do_signed_reg, count_reg,
|
reg_a, reg_b, answer_reg, sum, reg_a_times3)
|
reg_a, reg_b, answer_reg, sum, reg_a_times3)
|