0
\$\begingroup\$

I am trying to design a calculator circuit that adds 2 four-bit 2's-complement binary numbers as its input and outputs an 8-bit 2's-complement number when the control bits equal 01.

Here's what I have done so far using a software called Logisim. I am really stuck when I found out that I cannot put the other 4 output buttons (colored in blue) in my full adder. I am stumped on how to approach this problem now.

I have tested a few 2's-complement numbers and got the output I wanted and some 2's-complement numbers that did not go so well like (having 0100 as the first input and 0110 as the second input did not give me 1010 but gave me 1011.

block diagram

I just need help, suggestions and guidance on how to move forward.

\$\endgroup\$
0
\$\begingroup\$

You have a 4-bit full adder, so far OK. Then you connected a control input to the carry-in of the lowest bit. When you keep that control at 0 you still have your 4-bit adder. When you put it at 1 you will get the addition + 1, just as you described. Putting an inverter after the first output bit will 'solve' this ONLY for additions that had a 0 in the lowest bit (go figure out why).

If you want the control = 1 to give you the addition, and control = 0 must give 'something else, does not matter what' you could put the inverter in the control line.

BTW a 4-bit added will give you a 5-bit result. If you need an 8-bit 2s-complement result look up 'sign extension'. (This smells of homework, so I won't give away everything.)

\$\endgroup\$
7
  • \$\begingroup\$ Hi Wouter! I know what sign extension is, I will need to pad the number in the front with 0's if its a positive number or 1's in the front if its a negative number. Based on your feedback, it seems like I'm on the right track but I'm just missing sign extension. However the addition implementation only works for several 4 bit's 2 complement number(because the inverter flips the bit) the only reason I added the inverter was I was getting unexpected results otherwise. How would I implement something like sign extension? I'm guessing I would probably have to wire the remaining output in some way. \$\endgroup\$
    – Nicholas
    Nov 18 '12 at 13:49
  • \$\begingroup\$ Show me the inputs that don't work correctly with a carry-in of 0. \$\endgroup\$ Nov 18 '12 at 13:59
  • \$\begingroup\$ Hi Wouter, here's the link with the input that does not work. My circuit is suppose to perform addition(A + B) when first control bit is 0 and the second control bit is 1. However this input seems make my circuit work awkwardly. i33.photobucket.com/albums/d86/warnexus/gatepic.png \$\endgroup\$
    – Nicholas
    Nov 18 '12 at 21:03
  • \$\begingroup\$ You add 0b0100 + 0b0100 + 0b0001, you get 0b1011. Nothing wrong! The 0b0001 is beacuse the lower bit of what you call control is a 1 and you feed it into the carry-in of your lowest-bit adder. \$\endgroup\$ Nov 18 '12 at 22:01
  • \$\begingroup\$ but when you add 0100 + 0110, the output is 1010. My answer has to be wrong. I do not understand what did you mean about the 0B0100, that is not in my picture. \$\endgroup\$
    – Nicholas
    Nov 18 '12 at 22:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.