# Diodes for implementing digital logic

This diagram in this post is from Microelectronic Circuits by Sedra and Smith. The question corresponding to this picture asks to write a truth table with A and B as inputs and X and Y as outputs and to state what functions are being implemented.

Looking at this link, it seems like the second circuit implements the OR function because a 1 at either input turns one of the diodes on, so in the ideal case it acts as a short, and the applied positive voltage appears at node Y.

I am not sure about the circuit for part a though. It is structured similarly to the AND gate circuit in the link. I understand the reasoning for why that circuit implements AND. If both inputs are 0, both diodes are off and act as open circuits, so the output would be HIGH with no voltage drop across R. If one or both inputs are 0, the output is connected to ground, and the result is LOW.

However, the circuit in the link has a 5V source connected to the diodes, but in my problem, a current source is connected, so I am not sure if the reasoning they provided would apply here.

How does the part a circuit work? • In Part (a), they use an ideal current source. If both A and B are HI, then the output of the current source will be forced to go still higher (non-ideal diode case) in order to force the sources at A and B to sink the current. So in the ideal diode case, X is HI and must be. But if either one of the diodes has their input LO, then the current source will just use that diode (or both, if possible) to sink its current. And so X would have to be LO and any diode attached to a HI source would be OFF. Sep 20 at 1:57
• Sorry for the late response. Now it makes sense to me what happens when either input is LOW, but I am confused about the case when both A and B are high. You said that when both inputs are 1, the current source's "output" grows for the source's current to be sinked. Does output mean the amount of current supplied, or is the output the voltage at node X? If "output" is the voltage at node x, how is it possible for the current source to increase that voltage? Sep 20 at 2:45
• If output is the voltage at node x, then I do understand that if this voltage increases, the diodes turn on and current can flow through them Sep 20 at 2:48
• What you have drawn are current sources, which is not what you want. Replace those with simple resistors to voltage sources (as in the referenced link) and then look at the resulting current through those resistors. Sep 20 at 3:40
• Yes, replacing the current source in the part a circuit with a voltage source + a resistor does help. Now the circuit is the exact same as the one from the link. Thank you. Sep 20 at 10:51

# Considerations

This is the first time I have seen such a weird diode gate implementation with a current source, so I cannot immediately figure out what the point is. But here are some considerations that may help you to answer your question:

• In both circuits, there is no load connected to the output (open circuit).

• At the same time, there are always voltage sources (either LOW or HIGH) connected to the input.

• There are diode networks (only diode or an input voltage source and diode in series) that are connected in parallel. In the circuit (a), the current will flow (will be diverted) through the network with a higher forward voltage drop.

• If there is a low input voltage, the current source will pass its current through the diode networks with zero input voltage applied which are forward-biased; so the output voltage will be low.

• If there is no low input voltage, the current source will pass its current through the diode networks with high input voltage applied; so the output voltage will be high.

• Figuratively speaking, the current source is looking for a path to pass its current, and finds it through the diode network with the lowest forward voltage drop.

• In circuit (b), however, it is the opposite. It would be interesting to explain why...

# Simulations

## Circuit (a)

Of course, these explanations can be illustrated with impressive CircuitLab simulations to see where the currents flow. For simplicity, I have presented (implemented) A and B logic variables by VA and VB 5 V voltage sources. When A(B) is LOW, the corresponding voltage source is replaced by a "piece of wire", and when it is HIGH - the voltage source is inserted. I have also considered the interesting case when the input sources are disconnected aka "high-impedance state" (HI).

Also, I have used ideal diodes (with VF = 0) for the purposes of this conceptual circuit.

A = LOW, B = LOW: As you can see, the current source splits its current into two equal parts that flow through the two ideal diodes in parallel. The voltage drop Vout across them is zero. simulate this circuit – Schematic created using CircuitLab

A = LOW, B = HIGH: Now all the current flows (is steered") through D1 since its voltage is less than the total voltage across D2 and VB. So Vout = 0 V again. simulate this circuit

A = HIGH, B = LOW: Similarly, all the current flows through D2 since its voltage is less than the total voltage across D1 and VB. Vout = 0 V as above. simulate this circuit

A = HIGH, B = HIGH: In this a little more interesting case, the two "diode + voltage source" networks are connected in parallel. Now the current source splits its current into two equal parts that flow through the two networks. The voltage drop Vout across them is 5 V. simulate this circuit

A = HI, B = HI: The most interesting (but dangerous!) case is if you accidentally disconnect the input voltage sources. Then the current source has nowhere to pass its current, and in its quest to do so, it starts desperately increasing its voltage to infinity. In our case, because the CircuitLab voltmeter still has some very high resistance (see it in the Vout parameters window), the voltage stops at 1 MV (megavolts). If you decrease the voltmeter resistance e.g. to 10 kΩ (by double clicking the voltmeter and writing 10 k in the parameters window), Vout will be only 10 V. simulate this circuit

## Circuit (b)

A = LOW, B = LOW: Same as the circuit (a). simulate this circuit

A = LOW, B = HIGH: There is a difference here since the diode D2 connected in series with the voltage source VB is forward biased. So V2 applies its 5 V voltage (with reverse polarity) through D2 to D1. As a result, D1 is backward biased and all the current flows through D2 and VB. Vout = 5 V. simulate this circuit

A = HIGH, B = LOW: Similarly, all the current flows through D1 since VB is backward biased. Vout = 5 V as above. simulate this circuit

A = HIGH, B = HIGH: Same as the circuit (a). simulate this circuit

A = HI, B = HI: Same as the circuit (a); only Vout is with reversed polarity. simulate this circuit

• These simulations are helpful, and I am understand the part a circuit better. If I am understanding things correctly, current I needs to flow through a diode to ground, so Vout is going to change values depending on inputs A and B in order to allow that. For the considerations you listed, those are referring to the part A circuit, right? (which implements AND). Also, I am unsure about circuits 1.5 and 2.5. Does "HI" mean high impedance? If there is high impedance, I do not understand how the current is going to reach ground and why Vout becomes +/-1mV. Sep 20 at 11:14
• @Hamza Beder, I preferred to answer you in the body of my answer. As you can see, understanding this circuit requires you to have a good idea of ​​the behavior of an ideal constant current source (most people don't). In short, at the cost of everything, it tries to overcome the resistances and voltages that are harmful to it. To do this, it raises its internal voltage to +/-1 MV (megavolts, not millivolts). Sep 20 at 12:00