16

Consider:

Enter image description here

I can make no sense in my head how this can work. How is it possible to have a current flow through normal diodes from cathode to anode and represent an AND if both are 1?

Peter Mortensen
  • 1,676
  • 3
  • 17
  • 23
  • 4
    Note that this circuit typically *works* but it has no `gain` and as a result cannot restore `noise margins`. Typically, at slow to moderate speeds you can get away with doing something like this once in between conventional gates or other functional blocks having gain, but you can't really have a sequence of passive gates like these feeding one another without quickly running into problems. Still, tricks like this can be very useful when you have ICs that almost do what you need, but need a trivial amount of "glue" in between and the signals aren't too fast. Otherwise there's tinylogic. – Chris Stratton Oct 21 '17 at 17:29

2 Answers2

29

Imagine A and B are both high. Then there is no current that flows out of A nor is there current that flows out of B, so S is high.

schematic

simulate this circuit – Schematic created using CircuitLab

Now if A is low, the diode allows A to draw current, which pulls down the node voltage of S, so the voltage of S corresponds to the voltage drop of the diode when current is flowing through the resistor and the diode... which is approximately 0.7V, or 'low'.

schematic

simulate this circuit

Same if B is low.

Same if A or B are low.

Therefore, both A and B must be high in order for S to be high... AND gate!

As stated by fukanchik in the comments, the role of the diodes is to prevent the inputs from interfering with one other when they are in different states, but the diode is only necessary with inputs that can sink and source current. If the inputs can only sink current, such as in an open-collector configuration, then the diode is not necessary

schematic

simulate this circuit

slightlynybbled
  • 1,804
  • 12
  • 23
  • That's what I thought, too, but if there's no resistance between the source and S, why would anything ever flow through A or B? – Phil N DeBlanc Oct 20 '17 at 16:34
  • 1
    The 'source' is the 5V pull-up resistor. When A and B are high, S is only high because it is being pulled up by the resistor. No current is flowing through the diodes at all. When A or B is low, it has the result of pulling down the voltage of node S by sinking current, thus, (approximately) all of the 5V drop is across the resistor. – slightlynybbled Oct 20 '17 at 16:38
  • @PhilNDeBlanc current only flows left through those diodes, when the input is low, sourced from the pullup and from whatever follows. – Trevor_G Oct 20 '17 at 16:38
  • 2
    @PhilNDeBlanc I added a bit of clarification to the second paragraph. Hope it helps. Enjoy! – slightlynybbled Oct 20 '17 at 16:41
  • 3
    You should add that the role of diodes is to prevent current to flow from one input into another when inputs are not equal (01 or 10). – fukanchik Oct 20 '17 at 17:47
  • 1
    It may help to explain De Morgan equivalence -- this is a negative logic OR gate. – amI Oct 21 '17 at 20:56
10

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. Four possible input conditions.

The only one of the four switch combinations that allow the output to pull high is '11'. That is, by definition an AND function.

Transistor
  • 168,990
  • 12
  • 186
  • 385
  • +1 Can always trust you to use great illustrations. :) Might be nice to add the voltages to the 0 and 1 flags for even more clarity. – Trevor_G Oct 20 '17 at 17:16
  • 3
    If all diodes are replaced by wires you get the same results. I think this illustration is not representative of how the gate works. – Anonymous Coward Oct 20 '17 at 18:50
  • 2
    It directly answers the OP's question, "*how its possible to current flow through normal diodes from cathode to anode and represent an AND if both are 1.*" Please feel free to write an improved answer. – Transistor Oct 20 '17 at 19:00
  • In addition, this AND gate is shown in isolation. The point of the diodes is to prevent one input pulling down the other and affecting other gates or logic connected to that input. Replacing with wires would not give the same result. – Transistor Jun 05 '19 at 20:20