CPU and memory

CPU cycle

When an instruction is executed, the CPU follows the fetch, decode, execute, and store steps. The instruction is first read from memory, then interpreted, and executed. This process repeats for each instruction in the same manner, that is why it is called the CPU cycle.

Register

Memory elements in CPUs are called registers. These are small, high-speed storage units that temporarily hold data, memory addresses, and other information. Registers can be general-purpose or special-purpose, such as the program counter, instruction register, and status registers.

Memory types

There are different types of memory, two groups are volatile (forgetful) memory and non-volatile memory, which remembers data even after power is removed. Memory types differ in speed, cost and capacity.

RAM (SRAM, DRAM)

SRAM (Static RAM) is fast but expensive, DRAM (Dynamic RAM) is cheaper but slower. RAM itself is random access memory, which means that any part of it can be accessed immediately in random order.

ROM

A non-volatile memory that is used for reading only. Typically used to store firmware, subtypes are PROM, EPROM or EEPROM. Today, ROM is hardly used anywhere due to the low price of flash memory.

Flash

Its operation is based on EEPROM. When it was introduced in 1980, it meant a major advance that it was not necessary to erase all data to write new data. It is possible to read, delete, and write in blocks. The lifespan of flash is limited, so a separate control unit distributes incoming data, usually supplemented by a cache.

Data flow

Communication between the processor, memory and peripherals takes place on buses. All the information is put on the bus and other elements take off what they need. Even a simple microcontroller contains countless different bus systems, and their task depends on the architecture and the peripherals available.

What is a CPU architecture?

The architecture of a CPU defines its internal structure, instruction set, the size of data buses and registers, and the way it handles data.. The instruction set contains the list of instructions that the processor is able to execute. The architecture also determines the support for peripherals and other embedded functions. Modern Intel and AMD based computers use x86-64 (x64 for short) architecture.

ARM Cortex-M

ARM Ltd does not manufacture processors, but licenses its developments to manufacturers. Smartphones and modern Apple computers also contain ARM architecture processors. They also have a very large market share in microcontrollers, with Reneas, STMicroelectronics, Raspberry Pi, Nordic and other manufacturers using the ARM Cortex-M family. These are all 32-bit, reduced instruction set (RISC) processors.

RISC-V

Unlike the instruction set architectures (ISA) used by ARM, Intel or AMD, RISC-V is an open standard. It is a modular, open source, customizable architecture. Its popularity is growing year on year, and with increasing adoption of RISC-V processors for smart devices and servers, software support is also evolving.

ESP32

A popular product from Esppressif Systems is the ESP32 family of microcontrollers. As the name suggests, it uses 32-bit cores. Some of their products use licensed processors from the ARM-like company Tensilica, while others have RISC-V cores. Compatibility between the different models is maintained by Espressif's SDK called ESP-IDF, which can be integrated into the popular Visual Studio Code IDE.