OpenCores
URL https://opencores.org/ocsvn/mlite/mlite/trunk

Subversion Repositories mlite

[/] [mlite/] [trunk/] [vhdl/] [mult.vhd] - Diff between revs 18 and 23

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 18 Rev 23
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 86... Line 85...
      do_div_temp := '1';
      do_div_temp := '1';
      do_signed_temp := '0';
      do_signed_temp := '0';
   when mult_signed_divide =>
   when mult_signed_divide =>
      start := '1';
      start := '1';
      do_div_temp := '1';
      do_div_temp := '1';
      do_signed_temp := '1';
      do_signed_temp := a(31) xor b(31);
   when others =>
   when others =>
   end case;
   end case;
 
 
   if start = '1' then
   if start = '1' then
      count_temp := "000000";
      count_temp := "000000";
      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';
         b_temp(63) := '0';
         if do_signed_temp = '0' or b(31) = '0' then
         if mult_func /= mult_signed_divide 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);
 
         end if;
 
         if mult_func /= mult_signed_divide or a(31) = '0' then
 
            a_temp := a;
 
         else
            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
 
         a_temp := a;
         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
         b_temp(31 downto 0) := a;
         b_temp(31 downto 0) := a;
Line 122... 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;
   aa := do_signed_reg & reg_a;
   aa := '0' & 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) = do_signed_reg then
         if reg_b(63 downto 32) = ZERO and sum(32) = '0' 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;
         if count_reg /= "011111" then
         if count_reg /= "011111" then
            b_temp(62 downto 0) := reg_b(63 downto 1);
            b_temp(62 downto 0) := reg_b(63 downto 1);
         else
         else
            b_temp(63 downto 32) := a_temp;
            b_temp(63 downto 32) := a_temp;
 
            if do_signed_reg = '0' then
            b_temp(31 downto 0) := answer_temp;
            b_temp(31 downto 0) := answer_temp;
 
            else
 
               b_temp(31 downto 0) := bv_negate(answer_temp);
 
            end if;
         end if;
         end if;
      else  -- mult_mode
      else  -- mult_mode
         if reg_b(0) = '1' then
         if reg_b(0) = '1' then
            b_temp(63 downto 31) := sum;
            b_temp(63 downto 31) := sum;
         else
         else
Line 184... Line 188...
      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
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.