Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
8 years ago

Help multiplier vhdl

Hi everyone!

I've some problems with a design, I have to Design an algorithmic state machine to implement a parallel series multiplier for eight-bit numbers encoded in SM (Sign-Magnitude). The multiplying is in a register with parallel output and the multiplier in a shift register of length m with serial output, the first bit to be the least significant. Each bit of multiplier, in his turn, multiplies by multiplying all, so that with operations multiplication is performed.

I've the problem with the shift register with serial output, because I don´t know how to do it!!

I'm learning VHDL right now, and I've never work with this hardware description language.

Please if anyone can help me, I'd be very grateful.

Thank you!!

13 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Im feeling pretty generous today. I hate seeing overly complicated case statements.

    I think the following code does what you're trying to do:

    
    library IEEE;
    use IEEE.STD_LOGIC_1164.ALL;
    use IEEE.numeric_std.all;
    entity prueba2 is
    port (
      A         : in  std_logic_vector( (7 downto 0);
      B         : in  unsigned (7 downto 0);
      inicio    : in  std_logic;
      clk       : in  std_logic;
      reset     : in  std_logic;
      q         : out unsigned (2 downto 0);
      resultado : out unsigned (15 downto 0)
    );
    end prueba2;
    architecture behavioral of prueba2 is
    signal cuenta : unsigned(2 downto 0);
    signal y      : unsigned(15 downto 0);
    begin
      multi : process (clk, reset)
      begin
        if reset = '1' then
          y  <= (others => '0');
        elsif rising_edge(clk) then
          if inicio = '1' then
            cuenta <= cuenta + 1;
          end if;
          if A /= x"00" then
            if A( to_integer(cuenta) ) = '1' then
              Y   <= Y + ( resize(B, y'length)*(2**to_integer(cuenta)) );
            end if;
          end if;
        end if;
      end process;
      q         <= cuenta;
      resultado <= y;
    end architecture;
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Im feeling pretty generous today. I hate seeing overly complicated case statements.

    I think the following code does what you're trying to do:

    
    library IEEE;
    use IEEE.STD_LOGIC_1164.ALL;
    use IEEE.numeric_std.all;
    entity prueba2 is
    port (
      A         : in  unsigned (7 downto 0);
      B         : in  unsigned (7 downto 0);
      inicio    : in  std_logic;
      clk       : in  std_logic;
      reset     : in  std_logic;
      q         : out unsigned (2 downto 0);
      resultado : out unsigned (15 downto 0)
    );
    end prueba2;
    architecture behavioral of prueba2 is
    signal cuenta : unsigned(2 downto 0);
    signal y      : unsigned(15 downto 0);
    begin
      multi : process (A, clk, reset)
      begin
        if reset = '1' then
          y  <= (others => '0');
        elsif rising_edge(clk) then
          if inicio = '1' then
            cuenta <= cuenta + 1;
          end if;
          if B /= x"00" then
            Y   <= Y + ( resize(B, 15)*(2**to_integer(cuenta)) );
          end if;
        end if;
      end process;
      q         <= cuenta;
      resultado <= y;
    end architecture;
    

    --- Quote End ---

    well Tricky that might work but is too tricky for beginner, after all I can just say y = a*b

    I assume it is exercise that gets more and more compact under pressure...great
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    well Tricky that might work but is too tricky for beginner, after all I can just say y = a*b

    I assume it is exercise that gets more and more compact under pressure...great

    --- Quote End ---

    Thank you kaz and Tricky, finally before I read your answers I have solved it in the way that kaz as told me.

    So I've understood it very well. Thank you so much for the help!!!!