[CS] Computer Architecture

William Parker·2022년 11월 20일

CS

목록 보기
1/1
post-thumbnail

How the central processing unit (CPU) works

The CPU is the most important part of a computer. Corresponds to the 'human brain'

It is largely composed of three parts: operation unit, control unit, and register.

Calculator

Performs arithmetic and logical operations (hence the term arithmetic-logic unit)

Data required for operation is fetched from registers, and operation results are sent back to registers.

Controller

A device that controls the execution of instructions in order

Decodes program commands from the main memory device, and sends control signals to the memory device, arithmetic device, and input/output device according to the result.

It also receives the signals sent by these devices to decide what action to take next.

Register

high-speed memory

Temporarily stores instruction addresses, codes, data required for operation, operation results, etc.

Divided into general-purpose registers and special-purpose registers according to usage

Depending on the type of CPU, the number and size of available registers vary.

General purpose register: Temporarily stores data required for operation or operation result
Special-Purpose Registers: Registers used for special purposes.

Important special purpose registers

MAR (Memory Address Register): Stores the main memory address to perform read and write operations.

PC (Program Counter): stores the address of the instruction to be executed next

IR (Instruction Register): Stores the currently executing instruction

MBR (Memory Buffer Register): Temporarily stores data read from main memory or data to be saved.

AC (accumulator): temporary storage of operation results

CPU operating process

The main memory reads the data received from the input device or the program stored in the auxiliary memory.

The CPU reads and processes program instructions and data stored in the main memory to execute the program, and stores the result back in the main memory.

The main memory stores the processing result in secondary memory or sends it to the output device.

The control device controls each device so that commands are executed in order in steps 1 to 3.

What is an Instruction Set?

set of instructions to be executed by the CPU

Composed of Operation Code + Operand
Operation code: the operation to be executed
Operand: Required data or storage location

Operation code has operation, control, data transmission, and input/output functions.

Operands store addresses, numbers/letters, logical data, etc.

To execute the program, the CPU sequentially fetches instructions from the main memory, decodes them, and repeats the process of executing them.

The series of activities required for the CPU to fetch and execute one instruction at a time from main memory is called an 'instruction cycle'.

The instruction cycle is divided into fetch/execute/indirect/interrupt cycles.

One instruction is fetched from the designated address in main memory and the instruction is executed in the execution cycle. When one instruction finishes executing, the fetch cycle for the next instruction begins.

Instruction processing process by fetch cycle and execution cycle

The most important part of the fetch cycle is the PC (Program Counter) value increment.

Transfer the address stored in PC to MAR

Based on the stored contents, the instruction is fetched from the corresponding address in the main memory.

Store fetched instructions in MBR

Increment the PC value to fetch the next instruction

The contents stored in the memory buffer register (MBR) are transferred to the instruction register (IR).

T0 : MAR ← PC
T1 : MBR ← M[MAR], PC ← PC+1
T2 : IR ← MBR

Here's the process until withdrawal.

The process of executing instructions after fetching.

ADD addr instruction operation.

T0 : MAR ← IR(Addr)
T1 : MBR ← M[MAR]
T2 : AC ← AC + MBR

There is no need to increase the PC because the withdrawal is already in progress and only the command needs to be executed.

This means that the value of MBR is already stored in IR.

So, all you have to do is add MBR to AC.

profile
Developer who does not give up and keeps on going.

0개의 댓글