## boolean help. adder and subtractor

A boolean circuit has 4 inputs, a, b, cin and K. when K=0, the circuit is an adder. When K=1, the ciruit is a subtractor. WHere do I start? [o)] [*(] [g)] [?]

 PhysOrg.com engineering news on PhysOrg.com >> Researchers use light projector and single-pixel detectors to create 3-D images>> GPS solution provides 3-minute tsunami alerts>> Single-pixel power: Scientists make 3-D images without a camera
 Recognitions: Gold Member Science Advisor Staff Emeritus Depends on what you're trying to do and what you already know. I imagine you want the circuit for your adder/subtractor, right? There are lots of ways to go: You could build an adder, a subtractor, and a chooser circuit. You could make a truth table and build the circuit from that. You could analyze the difference between the circuits of an adder and a subtractor and hack it to provide the toggling capability.
 i'm not trying to make a REAL circuit, I just need to know the boolean equation and schematic. I already know what full adder and subtractor look like. I just don't know how to toggle between the two with a 4th input K.

Recognitions:
Gold Member
Staff Emeritus

## boolean help. adder and subtractor

Well, my post still applies if you replace "circuit" with "formula".

 not helping[*(]

 Originally posted by david90 A boolean circuit has 4 inputs, a, b, cin and K. when K=0, the circuit is an adder.
The inputs a and b are they 1 bit or buses?

 Recognitions: Gold Member Science Advisor Staff Emeritus Well, there are two cases, right? K is false and the formula gives the output of an adder or K is true and the formula gives the output of a subtractor
 still not helping. ur just restating my question. I already know there are 2 cases and that k=0 then it is an adder.
 Recognitions: Gold Member Science Advisor Staff Emeritus Consider the naive approach: multiplex the outputs of each, as Hurkyl said. A two-bit multiplexor looks like this: (m & s) | (n & ~s) where & is AND, | is OR, and ~ is NOT. m and n are the two inputs, and s is the select signal. Does this make sense? If you want to make the simplest possible formula, replace m and n with the formulas for a 1-bit adder and a 1-bit subtractor. Finally, do all the boolean simplification you can. Another approach would be to write out a truth table for the whole design -- a K-map -- and do the normal K-map stuff to get the equation. - Warren

Recognitions:
Gold Member
Staff Emeritus
 still not helping. ur just restating my question. I already know there are 2 cases and that k=0 then it is an adder.
There's something special about the way I restated your question; it's directly translatable into a formula!

 K is false and the formula gives the output of an adder or K is true and the formula gives the output of a subtractor
Is the same as

(~K & (formula for adder)) | (K & (formula for subtractor))

 Thanks i kinda get it now. what is "~"?

 Originally posted by david90 what is "~"?
it is another way of saying not...
~a = !a = not(a)

 not is an inverter right?
 Recognitions: Gold Member Science Advisor Staff Emeritus Yes, it's an inverter. David, you seem to be completely unprepared to handle this problem. Why? Are you in a class where this was asked? Are you not paying any attention to the lectures? - Warren
 Recognitions: Gold Member Science Advisor Staff Emeritus Here, I'll give you a hint to get you started: Think "2's compliment subtraction"
 I have been paying attention in class. It is just that my prof. cares so much about me and the students about getting a job after grad. that he teaches some extra stuff that we're not suppose to learn in ece 204. I'm not sure if I should cuss him out or thank him.[g)]
 what is a weighted code (BCD related) and how does it relates to gray code?