Fan-in is simply the number of inputs on a gate. A NOT gate has a fan-in of 1, a standard 2-input NAND has 2, and a 4-input OR has 4.
In logic terms a multi input gate works just like its 2-input version. In hardware, fan-in is limited. In CMOS, each extra input on a NAND or NOR adds a transistor to a series stack, and a long stack switches slowly. So libraries offer gates with up to about 4 inputs, and wider functions are built from several gates.
How to build a wide gate from 2-input ones:
- AND, OR, XOR: connect gates of the same type, because the operation is associative. A tree (pair up inputs, then pair up the results) is faster than a long chain. A chain of n inputs is n − 1 gates deep, while a tree is only about log₂ n deep.
- NAND, NOR, XNOR: don't chain them directly. Build the AND, OR or XOR tree first, then make the last gate the inverting one.
Fan-in is easy to confuse with fan out, which counts how many gate inputs a single output drives. Fan-in is about a gate's inputs; fan-out is about where a signal goes.