quwstion from newbie

Discussion in 'VHDL' started by mobi999, May 22, 2007.

  1. mobi999

    mobi999

    Joined:
    May 22, 2007
    Messages:
    2
    Hi!
    can u explain what this line do

    result <= ('0' & A)+('0' & B);

    esp this '0' thing

    thanks


    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_arith.all;
    use ieee.std_logic_unsigned.all;

    --------------------------------------------------------

    entity ADDER is

    generic(n: natural :=2);
    port( A: in std_logic_vector(n-1 downto 0);
    B: in std_logic_vector(n-1 downto 0);
    carry: out std_logic;
    sum: out std_logic_vector(n-1 downto 0)
    );

    end ADDER;

    --------------------------------------------------------

    architecture behv of ADDER is

    -- define a temparary signal to store the result

    signal result: std_logic_vector(n downto 0);

    begin

    -- the 3rd bit should be carry

    result <= ('0' & A)+('0' & B);
    sum <= result(n-1 downto 0);
    carry <= result(n);

    end behv;
    mobi999, May 22, 2007
    #1
    1. Advertising

  2. mobi999

    Paxwell

    Joined:
    May 22, 2007
    Messages:
    2
    Since the answer is one bit more than the inputs. If the '0' wouldn´t be there the carry would be lost. You can´t add two vectors of size x and get a result of size x+1. So the two input vectors have to extended with the most significant bit.
    The vectors are unsigned, that´s important. If a and b are signed it should be a(MSB) & a + b(MSB) & b.

    I hope this explains some.
    Last edited: May 22, 2007
    Paxwell, May 22, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Id0x
    Replies:
    4
    Views:
    1,169
    Erik Max Francis
    Jul 21, 2003
  2. JohnE

    newbie with newbie questions

    JohnE, Aug 17, 2009, in forum: ASP .Net
    Replies:
    3
    Views:
    483
    Gregory A. Beamer
    Aug 17, 2009
  3. Jerry C.
    Replies:
    8
    Views:
    207
    Uri Guttman
    Nov 23, 2003
  4. Kruno Saho
    Replies:
    0
    Views:
    125
    Kruno Saho
    Apr 7, 2013
  5. Dave Angel
    Replies:
    0
    Views:
    110
    Dave Angel
    Apr 7, 2013
Loading...

Share This Page