Electronic – How Specifically the Control Unit (CU) Works

circuit-designcontrolcpu

I am a software developer now interested in the electronic implementation of computers.

When I think about computers, the thing performing the action is the "processor". But the processor is technically the CPU. So looking within that, what looks like is doing the actual processing is the Control Unit (CU). It turns out the GPU also has a CU(s).

The CU receives external instructions or commands which it converts into a sequence of control signals that the CU applies to the data path to implement a sequence of register-transfer level operations…
Hardwired control units are implemented through use of combinational logic units, featuring a finite number of gates that can generate specific results based on the instructions that were used to invoke those responses. Hardwired control units are generally faster than microprogrammed designs…
The algorithm for the microprogram control unit is usually specified by flowchart description.

It is said that the control unit is what actually reads instructions from memory and runs them. But I'm wondering how exactly this works. Maybe not specifically the circuits because that seems highly dependent. But at a high level, what is the "spark" that actually is moving around electronically. What types of circuits there are involved. Whereas disk storage has a very detailed description (below), CU's don't (on Wikipedia).

My questions are:

  1. On a modern computer like the MacBook Pro, if the CU is hardwired or a microprogram.
  2. What is the actual spark or piece of electricity that is doing the "processing", i.e. "moving around the memory". How it actually "fetches from memory" and "stores to memory" and "fetches an instruction" and "executes an instruction". How it "reads an opcode", etc.. Wondering what is actually going on at the electronics level. Don't need to know each piece in detail if it's too complicated, just at a high level the electronics involved of any one of them.

While flip-flops have a detailed description so you can understand how actually a "bit" is stored, the CU is lacking so I can't actually tell how the program is "running". I would like to be able to explain how the computer runs, at a deeper level than that instruction cycle, down to the electronics.


Magnetic disk storage demo of how detailed the description is, to show you how it works.

…Due to the polycrystalline nature of the magnetic material each of these magnetic regions is composed of a few hundred magnetic grains. Magnetic grains are typically 10 nm in size and each form a single true magnetic domain. Each magnetic region in total forms a magnetic dipole which generates a magnetic field….

Best Answer

If you understand how a flip-flop (FF) works, the rest might be more understandable.

As Wikipedia states, a CU, or "control unit", is "digital circuitry contained within the processor that coordinates the sequence of data movements into, out of, and between a processor's many sub-units". In other words, it is a hard-wired sequencer, a machine that moves from one state to another as external clock ticks.

The CU is a collection of FFs with combinatorial logic wrapped around, which forms so-called "finite state machine". A set of FFs defines the states of this sequencer, each binary value defines a state. Different states of CU result in different actions for associated "sub-units", and define the next state.

As soon as the external hardware reset ends, the sequencer starts moving along a pre-defined sequence with each clock tick. Roughly speaking, the first state is to generate a signal to memory controller to "fetch" the very first instruction from a pre-defined memory location. This memory must contain a meaningful code sequence pre-loaded there somehow.

Then the CU waits for the memory controller (one of its "sub-units") to deliver the first instruction. The instruction is fetched into another set of FFs called "register", and is fed into another "sub-unit" called "instruction decoder". Depending on results of decoding, the CU proceeds with appropriate actions by moving to appropriate "next state", like instructing the same memory unit to fetch another argument from memory, or storing the result.

The above is just a basic idea. In reality everything is much-much more complicated. The Internet, however, should have plenty of animations for basic CPU behavior, like this video. This link might give you a better hint how the basic sequencer works.

Regarding whether a CU is "hardwired" or "microcoded", details of sequencer implementation are inconsequential. Typically the core of CU is "hardwired", but certain functions can be controlled by "microcode", and can be modified via "CPU patch".