What is a CPU and What Does it Do?

A central processing unit, or CPU, is the core of any computer or embedded system. Often compared to a calculator, it is responsible for calculating and processing information that allows the system to perform a specific function or task.

CPUs are used within almost all electronic devices we use daily, from cell phones, to smart watches, to home gadgets such as thermostats.

In this blog, we’ll discuss the CPU in more detail and provide insight into how it operates in a computer system.

What is the Purpose of a CPU?

The CPU is a hardware component that is found in the circuit board or motherboard of a computer or embedded device. While small in size, it holds great computing power due to its millions to billions of built-in transistors. A transistor is a binary switch that prevents or allows current to flow through, thereby conveying ones or zeros that translate into performing an action. Transistors are essentially what allows the CPU to make its calculations.

Intel CPU on motherboard Photo by Francesco Vantini on Unsplash

In essence, a CPU acts as the “brain” of the device, taking input from peripheral devices or a program, and processes and executes instructions as a result. The CPU then either outputs information or performs the peripheral’s requested task.

This computing process uses an instruction set that is categorized into three main stages: fetch, decode, and execute. A CPU fetches the instruction from the memory such as the RAM, decodes the instruction, and then executes the instruction using relevant parts of the CPU. We’ll provide more specifics on this later.

Components of a CPU

The major components that make up the CPU include:

  • Control Unit (CU) - directs all the processor’s operations.
  • Arithmetic Logic Unit (ALU) - performs mathematical, logical, and decision operations.
  • Memory Unit - stores all the data and the instructions required for processing.

Control Unit

The Control Unit handles all processor control signals where it is used to control the transfer of data and instructions among other units in the system. The CU manages and coordinates all the units of the computer, letting the logic unit, memory unit, as well as both input and output devices know how to respond to instructions received from a program.

Arithmetic Logic Unit

The Arithmetic Logic Unit is used to perform the arithmetic and logic operations of the CPU. The ALU uses operands and code that tell it which operations to perform for input data. Once the information is processed, it is sent to the memory. Two subcomponents of the ALU include the arithmetic section and the logic section:

  • The arithmetic section of the ALU is to perform arithmetic operations like addition, subtraction, multiplication, and division.
  • The logic section of the ALU is to perform logic operations such as comparing, selecting, matching, and merging of data.

Memory Unit

The Memory Unit, also known as an internal storage unit, main memory, primary storage, or Random Access Memory (RAM), is used to store instructions, data, and intermediate processing results. The unit sends this data to other units as needed to perform a function. The memory unit is also where all inputs and outputs are routed, and also saves the final processed data results before it’s sent to an output device.

CPU components diagram

Instruction Cycle of a CPU

The CPU uses a hard-coded “instruction set” in order to understand what it is capable of performing. The instruction set allows the CPU to execute specific operations, which can include adding two numbers together, jumping to a different part of the program, or comparing two values.

When a program sends a command to the CPU, it uses these instructions to execute the command in a series of steps known as the instruction cycle. The instruction cycle is the time required by the CPU to execute one single program instruction.

These steps include:

  • Fetch: The CPU fetches the command from the computer's RAM (random access memory).
  • Decode: The CPU calculates what's needed to make the command happen.
  • Execute: The CPU executes the actions needed to complete the command.

Fetching

The CPU initiates and executes the program instructions. As instructions come in, a register in the CPU referred to as the Program Counter (PC) stores the memory address of the instruction that should be processed next. Upon processing the instruction, the CPU copies the instruction’s memory address and stores the copied data to another register on the CPU called the Instruction Register (IR).

Decoding

Once the memory of the instruction is available, the instruction gets decoded. During this stage, the Control Unit decodes and defines the exact instructions that are stored in the IR, and as they are decoded, they are turned into a series of control signals that are used to execute the instruction.

Executing

The instruction is now ready to be performed. The control signals are sent to the ALU to be processed and completed where it performs the specified operation.

CPUs Used in Embedded Systems Today

CPUs have been used within computers and embedded systems for decades. Over time, they have evolved to become much more powerful, as well as smaller in size, which has allowed CPUs to be designed into much more compact devices.

Devices today are also increasingly incorporating the use of multi-core processors to help enhance performance while decreasing power consumption. A multi-core processor is a computer processor on a single integrated circuit with two or more separate processing units. Back during the original conception of a computer, most CPUs had a single processing core. Today, CPUs can consist of multiple cores, such as two, four, six, or more, which allow it perform multiple instructions at once.

CPUs can be found in almost all aspects of our lives, and as technology improves, we can expect even further improvements in the capabilities of these units.

How to Test and Develop Embedded Systems

Total Phase provides embedded systems engineers with host adapters and protocol analyzers to help with debugging and development of I2C, SPI, CAN, USB, and eSPI systems.

Host Adapters

Our I2C or SPI host adapters specifically can emulate master or slave devices to validate responses and communication occurring on the bus. As a master device, it can evaluate peripherals such as sensors and memory chips, and can also be used to emulate a slave device to test commands sent from microcontroller units or CPUs.

The Aardvark I2C/SPI Host Adapter is a general-purpose host adapter that can emulate an I2C or SPI master or slave device. It can signal up to 800 kHz as an I2C master, up to 8 MHz as an SPI master, and up to 4 MHz as an SPI slave. It allows users to perform multiple applications including prototyping and production testing.

The Cheetah SPI Host Adapter is a fast and powerful USB-to-SPI host adapter, capable of communicating at up to 40+ MHz. It is an ideal tool to develop, debug, and program SPI applications, helping users focus on core competencies by minimizing debugging and programming time.

The Promira Serial Platform is an FPGA-based platform that supports a variety of different protocols, speeds, and functionalities through downloadable applications. It is able to emulate an I2C or SPI master or slave device, and can signal up to 80 MHz as an SPI master, up to 20 MHz as an SPI slave, and up to 3.4 MHz as an I2C master or slave. It offers advanced features and capabilities that allow it to be a fitting device for a number of different applications, whether it be prototyping or Flash programming memory devices.

Protocol Analyzers

Our I2C/SPI protocol analyzer is a helpful tool to monitor bus data in real time. This allows engineers to capture data and analyze it to ensure all communication between devices is correct and contains no errors.

The Beagle I2C/SPI Protocol Analyzer can non-intrusively monitor I2C traffic up to 4 MHz and SPI up to 24 MHz.

To learn more about how our tools can assist with developing your own embedded system, please contact us at sales@totalphase.com.