In my digital electronics labs and lectures we are told to try and make things from NAND gates, because they are the cheapest kind of gate available to buy. Why is this? Why isn't an OR/AND gate the cheapest to buy?
NAND gates are cheap because there are so many of them lying around from the 1980s.
Seriously though, a NAND gate is about the simplest logic gate. You can think of it as a multi-input inverter. Electrically, that's exactly what TTL NAND gates are. Each input is just another emitter added to the input transistor. The rest of the circuit is just a inverter. It's different in CMOS, but a NAND gate is still very simple.
Since the chips require few transistors, they can be small, which allows lots of them per silicon wafer, which makes them cheap.
One of the reasons this may be said is that in CMOS circuits, a NAND gate is both smaller, area-wise, and faster than a NOR gate, whereas AND and OR gates require an explicit inverter circuit which is comparable in size to NAND/NOR. So in CMOS, NAND is a tiny bit cheaper.
This is not true of nMOS (it's the other way round there), and most certainly doesn't apply to packaged gates like the 74x series - the area cost is completely eclipsed by the cost of packaging and other overheads.
Reference: VLSI Design by Peter Robinson, p.14, "In CMOS, the NAND gate has better speed and area characteristics than the NOR gate".
Reference 2: here, paraphrased: "In CMOS, the NOR gate has two pMOS in series making it slower due to the poor mobility of the holes."
Any logical function can be built from NAND (or NOR) gates, even complete systems. OR and AND gates cost about the same as NANDs, but you need inverters as well. 1,000 NAND gates will be cheaper than a mixture of ORs, ANDs and inverters.
Seymour Cray used to build his Cray super-computers from ECL NOR gates for that reason.
A few points not yet mentioned:
- In TTL logic, which used to be the "normal" type before MOS-based logic totally took over, a two-input NAND gate requires four transistors, one of which has two emitters; a two-input NOR gate would require six transistors (each with one emitter). More generally, an N-input NAND gate would require four transistors, one of which has N emitters; an N-input NOR gate would require 2N+2 transistors.
- In NMOS logic, an N-input gate, whether NAND, NOR, or some combination thereof (with only a single inversion, at the end) would require N transistors and one resistor. In NMOS, NOR gates are slightly faster than NAND gates.
- In CMOS logic, an N-input gate, whether NAND, NOR, or some combination thereof (with only a single inversion, at the end) would generally require N PMOS transistors and N NMOS transistors. A NAND gate will be slightly faster to output a "high" than will a NOR gate, with the difference becoming more pronounced as the number of input increases. A NOR gate, however, will be slightly faster to output a "low" than will a NAND gate. Since CMOS technology is, all else being equal, slightly slower to output high signals than low ones, a NAND gate may have somewhat more "balanced" output times.
- In most CPLD designs, the fundamental logic block consists of a bunch of many-input NAND gates (where inputs may be connected or disconnected) whose outputs drive a bunch of many-input NAND gates. Note that documentation generally shows a bunch of "AND"'s driving a bunch of "OR"'s, but NANDs driving NANDs will yield the same behavior as ANDs driving ORs, but with fewer inversions, since a NAND gate is not only an an AND with an inverted output, but behaves the same as an OR with inverted inputs. Son take the ANDs and ORs, invert the outputs of the ANDs and the inputs of the ORs (which one can do, since the two inversions cancel), and one is left with NANDs driving NANDs.
Any logic design which doesn't desire three-state logic or optimal speed can be implemented entirely with NAND gates. That isn't to suggest that NAND gates are always the most practical way of implementing things. An exclusive-or gate, for example, would take four two-input NAND gates to build, representing a total of sixteen transistors in CMOS. If one builds a CMOS exclusive-OR gate directly out of transistors, however, the job may be done with eight.
As well as being simple, NAND gates can be used in the place of all other gates, therefore, when companies buy in bulk, they buy only NAND gates because they can be used for everything. This saves them storage space and cheaper in bulk. Therefore, producers follow trend - more demand allows them to decrease price to increase future profits.