Main Components of CPU

In this week’s classes, we learned mainly about the main components of CPU, including primary and secondary memory, machine instruction cycle and control system. We did a lot of activities along the way of learning, and I really enjoy the process. It’s amazing to find out more about how the computer is constructed from different components and how they function together to help us solve problems.

  1. Main components of a CPU

First, we learned about the main components of CPU, which includes CU, ALU, cache and registers. CPU is the key component of a computing system, and it’s called the “brain” of computer. It contains the circuit necessary to interpret and execute program instructions. CU is the control unit of CPU, which serves the function of decoding the instructions and controlling other component inside the CPU. More specifically, CU handles the loading of new commands and is responsible to decode them. It controls the data flow and operation of the ALU, telling ALU how the data should be processed and provides ALU with the data.

Image result for control unit
Control Unit

The function of ALU is to do all the arithmetic and logical calculations. It’s called the “core” of the CPU because this is the part that actually does all the calculations. Dual core technology means the computer has two ALU and can perform calculations simultaneously. Arithmetic calculations include adding, subtracting and so on. Logical calculations include to perform AND/OR and other logic gates.

Image result for ALU
ALU

Registers are very important parts in the CPU that provide small but very fast temporary storage inside the CPU. They directly connected to CU, ALU and Buses inside the CPU. There are mainly five types of registers, including PC (program counter), MAR (memory address register), MDR (memory data register), CIR (current instruction register), A register (accumulator). PC is an incrementing counter that holds the memory address of the next instruction. MAR stores the address in main memory that is currently being read or written. MDR is a two-way register that holds data fetched from memory (and ready for the CPU to process) or data waiting to be stored in memory. CIR stores the instruction that has just been fetched from memory which is currently decoded by the CU. Accumulator (A register) holds the immediate result of the ALU.

Picture1.png
Registers

The CPU block diagram is the simple version of CPU, including CU, ALU, MAR and MDR. The bus between MAR and RAM is the address bus and the bus between MDR and RAM is the data bus. Buses inside the CPU are used to connect different parts of CPU and transfer data between them.

Picture2
CPU Block Diagram
  1. Primary and secondary memory

Beside these components we mentioned earlier, there’s also storage unit related to CPU, including RAM, ROM and cache. We can see in this diagram that the storage part is related to the processing stage.

Image result for input process output storage
Input, Process, Output, Storage

There are two types of memory inside the computer, including primary memory and secondary memory. Primary memory includes register, cache, RAM, ROM and virtual memory. Primary memory is the memory that can directly accessed by the CPU. Every data need to be executed by the CPU need to first store in RAM. RAM (random access memory) can store data and instructions, but it’s a volatile memory, meaning it is a temporary storage and the data will be lost if power is turned off. ROM (read only memory), on the other hand, is a static and non-volatile memory, which means the data won’t be lost if the power is off. ROM also stores BIOS, which is used to tell computer what to do to find the operating system and boot the computer when it restarted.

Image result for primary memory
Primary Memory

Cache is a type of small, high-speed memory inside the CPU used to hold frequently used data, so that CPU doesn’t need to access RAM frequently. Cache is a SRAM (Static RAM), which is much faster than Dynamic RAM. L1 cache is usually inside the CPU, and it’s the fastest and smallest cache. L2 and L3 cache is bigger than L1 cache, but they are usually built between CPU and RAM, so they are slower than L1 cache. CPU will automatically search the cache first before it searches the RAM. If CPU finds the data it needs in the cache, it’s called cache hit. Cache miss is when CPU failed to find the data in cache. When CPU finds the data in RAM, it will first store it inside cache then send it back to CPU. Cache is smaller and faster than RAM.

Image result for cache
Cache

Virtual memory uses secondary memory to extend the capacity of primary memory. It let CPU “think” that there’s still enough space in primary memory. In fact, it segregates some part of the secondary memory and used it for primary memory if the primary memory is nearly full.

Image result for virtual memory
Virtual Memory

Secondary memory includes HDDs (hard disk drive), SSDs (solid state drive), flash, CD and DVD. The biggest difference between secondary memory and primary memory is that secondary memory is non-volatile memory. It means that it’s persistent memory and won’t lose when the power is off. Secondary memory is slower but has larger capacity than primary memory. Persistent memory is important because primary memory can cause data loss when the power is off. Persistent memory is able to store some repeatedly used basic information.

Image result for secondary memory
Secondary Memory
  1. Machine Instruction Cycle

Machine instruction cycle is how the computer works to execute one instruction. It includes four steps: fetch, decode, execute, store. Fetch is to fetch instruction from primary memory to control unit. Decode is to interpreted instruction in control unit, then the ALU executes the instruction. Then, the result is stored in the primary memory and CPU checks for the next instruction. If we see it from register’s perspective, the cycle works like this: PC sends the address of the next instruction to MAR, and then MAR fetches the instruction from RAM and stores it in MDR, and then the instruction is sent to CIR and processed by CU, and then the ALU does the calculation and the result stores in Accumulator. Then the data is sent back to MDR and then stores in RAM. From PC to CIR is the fetch phase, and CU is the decode phase, ALU is the execute phase and accumulator is the store phase. One cycle is called one clock cycle for CPU, and this is measured in CPU speed (MHz/GHz). A technique called pipelining allows overlap of operations to improve performance. It’s like when the ALU is executing, CU is already decoding the next instruction.

Image result for machine instruction cycle
Machine Instruction Cycle

We also did the activity from Little Man Computer to visualize the fetch-decode-execute cycle. We use assembly language for the LMC, a language that uses mnemonic codes to represent machine-language instructions. Assembler is used to translate assembly language into machine language.

A+B+C
A+B+C
(A+B)+(B+C)
(A+B)+(B+C)
The largest of three numbers
The Largest of Three Numbers
  1. Control System

We have learned about the basic concept of control system. The sensor is the input of the control system. There are multiple types of sensors, including sound, motion, vibration, optical/image, pressure, temperature, proximity and so on. All these serve the function of sensing different real-life signals.

Properties of sensors include accuracy, range and resolution. Accuracy is to determine how accurate the sensors can measure. Range is the acceptable range that allows the sensor to work normally. For example, a temperature sensor can only work between 30ºC to 60ºC. Resolution is the smallest increment the sensors can measure. For example, some sensors can measure 17.12cm while others might only measure 17.1cm. There are also some characteristics of sensors. The sensors should be insensitive to any other physical conditions present that could influence the reading and the sensors should not influence the measured property in any way. For example, the temperature sensor should not be influenced by wind or the temperature of its own.

Image result for temperature sensor
Temperature Sensor

Processor is the middle part of the control system. This is where algorithm works and the reason why we can “control”. There are three types of processors, including general purpose processors, microcontrollers, and graphics processing unit (GPU). General purpose processors are capable of dealing with all kinds of different programs and are usually used in larger system, for example the CPU. Microcontroller is smaller and more specific compare to general purpose processors. It may include one main elements of a larger system, like RAM or ROM. They perform specific functions. GPU is faster in graphics related calculations and are usually responsible for calculating pictures on the screen.

Image result for processor
Processor

Microprocessors have lots of advantage compare with human when come to control a system. It can calculate faster than human so it can react to changes more quickly. Also, it will seldom make errors and they don’t need time to rest. It can also operate in dangerous situations like deep under the sea. But they may not react fast enough when facing unexpected difficulties and they won’t function well if they are out of power.

One important features of closed loop control system is that the output can influence the input, and this can be called the feedback of control system. This can allow the control system to adapt according to the environment or other factors. While the control system is performing other tasks, the signal that needs immediate action is sent. This signal is called interrupt. The system needs to attend to the interrupt immediately. For example, when you need to use task manager to close a stuck program, you need to send the interrupt signal.

Image result for closed loop feedback
Feedback

In conclusion, we learned a lot in this week’s class, including primary and secondary memory, machine instruction cycle and control system. We also have some interesting videos to watch and some activities like programming on the Little Man Computer and so on. What I really love is the programming part. It made me realize that there are numerous ways to reach the same result. Even we perform a single calculation like multiplication, there’s still many ways to do so. Our task is more like to find the most efficient one. Just like in real life, we have lots of ways to get the same result, like we can choose to spend 30 minutes or an hour on the same task. It’s just a matter of efficiency and quality, and we always aim for the most efficient and the best quality one.

Leave a comment