Forum Discussion

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

can some onehelp me????

hi everyone .Im a 21 year old girl from Vietnam. i have a project and have to submit it to my teacher on the 20th of May . Can you guys here help me with this project.

I would really appriciate your help^^^

the project is: design and test 4X4 bit unsigned multiplier using right shift add algorithm.

I have difficluties in describing the two registers. Can you help me write it in VHDL code? thanks very much!!!

I have attached the diagram bellow..

Hope to get nice reply from you soon:)

thanks in advance^^^

18 Replies

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

    hi Kaz . iam just back.

    oh. tomorrow is monday.(i forgot). thanks for your enthusiam.

    again,many thanks to you.

    best wishes!
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    I played a bit with your algorithm and realised your output is serial.

    Here is the code that corresponds to your algorithm. It worked as far as I tested but check various values of the range 0_15 on both A,B inputs.

    
    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.numeric_std.all;
    entity mult1 is
    port(
         load   : in  std_logic;
         clk    : in  std_logic;
         A      : in  std_logic_vector(3 downto 0);
         B      : in  std_logic_vector(3 downto 0);
         ready  : out std_logic;
         R      : out std_logic
         );
    end entity;
    architecture rtl of mult1 is
    signal shift_reg1 : std_logic_vector(3 downto 0) := "0000";
    signal shift_reg2 : std_logic_vector(7 downto 0) := x"00";
    signal reg1 : std_logic_vector(7 downto 0);
    signal opA : std_logic_vector(3 downto 0);
    signal count : integer range 0 to 7 := 0;
    begin
    R <= shift_reg2(0);
    ready <= '1' when count = 5 else '0';
    reg1(7 downto 3) <= std_logic_vector(resize(unsigned(OpA),5) +  unsigned(shift_reg2(7 downto 4)));
    reg1(2 downto 0) <= shift_reg2(3 downto 1);
    process(load,clk)
    begin
    if load = '1' then
       count <= 0;
       shift_reg1 <= A; -- load input A into shift register
    elsif rising_edge(clk) then
       if count < 7 then
          count <= count + 1;
       end if;
       shift_reg1 <= '0' & shift_reg1(3 downto 1); -- shift right
       shift_reg2 <= reg1;
       if shift_reg1(0) = '1' then
           OpA <= B;
       else 
           OpA <= "0000";
       end if;
    end if;
    end process;
     
    end rtl; 
            
       
            
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    wow! Kaz ,im grateful to you for being so kind to me.I still have 5 days before having to submit my project to my teacher . tomorrow afternoon , I have a test ahead so have to spend time for it. Dont have enough time studying my project right now.

    The code you have just posted seems suitable for my algorithm.

    I will examine it in the next few days.

    Hope you will be pleased to continue...help....

    it's 11pm and I should go to sleep now.

    Happy to have a chat with you friend Kaz ;)
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    architecture rtl of mult1 is

    signal shift_reg1 : std_logic_vector(3 downto 0) := "0000";

    signal shift_reg2 : std_logic_vector(7 downto 0) := x"00";

    signal reg1 : std_logic_vector(7 downto 0);

    signal opA : std_logic_vector(3 downto 0);

    begin

    R <= shift_reg2(0);

    reg1(7 downto 3) <= std_logic_vector(resize(unsigned(OpA),5) + unsigned(shift_reg2(7 downto 4)));

    reg1(2 downto 0) <= shift_reg2(3 downto 1);

    what's the three signals shift-reg1,shift-reg2,reg1( they are the singals between?) what does shift-reg2(0) mean?

    Is it nessecary to write :="0000" and :=x"00" at the signal shift-reg1,2

    (My teacher dont write them in the signal declaration)

    and the next code I almost don't understand ( other ways to write them easier to understand??).
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Im not very good at VHdl so the question I asked you seem a little '' stupid" .Hope you won;t despise me........

    thanks very much!!!!!!!!!!!