Electronic – Inside a CPU, what happens in a single clock cycle

processor

In grossly simplified terms, a processor calculates 1 instruction in a single clock cycle. But what does that even mean? If a processor is a bunch of transistors, is 1 clock cycle simply 1 state change (or the potential for a state change) for all those millions of transistors? Is 1 clock cycle how often the state of every transistor get evaluated? What exactly is happening, electrically, in 1 clock cycle?

Best Answer

The transistors in a CPU will be arranged to form small functional units. These fall into two main categories: combinatorial logic (logic gates, adders, multiplexers, etc.) and stateful logic (flip flops, latches, SRAM, etc.). Combinatorial logic performs various logical and mathematical operations, while stateful logic can store data. Generally the clock is only connected to stateful logic, such as flip-flops. Combinatorial logic is then connected between stateful logic elements. So you might have a flip flop that feeds some logic gates, which then feeds another flip flop. Combinatorial logic has a propagation delay associated with it--how long it takes for the output to change after the input changes. Each flip flop will transfer whatever logic level is on its input through to its output on the active clock edge, once per clock cycle. The fastest possible clock period is then determined by the longest propagation delay through the logic between the flip flops.

So yes, your statement is essentially correct that each clock cycle is essentially one state change.

In a CPU (or any other synchronous digital logic), the clock serves merely to synchronize the flow of data though the chip such that computations are preformed correctly. The clock is necessary because the propagation delays through the logic can vary, either along different paths or with process, voltage, and temperature (PVT). Incidentally, this is why you see sites like silicon lottery and why CPU manufacturers sell multiple versions of the same chip that run at different speeds--variations in how each chip gets produced mean that the propagation delays of the logic will all be a little different, so some chips will support faster clocks than others.

It is possible to design CPUs that do not use a clock. This is called asynchronous design. It has the advantage of not requiring a clock and all of the complexity and power consumption associated with it, but asynchronous design is more difficult as the circuit must be designed such that no propagation delays are violated, even with variations between chips and across different voltages and temperatures. I have heard that a company made an asynchronous CPU quite a few years ago, and it would slow down if you set a cup of hot coffee on top of it due to the asynchronous logic adjusting to the temperature change.

Related Topic