How can I do 2A+3B(3 bits) with 4 bit ALU?

Discussion in 'Homework Help' started by ulas94, Mar 26, 2016.

  1. ulas94

    Thread Starter New Member

    Mar 26, 2016
    7
    0
    Hi. I have a question about ALU design. I have A and B variables which are 3-bit and ALU which has 4-bit inputs.My purpose is adding up 2A+3B but I can use ALU one time. How can I do it?

    q2.jpg
     
  2. ulas94

    Thread Starter New Member

    Mar 26, 2016
    7
    0
    And later (F=2A+3B) save it 8-bit register.
     
  3. ScottWang

    Moderator

    Aug 23, 2012
    4,855
    767
    Go to study 74HC181 then you will get the answer.
     
  4. ulas94

    Thread Starter New Member

    Mar 26, 2016
    7
    0
    For example I have two variable A and B which are 4-bit and I want to make 2A plus B and save the answer in 8-bit register.

    Solution:
    toplama.jpg blokdiagram.jpg

    Answer of my question will be like this but I can't do 2A plus 3B ( A and B 3-bits) and I need help :)
     
  5. ScottWang

    Moderator

    Aug 23, 2012
    4,855
    767
    Is this homework or personal learning?
     
  6. ulas94

    Thread Starter New Member

    Mar 26, 2016
    7
    0
    It is a question which has potatial to be in the exam :)
     
  7. WBahn

    Moderator

    Mar 31, 2012
    17,747
    4,796
    What is the maximum value that 2A + 3B can have? Can that be represented by the output, including carry, of a 4-bit adder?

    How many bits are required to represent it?

    You circuit diagram embodies some of what you need to do. Do you know which parts those are? Did you come up with that circuit diagram yourself? If so, think about why you made the connects you did and what parts of the math are taken care of and what parts aren't.

    And remember that it IS a math function you are trying to implement, so play with the math.

    For example, see if something like

    Y = 2A + 3B = 2(A+B) + B

    helps you out.
     
  8. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    I think you should be able to use the S inputs, so that you can put A<<1 to Ain, B<<1 to Bin and B to Sin so that you get 2A+2B+1B.
    (A<<1 being A shifted left by one bit)
     
    Last edited: Mar 27, 2016
  9. ulas94

    Thread Starter New Member

    Mar 26, 2016
    7
    0
    I think put B to Select pins wrong choice because if I apply 000 to B , the F will be 0 although A is not 0
     
  10. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    Oh sorry my mistake, i thought that S was the carry in, when in fact it is the mode select. Disregard my previous post.
    My first idea was that +3B could be equal to -1B if the size of the processing busses was just right. I think this idea needs some practice becaues the ALU you described doesn't really cover all the possibilities of 4bit inputs and the according results.
    So i suggest you try the A-B op code and see if it gets you anywhere.
     
  11. ulas94

    Thread Starter New Member

    Mar 26, 2016
    7
    0
    Yes this ALU works unsigned numbers I understand(but I don't know :) ) so inputs must be positive therefore signed numbers can be confusing in this scenario.
    My approximation like this
    20160328_030537.jpg
    B0 is going to D0 directly and A0 and B0 are going to ALU's A0 and B0 respectively and B1 is going to Cn but I have hanged out there because A1+B1+B2 does not happen.Probably I should use ALU's A3 and B3 bits which are not used in the above event
     
  12. kubeek

    AAC Fanatic!

    Sep 20, 2005
    4,670
    804
    can you use external gates as well, or only the ALU?
     
  13. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,808
    834
    Is "Not Possible" a valid answer? Given that the ALU can only be used once, that would be my answer. Because the function as defined has three operations. 2A can be calculated without using the ALU. But 3B needs to use the ALU. Leaving no way (since the ALU can only be used once) to add the two terms.
     
  14. ulas94

    Thread Starter New Member

    Mar 26, 2016
    7
    0
    Unfortinately only one ALU can be used :)
     
  15. WBahn

    Moderator

    Mar 31, 2012
    17,747
    4,796
    I'm not quite convinced it's not possible yet. There is an easy way to get all but the msb of B of the odd term taken care of (so 2A + 2B + B%4). But I'm not seeing any way to get that last bit in there.
     
Loading...