• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

2's complement binary subtractor

Status
Not open for further replies.

pizzamix

New Member
Hello,
I need to design a two's complement binary subtractor for an electronics test.
There needs to be two 3-bit inputs, one for the minuend and one for the subtrahend. The output needs to be the difference of the two numbers, eg. if the minuend and subtrahend are 2 and -1, respectively, the output should be 3. The design needs to include Boolean equations expressing each output bit in terms of the inputs.
The inputs should be represented as A2, A1, A0, and B2, B1, B0, with outputs of C2, C1, C0.

We have build an adder before on a different test, and I managed to do that, but for some reason, I can't seem to get my head around this one. I am getting confused about the "borrowing" part if the subtrahend is larger than the minuend, and I am not sure how to express negatives in the inputs. Any help will be greatly appreciated, and the sooner the better.
Thanks!
 

crutschow

Well-Known Member
Most Helpful Member
So, this is not really homework?
 

MikeMl

Well-Known Member
Most Helpful Member
I'm not going to do you school work for you, but go back to first principles. Write out a truth table; it has six input columns, so there will be 64 rows.

For each of the 64 combinations of inputs, you can write out what the three outputs would be. Writing the boolean equations for each output is just the OR of all the terms that produce a ONE. Simplifying can be done by any of the methods you should already have been taught...
 

pizzamix

New Member
alright, thank you. But what about negative numbers? should i put the leading bit to express whether it is positive or negative?

And no, i guess it is not technically homework, but it is part of a take-home test
 

MikeMl

Well-Known Member
Most Helpful Member
What method are you using to represent negative numbers? ones complement? two's complement?
 

pizzamix

New Member
The problem does not specify. It doesn't really make sense, it gives 2 - (-1) as an example of inputs the design should solve, but it mentions nothing else about negative numbers or how to represent them.
The only other thing the problem says is:
"In some cases the output will become too small or too large to fit into three bits, and in these cases your output can be undefined (i.e. anything goes). In all other cases, the output should be arithmetically correct."
This could mean that negative outputs do not really matter, but I can't tell.
 
Last edited:

MikeMl

Well-Known Member
Most Helpful Member
Actually, the title of your post says it. I think that your underlying problem is that you do not understand how negative base2 numbers are usually represented. If you did, you would not have posted the original question...
 

pizzamix

New Member
Well I think i might. You just add an extra bit to the beginning of the number right? 0 for positive, 1 for negative?
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top