Line 32... |
Line 32... |
signal do_signed_reg : std_logic;
|
signal do_signed_reg : std_logic;
|
signal count_reg : std_logic_vector(5 downto 0);
|
signal count_reg : std_logic_vector(5 downto 0);
|
signal reg_a : std_logic_vector(31 downto 0);
|
signal reg_a : std_logic_vector(31 downto 0);
|
signal reg_b : std_logic_vector(63 downto 0);
|
signal reg_b : std_logic_vector(63 downto 0);
|
signal answer_reg : std_logic_vector(31 downto 0);
|
signal answer_reg : std_logic_vector(31 downto 0);
|
|
-- signal sum_out : std_logic_vector(32 downto 0);
|
begin
|
begin
|
|
|
--multiplication/division unit
|
--multiplication/division unit
|
mult_proc: process(clk, a, b, mult_func,
|
mult_proc: process(clk, a, b, mult_func,
|
do_div_reg, do_signed_reg, count_reg,
|
do_div_reg, do_signed_reg, count_reg,
|
Line 45... |
Line 46... |
variable count_temp : std_logic_vector(5 downto 0);
|
variable count_temp : std_logic_vector(5 downto 0);
|
variable a_temp : std_logic_vector(31 downto 0);
|
variable a_temp : std_logic_vector(31 downto 0);
|
variable b_temp : std_logic_vector(63 downto 0);
|
variable b_temp : std_logic_vector(63 downto 0);
|
variable answer_temp : std_logic_vector(31 downto 0);
|
variable answer_temp : std_logic_vector(31 downto 0);
|
|
|
variable sign_extension : std_logic;
|
|
variable aa, bb : std_logic_vector(32 downto 0);
|
variable aa, bb : std_logic_vector(32 downto 0);
|
variable sum : std_logic_vector(32 downto 0);
|
variable sum : std_logic_vector(32 downto 0);
|
variable start : std_logic;
|
variable start : std_logic;
|
variable do_write : std_logic;
|
variable do_write : std_logic;
|
variable do_hi : std_logic;
|
variable do_hi : std_logic;
|
Line 60... |
Line 60... |
count_temp := count_reg;
|
count_temp := count_reg;
|
a_temp := reg_a;
|
a_temp := reg_a;
|
b_temp := reg_b;
|
b_temp := reg_b;
|
answer_temp := answer_reg;
|
answer_temp := answer_reg;
|
|
|
sign_extension := '0';
|
|
aa := '0' & ZERO;
|
aa := '0' & ZERO;
|
bb := '0' & ZERO;
|
bb := '0' & ZERO;
|
sum := '0' & ZERO;
|
sum := '0' & ZERO;
|
start := '0';
|
start := '0';
|
do_write := '0';
|
do_write := '0';
|
Line 96... |
Line 95... |
if start = '1' then
|
if start = '1' then
|
count_temp := "000000";
|
count_temp := "000000";
|
a_temp := a;
|
a_temp := a;
|
answer_temp := ZERO;
|
answer_temp := ZERO;
|
if do_div_temp = '1' then
|
if do_div_temp = '1' then
|
|
b_temp(63) := '0';
|
if do_signed_temp = '0' or b(31) = '0' then
|
if do_signed_temp = '0' or b(31) = '0' then
|
b_temp(62 downto 31) := b;
|
b_temp(62 downto 31) := b;
|
else
|
else
|
b_temp(62 downto 31) := bv_negate(b);
|
b_temp(62 downto 31) := bv_negate(b);
|
a_temp := bv_negate(a);
|
a_temp := bv_negate(a);
|
end if;
|
end if;
|
b_temp(30 downto 0) := ZERO(30 downto 0);
|
b_temp(30 downto 0) := ZERO(30 downto 0);
|
|
if do_signed_temp = '1' and a(31) = b(31) then
|
|
do_signed_temp := '0';
|
|
end if;
|
else --multiply
|
else --multiply
|
b_temp := ZERO & b;
|
b_temp := ZERO & b;
|
end if;
|
end if;
|
elsif do_write = '1' then
|
elsif do_write = '1' then
|
if do_hi = '0' then
|
if do_hi = '0' then
|
Line 119... |
Line 122... |
if do_div_reg = '1' then
|
if do_div_reg = '1' then
|
bb := reg_b(32 downto 0);
|
bb := reg_b(32 downto 0);
|
else
|
else
|
bb := '0' & reg_b(63 downto 32);
|
bb := '0' & reg_b(63 downto 32);
|
end if;
|
end if;
|
sign_extension := reg_a(31) and do_signed_reg;
|
aa := do_signed_reg & reg_a;
|
aa := sign_extension & reg_a;
|
|
sum := bv_adder(aa, bb, do_div_reg);
|
sum := bv_adder(aa, bb, do_div_reg);
|
-- sum := bv_adder_lookahead(aa, bb, do_div_reg);
|
-- sum := bv_adder_lookahead(aa, bb, do_div_reg);
|
|
|
if count_reg(5) = '0' and start = '0' then
|
if count_reg(5) = '0' and start = '0' then
|
count_temp := bv_inc6(count_reg);
|
count_temp := bv_inc6(count_reg);
|
if do_div_reg = '1' then
|
if do_div_reg = '1' then
|
answer_temp(31 downto 1) := answer_reg(30 downto 0);
|
answer_temp(31 downto 1) := answer_reg(30 downto 0);
|
if reg_b(63 downto 32) = ZERO and sum(32) = '0' then
|
if reg_b(63 downto 32) = ZERO and sum(32) = do_signed_reg then
|
a_temp := sum(31 downto 0); --aa=aa-bb;
|
a_temp := sum(31 downto 0); --aa=aa-bb;
|
answer_temp(0) := '1';
|
answer_temp(0) := '1';
|
else
|
else
|
answer_temp(0) := '0';
|
answer_temp(0) := '0';
|
end if;
|
end if;
|
Line 182... |
Line 184... |
c_mult <= reg_b(63 downto 32);
|
c_mult <= reg_b(63 downto 32);
|
else
|
else
|
c_mult <= ZERO;
|
c_mult <= ZERO;
|
end if;
|
end if;
|
|
|
|
-- sum_out <= sum;
|
|
|
end process;
|
end process;
|
|
|
end; --architecture logic
|
end; --architecture logic
|
|
|
|
|