1. Introduction

Software defines the instructions that a computer should run. We’re going to see how these instructions are copied from the disk to memory and then finally processed by the CPU.

This discussion will focus on the classical computer. Quantum computers are outside the scope of this discussion. They’re based on entirely different physical properties from those of their classical counterparts.

In this tutorial, we’ll see how software and hardware components communicate.

2. Basics

Let’s look at some basic electronics.

2.1. Bits

By now, we must already be aware that a bit represents a 1 or 0 at the logical level. However, at the physical level, a bit represents the electrical charge that’s being carried or stored in some electronic component.

2.2. Integrated Circuits

Integrated circuits were the key to the modern PC. Without them, we most probably wouldn’t be able to have computers as small as the ones we do.

An integrated circuit is an electrical circuit containing components such as resistors, capacitors, transistors, and diodes on a thin silicon sheet.

A modern CPU is an integrated circuit that contains billions of such microscopic components. Therefore, when we talk about CPU components such as the ALU or control unit, these are actually sub-circuits in it.

3. Running a Program

Let’s now see how the software we write translates into some physical action.

3.1. Machine Code

After writing some code, we need to compile it. Compiling means converting high-level instructions into machine code. Machine code is binary data that the CPU understands:

This data can only run for the specific CPU architecture we compiled for. The architecture (e.g. ×86 or ARM) has a particular instruction set that defines the acceptable instructions and their corresponding operands. The instruction set resides on the control unit.

3.2. Memory

After reading a program from the disk, the system loads it into memory. At this stage, we refer to it as a process.

A process requires some system resources in order to run. It needs to store its instructions somewhere (RAM) and then execute them somewhere (CPU or GPU). We’ll focus on the CPU for the rest of this discussion:

At the physical level, RAM is a matrix of storage cells that can store a binary charge. Therefore, reading or writing data in these cells equates to accessing a memory address.

Modern RAM cells are based on capacitors. A capacitor is an electronic component that stores a charge. In RAM, the presence of a charge in a capacitor signifies a binary digit of 1, while its absence, or discharge, represents a binary digit of 0.

These storage cells require a constant electrical charge to retain their data. This is why RAM loses data when we switch off the computer.

3.3. CPU

Let’s now look at the CPU. It gets instructions from RAM. It can get a block of these instructions and store them in high-speed memory locations within a CPU called registers.

Loading instructions into memory and then sending them to the CPU equates to “running” the program. At a physical level, this is achieved by reading data from the RAM cells and sending it to the CPU.

Buses facilitate the physical connection and communication between the CPU and memory. They allow information such as addresses, data, and control information to pass between the CPU and RAM. Buses are a set of parallel conductors (“wires”) that connect these two devices. Therefore, a 16-bit (“16 wire”) bus can carry 16 bits of information between RAM and the processor.

3.4. Fetch-Execute Cycle

The computer needs a timing mechanism to know the point at which it is being executed. We call this the clock cycle.

The clock cycle is a tick (an electric pulse) that tells the processor to fetch the next instruction in memory. This pulse acts as a timer for the CPU and other components to coordinate or synchronize their operations.

Each clock tick corresponds to one fetch-execute cycle. This simply means that whenever the clock ticks, the CPU gets the next instruction in memory, decodes, and executes it.

The computer continuously does this fetch-execute cycle until the program ends – that is until the last instruction is executed – or it shuts down.

4. Conclusion

In this tutorial, we’ve seen how software interacts with physical components such as RAM, the CPU, and even embedded devices or peripherals. We have done this by describing the physical equivalent of common operations such as reading from memory or performing a computation.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments