With our interpretation, the computer structure has become clearer and clearer. We know that computer commands are combined into programs to control hardware work, this cleverly controls the same hardware by writing different software to complete different tasks to enhance system flexibility. We also know that computer commands are nothing more than transmitting data for computation. But we still don't know how the computer controls the execution of each command.
CPU Internal Control
Like the PC system, the CPU is also an organic whole, which is divided into many components to complete the CPU function. The Address Buffer Mar and data buffer Mar connected to the external bus. The internal function components include the generator ALU, which is related to the generator ACC, the instruction counter PC, and the instruction register IR. Similar to the data interaction between external CPU commands and PC interfaces, In the CPU, micro commands are used to control the data flow between the CPU and the external bus. We can build a simple model for the CPU, such.
MRD and Mar are connected to external buses to cache bus data and send addresses to the bus respectively. PC is the address where the program counter is used to store the next instruction. IR is the instruction register used to store the addresses retrieved from the memory. AC is a accumulators connected to the external bus and serves as an operand and Operation Result of the ALU generator. CU is a controller that sends a series of control signals based on the operating code in the instruction in IR and the clock signal. Now let's take a look at how the CPU extracts commands from the memory for execution.
1. the control signal C (0) is valid. Open the PC and send it to mar's control door. The address in the PC reaches Mar.
2. the control signal C (1) is valid. Open the output gate sent by Mar to the address bus.
3. Send a reading signal to the primary storage through the control bus.
4. the control signal C (2) is valid. Open the data bus and send it to the input gate of the MCM.
5, C (3) valid, open the control door between the MCM and IR, so far, the command is sent to the IR
6. C (4) is effective. Open the command operation code and send it to the Cu output gate. The Cu generates various control signals for the command under the control of the operation code and clock.
7. Add 1 to the PC content.
Instruction Decoding
It is really easy. The CPU only needs to execute commands for each command, remember its time sequence control sequence, and know that when each command is being executed, each clock cycle should send a specific control signal to connect two components so that data can be transferred from one component to another or interact with the bus. Obviously, the execution of each command sends some constant control signals. Each Command corresponds to a series of switch actions, and each switch action is called a micro operation, in addition, we can also write these micro operations in the firmware. As long as the firmware is upgraded, We can modify or upgrade the commands.
The CPU model in does not take into account the CPU's internal BUS, And the CPU's internal components are directly connected together. We can also improve this model and use the internal BUS to connect all components together, then set the switch for each component to access the bus, so that we can also control the data from one component to another through the control signal, as shown in the figure.
With this superb design, computers can run intelligently. At the same time, we can see that computers are actually a common automatic control system. It is only because of the clever design that he looks so intelligent and incredible.