# Logic Gates -- What's the real story of how comparison is made?

Status
Not open for further replies.

#### rbaulbin

Joined Jan 4, 2011
14
Trying to get my mind around gates and their comparative functions -- if any one of you folks can lend a hand, I'd appreciate it

I've read a bit about gates, and often hear "2 switches wired in series and both being closed" will allow 2 inputs to flow to the lightbulb on Q. But that's not saying anything about the 2 inputs themselves playing a part in whether or not the switches are closed.

If I put a low signal through input A flowing to Switch 1, and a high signal to input B flowing to Switch 2, and both switches are closed (completing circuit), and the lightbulb on Q lights, then both signals have not been compared.

As I understand it, this is NOT the full story of the AND gates used in electronic logic.

The logic levels is not just in the status of the switches (the traditional hand closing faucet idea -- as the hand is not identified in that example). Otherwise a low and a high signal could be sent through inputs A and B, and since the switches are closed, this makes Q true (both switch 1 AND switch 2 are closed -- and this is comparing the switches themselves, but not the inputs), but an actual AND gate will only allow 2 HIGH signals through in order to make Q true (on).

Question: What's really happening with 2 switches in series in order to compare 2 high signals to make Q high? Something about the inputs themselves must be closing the switches. Is it correct then, that 2 transistors in series to make an AND gate are applied outside voltage to be made "active" (capable of turning on and off?), but what is *really* closing the switches is *not* this voltage (i.e., NOT some outside force), but the sensitivity of both transistors in *requiring* a high voltage from both inputs in order to close (as opposed to low voltages), *thus* allowing both inputs through and lighting Q?

The logic then is a *combination* of the inputs and their *impact* on the transistors/switches themselves, and not merely in the status of them prior to this. Is it true then the purpose of the outside voltage/current is simply to enable the transistor to be flicked on (or off) by either 5V or 0V coming from the input itself (why, I also don't understand -- since 0V is not really what it is, as 0V can do nothing -- it's more like something around 0 so that there's some force there...?) ... certain transistors are by default "off" when "activated" by an outside voltage, and then constructed so that they're able to be switched in the opposite on/off position by either a 5V or ~0V input?

#### thatoneguy

Joined Feb 19, 2009
6,359
I think you are overlooking the "Nomans Land"/"Threshold or Forbidden Area".

Logic Low is 0V around 0.7V
Logic High is roughly 3.6V -5V

Anything from 0.7 to 3.6 (sometimes up to 4V) is an "invalid input", and the gate may not respond correctly.

This is where fan-out and fan-in come into play with TTL, one gate can only drive so many inputs to one state or the other, there's a limit in the real world, and if that line/limit isn't reached, the circuit won't work as designed.

#### rbaulbin

Joined Jan 4, 2011
14
>I think you are overlooking the "Nomans Land"/"Threshold or Forbidden Area".

>Logic Low is 0V around 0.7V
>Logic High is roughly 3.6V -5V

>Anything from 0.7 to 3.6 (sometimes up to 4V) is an "invalid input", and the >gate may not respond correctly.

How is 0V useful on the line? It's never actually 0V, correct? It's confusing how "logic 0" is often equated with 0V, but it can't literally be 0V or there's no signal, which just doesn't make any sense to me. An inverter, for example, necessitates some voltage to make the signal high ... ergo, there can't be nothing(?) Is not "on" or "off" a misnomer of sorts?

#### SgtWookie

Joined Jul 17, 2007
22,230
You've touched on something that will "bite" you if you're not aware of it.

CMOS logic ICs must have a current path to either Vdd (Vcc, +V) or Vss (ground, 0v) or they may oscillate at high frequency. The current path can be a direct connection via a wire, a suitable resistor, or a semiconductor device. If left "floating", you will experience problems.

Same thing with inputs to unused channels on comparators or opamps. You'll have all kinds of weird problems until you suddenly remember, "Dang, I forgot to provide a current path for the inputs...."

#### Ron H

Joined Apr 14, 2005
7,063
You're really going to hate this answer. Logic zero and logic one voltage levels are totally determined by the circuit design of the logic gate in question. There is a logic family called emitter coupled logic (ECL) in which logic "0" is represented by -1.65V, and logic "1" is nominally -0.9V.
Zero volts (0.000000V) is perfectly acceptable as a logic zero for TTL and CMOS logic families. Unfortunately, I'm not sure where to start in helping to clear up your misconceptions.

#### rbaulbin

Joined Jan 4, 2011
14
You're really going to hate this answer. Logic zero and logic one voltage levels are totally determined by the circuit design of the logic gate in question. There is a logic family called emitter coupled logic (ECL) in which logic "0" is represented by -1.65V, and logic "1" is nominally -0.9V.
Zero volts (0.000000V) is perfectly acceptable as a logic zero for TTL and CMOS logic families. Unfortunately, I'm not sure where to start in helping to clear up your misconceptions.
Ok, but consider an inverter for a moment. If you want a high signal, it needs a low one. If a low one is 0.000000V, there's nothing for it to invert: it has nothing to act on -- so this makes no sense. 0V cannot be what's going on in, for example, 5V and 0V logic high/low situations. It must be 5V and 0.000000001V or something, right?

#### Ron H

Joined Apr 14, 2005
7,063
I think you will at least need to learn about how transistors work before you can understand how logic gates work.

#### Robin Mitchell

Joined Oct 25, 2009
819
my god Ron H i was JUST about to sat the same XD

If there is no current on the base of a transistor it does not conduct. If you look at how TTL logic gates are made then.... look just accept it XD

Robin

#### beenthere

Joined Apr 20, 2004
15,819
If you want a high signal, it needs a low one. If a low one is 0.000000V, there's nothing for it to invert: it has nothing to act on -- so this makes no sense. 0V cannot be what's going on in, for example, 5V and 0V logic high/low situations. It must be 5V and 0.000000001V or something, right
Every logic family has some voltage level at which the signal input is sensed as a LOW, and another at which it is a HIGH. An inverter simply outputs the logic state that is the inverse of the input - 0.000000000000 volts will certainly be valid as a LOW, resulting in a HIGH output. The input circuitry is not powered by the voltage coming in, as you seem to imply.

Reading up on the input requirements for the various logic families should help you confusion. In RonH's example, ECL uses the voltage level at the emitter of a transistor. It is fast, as the logic element is always on - just in different states of conduction. That logic is also power hungry and a real pain to make use of.

#### tom66

Joined May 9, 2009
2,595
Below is a circuit which will invert a logic signal.

When the input is low the transistor is in "cutoff" and no current flows. The 10k resistor pulls the signal high.

When the input is high the transistor pulls the signal low - to about 10mV. This is because the transistor's low voltage drop (less than 100mV) overwhelms the 10k resistor.

Despite the fact that the input has no signal, and despite the fact there is no base current (in the off state), the transistor still controls another signal. It is an inverter. You can do a similar thing with MOSFETs and CMOS logic, though it gets more complicated.

Think of it this way: 0V is only relative. In this case, saying a signal is 0V means compared to a predefined ground reference. So it's not no signal - it's relatively zero difference - but the electrons (charge carriers) still have an energy. You could have a similar set up with a 9V battery. You call the negative terminal -4.5V and the positive terminal 4.5V. You connect the Vss/Vee of the logic gate to -4.5V; your zero input would now be -4.5V. For convenience, most electronics deals with a defined ground point, usually at a battery negative, but you can work without a ground.

#### Attachments

• 20.5 KB Views: 53

#### Markd77

Joined Sep 7, 2009
2,806

#### rbaulbin

Joined Jan 4, 2011
14
Below is a circuit which will invert a logic signal.

When the input is low the transistor is in "cutoff" and no current flows. The 10k resistor pulls the signal high.

When the input is high the transistor pulls the signal low - to about 10mV. This is because the transistor's low voltage drop (less than 100mV) overwhelms the 10k resistor.

Despite the fact that the input has no signal, and despite the fact there is no base current (in the off state), the transistor still controls another signal. It is an inverter. You can do a similar thing with MOSFETs and CMOS logic, though it gets more complicated.

Think of it this way: 0V is only relative. In this case, saying a signal is 0V means compared to a predefined ground reference. So it's not no signal - it's relatively zero difference - but the electrons (charge carriers) still have an energy. You could have a similar set up with a 9V battery. You call the negative terminal -4.5V and the positive terminal 4.5V. You connect the Vss/Vee of the logic gate to -4.5V; your zero input would now be -4.5V. For convenience, most electronics deals with a defined ground point, usually at a battery negative, but you can work without a ground.

Thank you for the detailed explanation (and also for the others).

Let me qualify my original question a bit. I'm coming from this stuff from an informatics/logic thrust, and looking to get an abstract theory of computation and logic flow -- it's more regarding the underlying principle of computation in light of George Boole's theories ("The Laws of Thought"). I'm not an electronics guy (which you picked up from - Ron H and Robin), but my question involves theory that overlaps into electronics (because electronics puts Boole's theory into motion), hence why I posted my question in a forum of people with electronics expertise.

I've done some homework in reading up on transistors and logic gates, but none of the material is getting at the gist of my question, which I think I can refine here better due to your original responses.

So let me refine the question, if I may...

I read in various places online that an "AND" gate can be likened to 2 switches in series as in the below diagram.

Source___/__/___Lightbulb
.........1..2 (disregard dots; can't use spaces to move characters)

I don't understand how this can be said, since in the above situation, 2 signals are not being compared, only 2 switches, and nothing is being said about what controls the switches. If both switches are closed, the lightbulb lights, and provided you have the proper voltage/current, it lights. Yes, "switch 1" AND "switch 2" must be closed to light the light. The logic here, then, is in the SWITCHES, not the signal.

So how does this have anything to do with comparing the logic states of 2 signals as in the below:

__/_/__Lightbulb
..| |
..| |
..1 2

These are switches wired in series, each with wires coming to them with their own source, and if the switch on input 2 is closed, the lightbulb will light. However, if both switches are "tuned" such that they close and thus only allow electricity to pass through them if the signal is above a certain threshold (e.g., 5V), then the switches themselves close, and the lightbulb lights. In essence then, a "comparison" of the signals themselves has been created in order to effect a desired outcome. The logic of this circuit is not really in the switches then, it is in the capacity of the signals themselves to turn the respective switch on if they're at a voltage level that meets or exceeds the threshold the switch is tuned to receive to turn on (frequently 5V or 3V).

Trying to get inside the brain of the system from an aerial viewpoint -- are both of these example concepts above independently employed in modern computers -- where the switches themselves determine the logic vs. the signals? Which one is used the most or at all?

Last edited:

#### tom66

Joined May 9, 2009
2,595

What you are asking is akin to asking is whether or not you turning on a light constitutes the switch or yourself having logic. While the switch controls the power, it only does so on command from an external signal, i.e. you. And since you have far more logic going on than a simple switch, I'd vote for you being the deciding factor.

Both parts are critical in the system.

#### rbaulbin

Joined Jan 4, 2011
14

What you are asking is akin to asking is whether or not you turning on a light constitutes the switch or yourself having logic. While the switch controls the power, it only does so on command from an external signal, i.e. you. And since you have far more logic going on than a simple switch, I'd vote for you being the deciding factor.

Both parts are critical in the system.

In the context of chips on a motherboard, things are turning on switches for other things. In the first example in the reply, 2 switches need to be closed by some outside force (one signal is required to get the "AND" function to be carried out. In the second case, 2 switches need to be closed by 2 independent signals: The nature of the signals determines the capacity for an "AND" function to be carried out.

Both light the lightbulb, but both are very different things because comparison is happening in the first case by flicking 2 switches with one signal, and in the second case 2 signals explicitly compared to attain the "AND" logic of 1. So they're both "AND" gates in a sense, but both are completely different... I'm trying to find out how much of what is going on where to see how logic flows in the system... Where is the "information" and logic comparison happening most of the time?

#### thatoneguy

Joined Feb 19, 2009
6,359
I think you are missing the "Abstraction Viewpoint".

An AND gate isn't two Analog->Digital converters to compare the magnitude of the signals.

Logic Gates have "Ground Rules", so to speak. With TTL, Low signal is Ground (NOT Disconnected), and a HIGH Signal is > about 3.7V.

With different classes of logic, those rules change. However, when those rules are followed, the expected behavior happens perfectly.

Abstractions and simplifications are found everywhere in electronics, the "Grandfather" of all of them is Maxwell's Equations. When certain limits are placed on Maxwell's equations (operating speed slower than speed of light, circuit is continual, etc), Kirchoffs Voltage Law and Kirchoff's Current Law are used as abstractions to dump off a huge amount of heavy math. Thevenin's Theorem, and Logic Gates are also abstractions, so if the rules are played by, everything "Just Works".

Example, modern computers are pretty much hitting a wall at 3.5Ghz. Their Logic High and Low are miniscule (<0.2 for low, and >0.5 for 1), the silicon chip is extremely tiny. Voltages are low, etc. To speed up systems, designers (AMD, Intel), are adding more "cores" to the processor.

When a smaller "process" of creating chips is available, speeds can still increase, but there IS a limit, at which point, logic will have to be designed from the ground up by Maxwell's equations, 4 abstractions away! OR, by an entirely New Insight such as quantum computers.

Known functions are added to known functions to make a block, be it an amp or a gate, they work, Within the Design considerations. Once outside those limits, you reach the no-mans land that has nothing to do with threshold levels.

#### Ron H

Joined Apr 14, 2005
7,063
In the context of chips on a motherboard, things are turning on switches for other things. In the first example in the reply, 2 switches need to be closed by some outside force (one signal is required to get the "AND" function to be carried out. In the second case, 2 switches need to be closed by 2 independent signals: The nature of the signals determines the capacity for an "AND" function to be carried out.

Both light the lightbulb, but both are very different things because comparison is happening in the first case by flicking 2 switches with one signal, and in the second case 2 signals explicitly compared to attain the "AND" logic of 1. So they're both "AND" gates in a sense, but both are completely different... I'm trying to find out how much of what is going on where to see how logic flows in the system... Where is the "information" and logic comparison happening most of the time?
I don't get the part about "flicking 2 switches with one signal". You have mentioned this several times, and I still don't get it. An AND gate requires at least two inputs. Of course, you can use the same signal to control both inputs, in which case your AND gate degenerates to a follower, or buffer (non-inverting).

#### Markd77

Joined Sep 7, 2009
2,806
What's really happening is the circuit inside the AND gate is measuring the voltages at the inputs (if they are higher or lower than the threshold) and then deciding whether to connect the output to the positive supply or the negative supply.
There isn't a current going from the inputs to the outputs, only the tiniest current will flow into the inputs, but the output can be comparatively large.

#### beenthere

Joined Apr 20, 2004
15,819
and in the second case 2 signals explicitly compared to attain the "AND" logic of 1
The signals are more explicitly not compared. If they happen to both be HIGH, then the output will be HIGH at and during that time. Call one input "A" and the other "B". Call the output "Q".

Get the data sheet for a quad 1 input AND gate (a 7408) - http://www.nxp.com/documents/data_sheet/74F08.pdf

On page 2 there is a truth table (they call it a function list). See how it works - Q is always LOW unless both A and B are HIGH.

In the contest of real mysteries, what does this mean? -
In the context of chips on a motherboard, things are turning on switches for other things.
You may not be aware of it, but all signals in a motherboard are clocked so that functions occur in synchrony. The data bus, for instance, has an applied clock to control the data. It is READ/WRITE^ (the ^ means not). When Read is HIGH, the data at that time is being read from memory or I/O. When the signal is LOW, data at that time is being sent to memory to be stored, or to I/O to be transmitted externally.

#### Papabravo

Joined Feb 24, 2006
21,225
A gate which compares two logic signals would be an Exclusive-OR gate. The output is 1(HIGH) if the two inputs are different, and the output is 0(LOW) if the two inputs are the same. If you add an inverter to the output you have an exclusive-NOR gate. In that case the output is 1(HIGH) if the inputs are the same and 0(LOW) if the inputs are different.

Either function can be expressed as a combination of AND gates, OR gates and inverters.

The mechanical switch analogy is just that. What changes the state of the switch may not be a signal -- it might be a finger on a hand. In household wiring it is not uncommon to have switches wired in parallel so they perform an OR function. The AND function is less common in household applications.

The switch analogy is also useful in industrial control applications which are designed using ladder logic with various mechanical switches and relay contacts.

#### Wendy

Joined Mar 24, 2008
23,427
Just throwing my two cents in. The two switch system you show would work perfectly for relays. The input of a relay is the coil (1 = powered up, 0 = no power), and the relay contacts are the gate.

Every family has its own internal self consistent rules. Step outside the rules and it doesn't work predictably anymore.

Status
Not open for further replies.