need help with ALU 8 BIT

Discussion in 'VHDL' started by Lily, Apr 6, 2004.

  1. Lily

    Lily Guest

    hello

    im a student. beginner to vhdl so bear with me :)

    below is part of my ALU 8 bit program. currently im editing my
    program so that it can detect the overflow, zero and carry-out flag.
    what is the best approach to solve this let say operation (a+b) it
    will detect flag carry, zero and overflow? i try to add as new
    variable as below

    function arith_add (operand_A, operand_B : std_logic_vector(7 downto
    0))
    return std_logic_vector is

    variable arith_out: std_logic_vector(7 downto 0);
    variable carry_in : std_logic_vector(7 downto 0);
    variable carry_out : STD_LOGIC_VECTOR(7 downto 0);
    variable overflow : std_logic;
    begin

    -- condition for this (A+B) operation
    carry_in := carry_out;
    carry_out := "00000000";
    --overflow(7) := '1';

    -- compute the result of adder

    for i in 0 to 7 loop

    arith_out(i) := (operand_A(i) xor operand_B(i)) xor carry_in(i);
    carry_out(i+1) := (operand_A(i) and operand_B(i)) or
    ((operand_A(i) xor operand_B(i)) and carry_in(i));

    end loop;
    return arith_out;
    if carry_out(7) := '1' then
    return overflow;
    end if
    end;

    I also need to design this using RTL concept which consist of
    datapath, controller and structural. My plan is currently to control
    the input operand_B by using multiplexer (because operand_A) will
    always be used every time arithmetic operation.
    What i want to do is to say something like when i select operand (A+B)
    operand_B is positive/1, when (A-B) operand_B is negative.. (based on
    the full adder truth table). can anybody teach me how to assign this ?

    which one would be the better option either to write using function or
    procedure ? pls give comments ?


    thank you very much.
     
    Lily, Apr 6, 2004
    #1
    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. coldplay112
    Replies:
    12
    Views:
    33,152
    etokcan
    Apr 16, 2009
  2. Replies:
    3
    Views:
    1,830
    Timothy Bendfelt
    Jan 19, 2007
  3. Replies:
    9
    Views:
    1,033
    Juha Nieminen
    Aug 22, 2007
  4. Alterah

    Four Bit Adder Help For ALU

    Alterah, Nov 13, 2009, in forum: VHDL
    Replies:
    4
    Views:
    1,782
    Alterah
    Nov 15, 2009
  5. Jeff.M
    Replies:
    6
    Views:
    199
    Lasse Reichstein Nielsen
    May 4, 2009
Loading...

Share This Page