# Can an operational amplifier circuit be made entirely out of diode Nand and Nor gates?

I'm not sure whether this question has been asked before, but in researching my question, I came across this user's post (at If-else decision structure using op amps or any other non-programmable electronic device), which appears to ask my question in reverse. This user seems to be asking (effectively) whether OP Amp circuitry can be constructed in such a way as to mimic or "emulate" logical operations (or by extension, logic gates). My question, which is precisely the reverse of that, is can a circuit, consisting entirely of particular combinations of NAND and NOR diode logic gates, be constructed to function like an Operational Amplifier? (I recently asked an electrical engineer that question, and his brief answer was "no". But he never explained why he believed that it could not be done. If it cannot be done, there should be a rational reason why that is the case.) I suppose that an equivalent alternative way of phrasing my question might be, can there exist an algorithm for simulating all of the operations of an Operational Amplifier? --John

-

Can An Operational Amplifier Circuit Be Made Entirely Out Of Diode Nand And Nor Gates?

This apparently simple-enough question is somewhat ambiguous and can be answered several ways.

• Spehro has assumed that you convert the input to a digital value and perform digital arithmetic on it. So he says the answer is yes.

• ScottMcP takes your question at face value, notes that you say "diode gates", which have no gain, assumes that you want to use the digital gate as an analog amplifier, and as diode gates have analog gains of < unity, says no.

• WhatRoughBeast also takes the "digital gate as analog amplifier" and notes that the digital gate lacks features needed to make an opamp. But he also notes that you can make a single input amplifier using a digital gate as an analog gain stage.

• Placeholder adopts "digital gate as analog stage" approach BUT goes the second mile and shows how a "true" [tm] differential input amplifier could be constructed.
• There another option, not covered so far. That is, inputting analog signal into a digital gate which is acting as a "digital" oscillator (albeit using an analog timing delay) so that the gate outputs a digital signal, but the gate's digital operation (in this case the oscillator mark-space ratio) is affected by the analog signal, allowing amplification in the digital domain and then conversion back to audio.

Below I cover the "digital gate converted to an analog amplifier" aspects and then introduce the rarely seen [draws deep breath] "digital gate acting as an analog amplifier while producing digital output which can be easily be converted back to analog" concept. Usually more fun than useful, but potentially of value 'in an extreme situation'.

So:

Gate is digital, signals are analog"

No, not if the gates are used as digital logic gates and the amplifier deals only with analog signals.

Diode resistor logic gates with no gain.

And, also no, if the gates have no "gain".

• Diode & resistor only gates have no gain - but they are also never used in anything practical because of loading by subsequent stages.

"DTL" gates operating in analog mode.

Only "sort of".

DTL = Diode-Transistor-Logic gates can have gain and can be made into (not very good) amplifiers by using them "strangely". The series diode connected inputs place constraints on what can be achieved with analog inputs. You'd have to be very keen.

More modern digital gates in analog mode:

If you are prepared to use digital gates in analog mode, as is done in some applications, then yes, it can be done. This is relatively unusual in everyday use and is usually a compromise or "done for fun" or extreme cost cutting.

General background:

An "Op-Amp"is an analog signal amplifier with high gain (Vout/Vin = "high", a high input impedance and a low output impedance. I could explain what "analog" means in this context but, if that's unclear, it's an essential part to understanding the question, let alone the answer, and you can very easily research it yourself.

If SOME digital gates have connections made from output to input via a resistor or resistor network, they can be biased into a linear state and then used as an analog amplifier.

Some Diode AND and OR gates MAY be able to be biased in this manner and so used as an amplifier. This is not using them in their intended mode and the amplifier quality would be poor. The diodes would add very significant distortion. Even older RTL logic may work better than this but it's still not a true digital gate when used this way.

Example of a modern CMOS gate being used in an analog biased mode to create a lineara amplifier.

They say:

• CMOS inverters can be used as linear amplifiers where negative feedback is applied. Best linearity is achieved with feedback applied around three inverters which gives almost perfect linearity up to a dynamic output of 5 V peak to peak with a 10 V supply rail The gain is set by the ratio of Rl and R2 and the values are typical for a gain of 100. The high frequency response with the values given is almost flat to 20 kHz. The frequency response is determined by Cl and C2..

This circuit is not suitable for low level signals because the signal to noise ratio is only approx 50 dB to 5 V output with the typical values shown.

Analog amplifier with purely digital gate:

You will only rarely find this concept described. It works.

BUT (and many people are not aware of this) you can use some sorts of digital gates as analog amplifiers while remaining in a digital mode. This is a rather (or very) special case.

eg if a 74C14 Schmitt triggered input inverter has a resistor connected from output to input it will oscillate (for a certain range of resistors), using stray capacitance as part of the RC timing circuit. If you now AC couple an AC signal to the input the output will be pulse width modulated. If you low pass filter the output signal you can get amplified analog. Ask me how I know :-). The secret to "keeping it digital" is the Schmitt trigger input. The gate cannot be biased into a linear mode due to hysteresis and oscillates instead.

fosc should be >> finput. As the gate input is driven above half way by the incoming AC the negative to positive transition times of the oscillation are skewed, and similarly as Von falls below half voltage, but with opposite effect on mark space. The resultant output is variable mark-space PWM driven by Vin. Filtering this AC signal recovers the amplified signal.

Diagram based on this original

-
"digital gate converted to an analog amplifier" I believe they call them Class-D amplifiers. They are the cheapest and most efficient amplifier designs available. It is likely your portable electronics uses one. – Aron Jul 23 '14 at 17:16
The easy answer is no, I like that Sphero found a yes. (oops Spehro, couldn't you just change your name Sphero, it's got such a nice round feel :^) @Spehro Pefhany – George Herold Jul 24 '14 at 0:13
@DietrichEpp In my example with the Schmitt trigger input gate then, no, the gate's output transistors are running as pure switches. The output (which I show as "PWM") is a rail to rail 'square wave' with variable mark-space. It's Class D, with the relative magnitude of mark and space periods affected by how much the analog input assists or opposes the feedback via Rosc. The gain of the amplifier is affected by the ratio of Rosc and input impedance. If the input can perturb the mean current substantially the mark:space is affected more and the filtered output has a greater signal component. – Russell McMahon Jul 24 '14 at 6:41
@Aron -Indeed. Class D it is - but you'll seldom see it achieved this informally. It's very easy to look at the circuit and think it must be running in linear mode - and, without Schmitt trigger input it would be. – Russell McMahon Jul 24 '14 at 6:42
Ah... I'm used to seeing the little squiggly hysteresis mark, I didn't bother reading the notes. – Dietrich Epp Jul 24 '14 at 7:56

The heart of the operational amplifier is the difference amplifier, where a current is divided between a pair of highly matched input transistors. This is what allows high gain combined with low offsets. Logic gates simply don't have the geometry to do this.

That said, logic inverters (and by extension almost any inverting gate such as a NAND or NOR), has the potential to be used as a linear amplifier - provided you can provide proper biasing and don't expect great performance. This approach is commonly used in producing low-performance crystal oscillators, which don't require purity of output waveform or exceptional stability. Back many years ago I seem to recall the occasional circuit idea using CD4000-series inverters as AC-coupled amplifiers, with such use limited to the non-buffered gates. But these applications are not operational amplifiers, merely more-or-less adequate single-ended amps. I also seem to recall that they had very limited linearity.

-
See my 'digital gate in digital mode as analog / PWM / analog amplifier' example :-). More fun than value. – Russell McMahon Jul 23 '14 at 4:13

Sure, if you have digital numbers for the input voltages an op amp merely does the calculation Vout = Av(Vin+ - Vin-). Easily done with gates (and either NAND or NOR gates would be sufficient).

NAND and NOR gates require more than just diodes, they require transistors, of course. OR and AND gates are not sufficient.

If you do the calculation periodically (meaning some kind of clock) you can simulate an analog op-amp arbitrarily closely, assuming the calculations are fast enough and the digitization is below the noise floor of the analog op-amp.

-

One of the simplest op-amps looks like this:

simulate this circuit – Schematic created using CircuitLab

And you can build it using NAND gates:

simulate this circuit

simulate this circuit

Keep in mind that this will be crap, and will operate only over avery narrow range. The primary tool for operation that we have in the design of op-amps from transistors is playing with the widths and length of the transistors. We could do this here a little bit, especially in the diff pair as I could parallel several NAND gates.

Of course I haven't given you the necessary background to understand how this works, but the circuits (topology) are identical. To clarify things, if something is not hooked up, then ignore it and if you trace the connections you can see that I have duplicated the op-amp using 5 NANDs.

-

An operational amplifier must have gain. There is no way to get gain out of diodes.

-