13
\$\begingroup\$

Why do we need to use transistors when building an OR gate? Wouldn't we be able to achieve the same result without transistors at all, just by joining the two inputs and reading the output?

\$\endgroup\$
  • 14
    \$\begingroup\$ There's that dangerous FLW (four letter word) 'just'! \$\endgroup\$ – Neil_UK Sep 16 at 5:18
  • \$\begingroup\$ You can't just join wires together. How would it know to be an OR, or an AND, or an XOR? However, you can do all this without transistors. Have a look at Harry Porter's Relay Computer, for example. \$\endgroup\$ – jonk Sep 16 at 5:19
  • 6
    \$\begingroup\$ @Neil_UK Don't you mean ETLW (Extended Three Letter Word). Cf. ETLA - Extended Three Letter Acronym \$\endgroup\$ – TripeHound Sep 16 at 13:00
  • 6
    \$\begingroup\$ What you propose has characteristics of an analog computer, and moves away from digital "gates". For digital gates having two states we use transistors with at least a little voltage gain or current gain to make up for losses. \$\endgroup\$ – glen_geek Sep 16 at 13:33
28
\$\begingroup\$

What you describe is called a wired OR connection. It is possible in some logic families, particularly ECL (emitter coupled logic), but not in the most common ones (TTL and CMOS).

In CMOS it isn't possible because when a CMOS output is low, it creates a very near short from the output pin through the chip to ground. And when it is high, it creates a very near short from VDD through the chip to the the output pin.

So if you tied two CMOS outputs together and one output high while the other output low, you'd have a very near short from VDD to ground, which would draw a large current and likely overheat one or the other of the two chips involved.

For TTL, there's a similar issue, but the "shorts" from the output pin to VDD or ground aren't quite as near short as they are in CMOS.

There's a variant output style, called open drain for CMOS or open collector for TTL, that allows wired AND connections rather than wired OR. These outputs are designed to only be able to sink current to ground, not to be able to produce any output current when they're nominally in the high state. These are normally used with an external pull-up resistor so that the output voltage will actually reach the "high" voltage level when required.

Note: Open collector or open drain can be used for wired OR if you use active-low logic (low voltage represents logic 1, high voltage represents logic 0).

\$\endgroup\$
  • 3
    \$\begingroup\$ Nah. All that stuff still uses transistors. This is a true wire-OR gate. Just need a few wire bending jigs. Like we used to do, "back in the day," around the time we used 7 switches and a push button for a keyboard. And it can be easily read by a human looking down on it. Of course, the human will also need to trace backward along the wires to see the other gates involved and eventually back to the "wire inputs" at the beginning. The OP wanted to know about the zero-transistor case. ;) \$\endgroup\$ – jonk Sep 16 at 5:15
  • \$\begingroup\$ @jonk, Just mechanically couple the keys on the keypad and you don't even need wires to make an "OR". \$\endgroup\$ – The Photon Sep 16 at 5:20
  • 1
    \$\begingroup\$ Well, there's more than one way to skin a cat, I suppose. :) (And by the way, I actually did use 7 switches and a push button for a keyboard "back in the day.") \$\endgroup\$ – jonk Sep 16 at 5:22
  • \$\begingroup\$ @jonk, that's well before my time. TIL what octal notation is for: Saves you a couple bucks worth of switches for your hand-keying interface. \$\endgroup\$ – The Photon Sep 16 at 5:27
  • 1
    \$\begingroup\$ See this datasheet of the 7403 family. "The open-collector outputs require pull-up resistors to perform correctly. They may be connected to other open-collector outputs to implement active-low wired-OR or active-high wired-AND functions." \$\endgroup\$ – Uwe Sep 16 at 17:28
13
\$\begingroup\$

this lets you "join the outputs"

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
  • 26
    \$\begingroup\$ Is there a specific reason why this answer is completely in circuitlab? I think the quality suffers a bit when the text is contained in a picture. \$\endgroup\$ – Arsenal Sep 16 at 14:47
  • 6
    \$\begingroup\$ @Arsenal - Agreed. IMO, in addition to it being lower quality and more difficult to visually parse, the biggest issue to me is that the content of the answer is not text-searchable... \$\endgroup\$ – Hitek Sep 16 at 20:53
  • 2
    \$\begingroup\$ That's the right answer. You don't need transistors for a gate, depending on your logic conventions, but they help performance and noise immunity (and you obviously need one as soon as you incorporate an inverter). And in the modern world, I suspect two MOSFETs is no more silicon than two diodes? \$\endgroup\$ – Rich Sep 17 at 1:14
  • 2
    \$\begingroup\$ imgur is blocked for me. The entire answer reads: this lets you "join the outputs" schematic with a link to circuitlab \$\endgroup\$ – tolos Sep 17 at 12:46
8
\$\begingroup\$

If you just connect the wires, you'd have the (fairly likely) possibility of a 0 and a 1 together. Since a 0 is gnd, and a 1 is 5V (depending on the chips, but it's a standard), you'd have 5V and gnd connected together by wires. The term for that is a short circuit!

You could use diodes for a simple OR gate. Or even resistors. The problems occur when you connect this gate to other gates, other circuitry. You can build an AND gate from 2 diodes the other way round. But if you try connect a lot of them together you end up with one giant circuit that doesn't function as small separate parts, but as one big one. Connections that aren't in your simple gate plan, might crop up in real life, messing up what you want to happen.

A transistor lets you separate the input from the output. The output of a transistor can't feed backward and affect it's input. A relay would be another alternative, though slower. Since the switch can't affect the electromagnet.

Early logic was RTL or DTL, resistor-transistor logic, or diode-transistor logic. Resistors, at first, then later diodes, were used to form the gate, then a transistor acted to buffer the result so the next gate you used didn't feed back through this one to it's inputs.

Now, since transistors on chips are virtually free of charge, financially that is, we have the luxury of everything being properly buffered and separate. Usually that's what we want. TTL logic!

\$\endgroup\$
  • \$\begingroup\$ Thanks for the excellent explanation! \$\endgroup\$ – Tarek Sep 16 at 23:00
  • \$\begingroup\$ You're welcome! \$\endgroup\$ – Greenaum Sep 16 at 23:37
5
\$\begingroup\$

Consider what happens if one input is high and one is low, and you connect the two inputs. It depends on how you build your logic gates.

If your logic gates are designed so that a high is really pulled high and a low is really pulled low (CMOS) then this is a short circuit and something will blow up.

If your logic gates are designed so that a high is "weak" or high resistance (e.g. NMOS) then the output will be low, but also the other input (that is supposed to be high) will be forced to be low even though it's supposed to be high, and this will have a knock-on effect on other logic gates which use the same input.

\$\endgroup\$
1
\$\begingroup\$

There is an analog approach:
Combine any number of inputs (suppose either 0 or 5 volts) with resistors.
If the result voltage is 0, all are off.
If the result voltage is 5, then all are on.
In-between voltages indicate that some are on and some are off.
Example: If there are 4 inputs, 2.5 volts means 2 are on and 2 are off.

result == 0: nor gate
result == 5: and gate
result != 0: or gate
result != 5: nand gate

You don't need transistors for the inputs, just for the output to check the voltage and restore a 0 or 5 volt logical result.

This might be used for an analog neural network node with a non-linear output function that has a "soft" result that might not be entirely true or false.

After thought:
Resistors used this way can slow down logic speed since capacitance following the resistors must be charged or discharged when inputs change. Also, use of transistors can greatly reduce power consumption. Resistors used this way can always consume power with a mix of input states. With transistors, power consumption can be roughly divided by the gain of the transistors.

\$\endgroup\$
  • \$\begingroup\$ Very interesting, thanks! \$\endgroup\$ – Tarek Sep 19 at 2:09
0
\$\begingroup\$

With some logic elements (all car door swithches ighting up the same lamp) this is possible, but not for example with CMOS gates as they are built with P and N channel FET transistors so they need defined high and low voltage input to provide the output, the input cannot be left to float. Connecting CMOS outputs together would not work.

\$\endgroup\$

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.