Transistors operate as switches just like the ones you see below), the only thing is you don’t switch them on/off physically. Transistors can store binary value 0 (when current is not flowing through the base) and 1 (when current is flowing through the base). But, you may think how is this so different from a physical switch we have in circuitry like the below.
Transistors as switches
Physical switches (like above) have physical actuation – it has to be switched on/off by pressing it. If you try doing it, you’ll realize you won’t be able to do it maximum 2-3 times per second. Whereas transistors have electronic actuation basis the current flow, which means the transistor on/off is controlled by low voltage current flow to the base. The advantage with this is: transistors can be switched on/off many number of times, like 1000s of times in a second. Some transistors work at KHz and some transistors at GHz too (that is the number of on/offs that can be done per second).
The advantage of it is: the higher the frequency of switching, the more 1s and 0s the transistor can process – indirectly meaning the more data the processor can process.
For example, if a transistor can switch on/off in one second, it can be in two data states in one second. But, if it can switch on/off 8 times per second, then it can handle 8 bits in one second. Now, imagine transistors having a switching speed of MHz (one million times per second). And then imagine billions of transistors switching on/off millions of times – that is exactly what is happening inside the processor.
Step 1: When you put two transistors together with capacitors and resistance, you get various circuits called GATES. These are different types of GATES such as AND, OR, NAND, NOR, and NOT gate. Refer this beautiful depiction of GATES built from transistors: http://hyperphysics.phy-astr.gsu.edu/hbase/Electronic/trangate.html#c1
Step 2: Put together these GATE circuits and you make flip-flops. Flip-flops are the circuits that each have 1 bit memory. These circuits are used make memory cells and integrated circuits.
Step 3: Use memory cells and gates to make an Arithmetic Logic Unit (ALU).
Step 4: Now, use an ALU with some instructions (instruction register) and few memory cells to understand which line you’re processing and which line the output will be represented on. Now, that becomes a CPU.
Step 5: Now, we have a CPU that works, but we need some program to start the CPU and load the first set of instructions, and that program is BIOS that automatically runs when you switch on the system.
Hope this is useful to learn how transistors become the CPU in a simple manner.