1. A short C program that asks about the machine beneath it
A short C puzzle keeps appearing in discussions of low-level programming. At first it looks like an interview trick, but it leads straight to the foundations of computer architecture: how physical logic gates interpret sequences of zeros and ones.
#include <stdio.h>
int main(void) {
unsigned int a = -1;
int b;
b = ~0;
if (a == b)
printf("equal\n");
else
printf("not equal\n");
return 0;
}
Two quick answers usually follow: not equal, because the types have different signedness, or equal, because both variables “contain all ones”. On a contemporary C implementation using two’s complement, the program prints equal; C23 requires that representation. The interesting part is why this happens, and why earlier language standards allowed other outcomes.
Let us take the code apart. For the bit patterns, I assume bits without padding bits; the general rule for conversion to an unsigned type works modulo the mathematical value UINT_MAX + 1.
-
The assignment
unsigned int a = -1;: the conversion is defined mathematically. Its result isUINT_MAX, regardless of how the hardware stores negative numbers. In our model:With 32 bits, the hexadecimal representation is
0xFFFFFFFF. -
The operation
b = ~0;: the literal0has typeint. Bitwise complement inverts the bits of its representation. In this model, the result contains all ones, but their interpretation as a signed number depends on the representation permitted by that version of C. -
The comparison
a == b: the usual arithmetic conversions convertbtounsigned inthere. They convert its numerical value, rather than unconditionally copying its bit pattern. The resulting values are then compared.
Three historical signed-number representations make the distinction clear:
-
Two’s complement — used by x86, Arm and RISC-V, among others. The most significant bit has a negative weight:
All ones represent . Conversion to
unsigned intproduces , so the result isequal. -
Ones’ complement — used, for example, by the 60-bit CDC 6600. Negating a number means inverting its bits:
In a 32-bit illustration,
0xFFFFFFFErepresents , while0xFFFFFFFFrepresents negative zero. In an older C implementation that supports negative zero, its numerical value is zero. Convertingbto unsigned therefore produces0, and the result isnot equal. The standard also allowed normalization to positive zero. If an implementation did not support negative zero, an operation producing that result could have undefined behavior. Comparing raw register bits does not replace the semantics of C’s==operator. -
Sign-magnitude — used, for example, by the 36-bit IBM 7090. The sign bit is separate from the magnitude:
In our 32-bit illustration,
0x80000001means , whereas all ones mean . Converting the latter value modulo produces0x80000001, which differs from0xFFFFFFFF:not equal.
The representation and conversion rules appear in C11 draft N1570, §6.2.6.2, §6.3.1.3 and §6.3.1.8, and the change to mandatory two’s complement in C23 draft N3096, §6.2.6.2. The historical machines illustrate representations; I am not attributing the output of a particular C compiler to them.
Why did two’s complement win in practice? The same adder can handle signed and unsigned addition, while subtraction can be implemented by adding the complemented operand and one. There is also only one zero. Shared hardware logic does not change the language rules: ordinary signed integer overflow remains undefined in C, while unsigned arithmetic has defined modular wraparound.
This small example shows why I enjoy looking at software through the hardware beneath it. My work has taken me from early projects in a home workshop, through assembly and low-level C/C++ on eight- and 32-bit microcontrollers, to systems combining electronics, optics and PC computation. I have encountered many of these architectures directly at register level. Here I work through that landscape, from a single processor instruction to PCIe buses and contemporary SoCs.
2. What is a CPU architecture? ISA, microarchitecture and the cost of decoding
In everyday conversation, “architecture” can mean either a processor’s instruction set — x86-64, Arm64 or RISC-V — or a particular core design such as Zen 5, Cortex-X925 or Cortex-M4. These are two distinct layers:
- ISA — Instruction Set Architecture: the contract between software and hardware. It specifies the programmer-visible registers, supported instructions, their encodings, addressing modes, interrupt behavior and memory-ordering rules.
- Microarchitecture: a particular implementation of that contract in silicon: decode width, pipeline depth, reorder buffer (ROB), ALUs and FPUs, branch prediction and caches. Two processors can implement the same ISA while having very different internal designs and purposes.
Where does the cost of variable-length decoding come from?
An instruction stored in program memory passes through the processor’s front end: it is fetched and decoded into internal control signals or, in many designs, micro-operations ().
The historical distinction between CISC (Complex Instruction Set Computer, represented by x86) and RISC (Reduced Instruction Set Computer, including Arm, RISC-V, MIPS and PowerPC) developed around the question of how much work a single instruction should describe.
In x86-64, an instruction can combine address calculation, memory access and arithmetic, as in ADD [RAX], EBX. Its encoding carries the history of a family started by the Intel 8086 in 1978. Instructions occupy 1–15 bytes: depending on the operation, they include prefixes, an opcode, ModR/M and SIB fields, an address displacement and an immediate operand. Intel’s Software Developer’s Manual, volume 2, documents the encodings.
The boundaries of x86 instructions have to be recovered from their encoding. An arbitrary fetched block cannot simply be divided into equal words and sent to independent decoders.
At 5 GHz, a core has only 200 ps per cycle to decode several instructions. Fast implementations therefore use parallel boundary detection, predecoding and buffering. Some complex instructions invoke microcode sequences. Many cores also have a micro-operation cache, allowing familiar code to bypass decoding on subsequent passes. These are microarchitectural choices; the ISA does not require such a cache.
Arm and RISC-V start from different choices:
- The foundation is load–store operation: ordinary arithmetic works on registers, while loads and stores transfer data to and from memory. Atomic extensions can combine a memory read, modification and write in one operation.
- A64 instructions are 32 bits long, as are those of the base RV32I/RV64I sets. Thumb/Thumb-2 and RISC-V with C mix 16- and 32-bit instructions, but recognize their length differently. The two least significant bits distinguish compressed and 32-bit instructions in RISC-V restricted to those lengths; Thumb checks high-order bits in the first halfword. RISC-V’s wider encoding convention also provides for longer instructions. See the RISC-V specification and Arm’s A64 guide.
Fixed length mainly simplifies finding instruction boundaries. An aligned 64-byte A64 block contains 16 instruction words at four-byte intervals. They can be distributed among parallel decoders without a chain of dependencies on preceding instruction lengths. Decoding their meaning, checking dependencies and executing them still requires substantial logic.
Simpler boundary detection can reduce switching and make a wide front end easier to design. Dynamic power is approximately:
where is switching activity, the effective switched capacitance, voltage and frequency. Lower capacitance reduces dynamic power when the other quantities stay unchanged. This approximation does not include every source of power consumption, such as leakage.
Total processor energy also depends on caches, branch prediction, out-of-order execution, manufacturing process, voltage and workload. A small Cortex-M and a large Arm server core can differ more than similarly sized cores with different ISAs. Instruction length alone does not establish a whole-chip energy advantage. For that comparison, I need measurements of the same work under specified power conditions.
In practice — predicting the output and timing the code
Will the same C program print the same value on both machines? Will it run equally fast? The C conversion rules settle the first question in this example. For the second, inspect the instructions the compiler emitted and time them on each core.
3. Von Neumann, Harvard and modified Harvard: separating code from data
In my earlier article on memory physics and LLM inference hardware, I looked at the memory wall from the perspective of large AI models. In CPU and microcontroller design, the distinction between von Neumann and Harvard asks a more basic question: do instructions and data occupy the same memory and travel over the same wires?
Classical von Neumann: one memory, one bus
In the classical model associated with the 1945 First Draft of a Report on the EDVAC, instructions and data share memory, an address space and an access path.
This is flexible: an operating system can load a program from storage into RAM as bytes, then transfer execution to its address. The shared path also introduces the von Neumann bottleneck: while it is carrying a data access, it cannot simultaneously carry a new instruction fetch.
Harvard in microcontrollers: why separate Flash and SRAM?
The documentation for classic eight-bit Microchip PIC16 and AVR devices, such as the ATmega328P, describes Harvard organization with separate program and data spaces. Some instructions provide controlled crossings between those spaces. Non-volatile program Flash and volatile data SRAM are physically distinct blocks connected to the core by separate paths.
Those paths do not even have to carry words of the same width. This is immediately visible in assembly:
- The mid-range PIC16F628A has eight-bit SRAM data and 14-bit instruction words. A bit-oriented instruction fits its opcode, register address and bit index into one word, fetched in a single access while the data path carries an eight-bit byte. Other PIC cores use different widths: baseline cores have 12-bit words and PIC18 has 16-bit words. That is why I check the actual core documentation; the PIC12/PIC16 product prefix alone does not tell me its organization.
- Classic AVR has an eight-bit data path and program Flash organized as 16-bit words. Most instructions occupy 16 bits, but some — including
JMP/CALLand full-widthLDS/STS— occupy 32. On an ATmega328P, ordinary loads such asLDandLDSaddress the data space containing registers, I/O and SRAM. Using an ordinary data pointer to read a table placed in Flash therefore accesses the wrong address space. Reading a program byte requiresLPM(Load Program Memory), using the 16-bitZpointer. With the usual AVR-GCC/avr-libc tools, this meansPROGMEMand functions such aspgm_read_byte(). Some newer AVRs also map Flash into data space; I check the exact device family and compiler.
Why use this separation in a microcontroller?
- Fast startup and execute in place (XIP): instructions can be fetched directly from non-volatile Flash without first loading a system from disk. Startup still depends on reset, oscillator settling, bootloader and configuration. XIP is a property of the memory path, not an exclusive feature of Harvard organization.
- Separate paths and pipelining: fetching the next instruction can overlap a data access. This makes a short loop easier to analyze. Wait states, branches and arbitration still matter in the actual device.
- Controlled program access: an ordinary data-space write does not overwrite program Flash. Many MCUs can nevertheless program their own Flash through a dedicated controller or instruction. Separate buses limit one class of mistakes, but do not replace memory protection or control-flow integrity.
Modified Harvard: shared addresses, separate paths near the core
Contemporary x86-64 and Arm application processors, together with cores such as Cortex-M3/M4/M7, combine aspects of the two models:
- A shared address space: software sees a unified map. Cortex-M has a 32-bit, 4 GB map; x86-64/Arm64 implementations normally use fewer than all 64 address bits. On many STM32 devices, for example, Flash starts at
0x08000000, SRAM at0x20000000and peripherals at0x40000000. Aconst uint8_t*can read a table in Flash without a special instruction like AVR’sLPM. - Separate paths close to the core: many application processors have L1I and L1D caches that join a shared hierarchy further out. Cortex-M3/M4 expose I-Code, D-Code and System interfaces. Cortex-M7 has a different organization involving AXI, caches and ITCM/DTCM ports. TCM provides short, predictable access with the right configuration. Cortex-M0/M0+ have a simpler, shared instruction/data interface; one bus diagram cannot describe every Cortex-M.
4. The architectures in my workshop: PIC16, AVR, Arm, x86-64 and RISC-V
When you work across these levels — from individual assembly instructions controlling an eight-bit chip’s pins to multithreaded system software — each architecture develops a recognizable character. It follows directly from the decisions made by its designers.
1. Learning on eight bits: Microchip PIC16 and Atmel AVR
I find eight-bit devices a good place to learn hardware because the registers and execution costs are visible without an operating system in between.
In the classic PIC16F628A, nearly every arithmetic operation goes through the W working register. An instruction cycle takes four oscillator cycles: at 20 MHz, the maximum rate for simple instructions is five million per second. RAM is divided into small banks selected through STATUS, while the hardware return-address stack has eight levels and is separate from SRAM. Assembly programming makes those limits tangible, and larger algorithms need careful bank management.
Against that background, AVR, developed in the 1990s at Atmel’s Norwegian operation with Alf-Egil Bogen and Vegard Wollan, offered a different working model. It provided 32 eight-bit general-purpose registers (R0–R31) directly connected to the ALU. The last three pairs — R27:R26, R29:R28 and R31:R30, high byte first — form the 16-bit X, Y and Z pointers. Most instructions execute in one clock cycle, giving an upper limit of 16 MIPS for such instructions at 16 MHz; the stack resides in SRAM. AVRs became widespread among electronics enthusiasts, from ATtiny to ATmega. In 2016 Microchip acquired Atmel, bringing the once-competing PIC and AVR families under one manufacturer.
2. Arm is not one processor: Cortex-M, Cortex-R and Cortex-A
“Arm architecture” often groups together very different designs. Since Armv7, Arm has distinguished three profiles. They followed classic designs such as ARM7TDMI, ARM9 and ARM11, where many embedded developers learned to switch between 32-bit ARM and 16-bit Thumb state using BX.
-
Cortex-M — Microcontroller, including M0, M0+, M3, M4, M7, M33, M55 and M85: designed for embedded control and low power. These cores execute Thumb-family instructions, with the supported 16-/32-bit subset depending on the core.
A central feature is the NVIC — Nested Vectored Interrupt Controller. Cortex-M hardware saves a basic exception frame containing
R0–R3,R12,LR,PCandxPSR, allowing handlers to be written in C. The baseline M3/M4 entry latency is 12 cycles. If another exception is pending when a handler finishes, tail-chaining skips restoring and saving the same frame, reducing the transition to six cycles. Both figures assume zero-wait-state memory, no access contention and no blocking higher-priority exception. In a design, I check those conditions against the Cortex-M4 Technical Reference Manual, §3.9.Cortex-M has no MMU for virtual-memory translation and paging, so it does not run a conventional MMU-based Linux system; no-MMU variants are a separate case. An optional MPU can protect regions for an RTOS such as FreeRTOS or Zephyr. DSP instructions, an FPU and MVE vector support depend on the core and the chip vendor’s configuration.
-
Cortex-R — Real-Time, including R4, R5, R52 and R82: intended for predictable response, for example in control and storage. Selected implementations provide TCM, ECC and dual-core lockstep, with two cores running the same code and comparison logic detecting divergence. A core may support a particular functional-safety design, but certification and worst-case response concern the complete system. There are major differences within the family: Cortex-R82 has an MMU and can run Linux alongside real-time uses.
-
Cortex-A, Cortex-X and Neoverse — Application: cores for systems with MMUs, virtual memory, TLBs and caches. High-performance designs execute out of order; smaller cores such as Cortex-A53 are in-order. NEON, SVE and SVE2 availability depends on the architecture version and core. The A profile includes 32- and 64-bit architectures used by Linux, Android and Windows on Arm. Apple M, Qualcomm Snapdragon X and NVIDIA Grace implement Arm architectures; that does not automatically make their cores Cortex-A products. This spans phones, single-board computers, laptops and servers.
3. x86 and x86-64: single-thread performance and an established ecosystem
x86-64, introduced by AMD as an extension of Intel’s 32-bit x86, built its position around PC software continuity and aggressive implementations aimed at high clock rates and single-thread performance.
Inside modern Intel Core/Xeon or AMD Ryzen/EPYC designs, the decoder feeds a back end operating on micro-operations. Hundreds of physical registers are hidden behind architectural registers through register renaming, alongside large reorder buffers and multiple execution ports. SIMD includes AVX2 (256-bit) and, on supporting processors, AVX-512 (512-bit); availability and actual execution width depend on the model. x86-64 remains a natural fit where existing PC software, drivers, substantial PCIe connectivity or strong single-thread performance are priorities.
4. RISC-V: modularity and an open specification
RISC-V began at UC Berkeley in 2010 through the work of Krste Asanović, David Patterson, Andrew Waterman and Yunsup Lee. Unlike the dominant proprietary x86 and Arm licensing ecosystems, the RISC-V ISA specification is open and royalty-free.
Its engineering appeal is modularity:
- A core starts with a compact integer base such as
RV32IorRV64I, containing only a few dozen instructions. - Standard extensions add capabilities: M for integer multiplication/division, A for atomics, F/D for single-/double-precision floating point, C for compressed instructions and V for vectors. In
RV64GC, G meansIMAFDplusZicsrandZifencei; C adds compressed instructions. A user ISA name alone does not guarantee Linux support: privilege modes, memory facilities, interrupts, firmware and platform support also matter. The RISC-V naming rules define the abbreviations. - Reserved opcode space supports custom instructions. An ASIC or FPGA core can add operations for cryptography, DSP or matrix processing, accessed through inline assembly or intrinsics. Having GCC or LLVM select those instructions automatically requires toolchain support; compatibility with the base ISA does not provide that by itself.
5. Choosing an architecture — and where I think the market is going
The useful comparison separates architectural properties from the requirements of a particular project:
| Family | Data and instruction encoding | Memory organization | What I check when choosing |
|---|---|---|---|
| PIC16F628A / ATmega328P | Eight-bit data; 14-bit / 16- or 32-bit instructions | Separate program/data spaces; no MMU | Timers, supply range, memory, power and cost |
| Cortex-M / RISC-V MCUs | Usually 32-bit data; 16-/32-bit instructions depending on ISA | Map, ports, caches, TCM and protection depend on core and SoC | Interrupt latency, DMA, peripherals and tools |
| Cortex-R | 32- and 64-bit variants | TCM, caches, MPU; MMU on selected cores | Worst-case execution, ECC, lockstep and system safety requirements |
| Arm A-profile | A32/T32 or A64 depending on version; A64 instructions are 32-bit | MMU, usually separate L1I/L1D, external DRAM | Performance, energy efficiency, I/O and software support |
| x86-64 | 64-bit data; instructions of 1–15 bytes | MMU, L1I/L1D and further cache levels | Binary compatibility, SIMD, performance, expansion and PCIe lanes |
My view of the market’s direction
My expectation is that Arm will gain further ground in personal computers, laptops and servers, while Cortex-M and RISC-V will increasingly share new microcontroller designs.
Three developments inform that view:
- Power and SoC integration: placing CPUs, GPUs, accelerators and controllers close together can reduce data-movement costs. A large shared memory pool helps local AI and image processing. x86 designs can use this approach too; the actual silicon, package and memory design matter.
- A broad range of capable implementations: Apple M, AWS Graviton, Ampere, NVIDIA Grace, RTX Spark and DGX Spark show how far Arm extends beyond phones. Performance and energy still need to be compared for a particular chip and workload; they do not follow from the ISA logo.
- A more mature ecosystem: much of the open software stack has
aarch64releases. Binary dependencies, SIMD code, drivers and libraries still need checking. On Windows desktops, binary translation helps older applications run, although it does not remove every limitation.
I also expect RISC-V to grow in new MCUs: an open ISA lets vendors design their own cores or choose IP suppliers. Portable C, C++ or Rust logic makes migration easier. Platform-specific startup, interrupts, atomics, register maps, DMA and debugging usually require real work. Even two MCUs containing the same Cortex-M core need not have compatible peripherals.
6. Software compatibility, binary translation and NVIDIA RTX Spark
If we can write the same C++, Rust or Python source, why does a change of CPU architecture matter so much for existing applications and games?
A compiler producing a native executable — a Windows .exe or a Linux ELF file, for example — emits instructions for a particular ISA and follows an ABI (Application Binary Interface) covering calling conventions, data layout and interaction with the operating system and libraries. An x86-64 executable does not run directly on Arm for three main reasons:
- Different instructions and registers: the bytes encoding
MOV RAX, [RBX+RCX*4]do not mean the same thing to an Arm decoder, and may be invalid instructions. Base x86-64 has 16 general-purpose registers, includingRAX,RSPandR8–R15, and 16 or 32 vector registers depending on the extension. AArch64 has 31 general-purpose registers (X0–X30) and 32 vector registers (V0–V31). - Architecture-specific SIMD: games, codecs and engineering software may contain hand-written assembly or intrinsics for SSE2, AVX, AVX2 or FMA.
- Different memory-ordering rules: for ordinary write-back memory, x86 gives stronger ordering guarantees than Arm. This still falls short of full sequential consistency: a store buffer can allow a load from another address before an earlier store becomes globally visible. Arm provides mechanisms including
DMBbarriers and acquire/release operations such asLDARandSTLR. A translator must preserve the guest code’s semantics. At the C/C++ level, correct multithreaded code needs atomics or synchronization regardless of ISA; a data race does not become valid because it appeared to work on one x86 machine.
Interpreters and binary translators: Prism, Rosetta 2, Box64 and FEX-Emu
To run an x86-64 binary on Arm without its source, software must translate its instructions. Several techniques contribute:
- Interpretation: software reads guest instructions and implements their effects on the host. This straightforward model is useful for compatibility and diagnostics; its overhead depends on the interpreter and workload.
- Dynamic binary translation (DBT/JIT) and ahead-of-time translation (AOT): systems such as Microsoft Prism, Apple Rosetta 2, FEX-Emu and Box64 translate regions of machine code into host instructions and cache the result. Basic blocks — straight-line sequences ending in a control-flow transfer — provide a useful starting point, although implementations may work with larger regions and combine strategies.
- Register mapping: AArch64’s 31 general-purpose registers offer room for the state of base x86-64’s 16 registers. Not all are permanently available: the ABI, stack and translator need registers too, while flags and vectors need their own representation. This maps to the host’s architectural registers; its microarchitecture allocates physical registers later. Intel APX expands x86-64 to 32 GPRs, so the 16-versus-31 comparison concerns baseline code.
- Hybrid libraries: Windows ARM64EC allows native modules and emulated x64 code in one process through a compatible ABI and transitions between modules. Kernel drivers must be built natively for Arm64; application emulation does not replace them. Microsoft documents the scope of emulation and Prism.
A contemporary example: RTX Spark N1X and DGX Spark GB10
Two distinct NVIDIA platforms illustrate the subject. RTX Spark N1X targets Windows 11 PCs, while DGX Spark with GB10 is a compact AI workstation supplied with the Linux-based DGX OS environment.
For the larger RTX Spark configuration, NVIDIA lists a 20-core Grace CPU, a Blackwell RTX GPU with 6144 CUDA cores and up to 128 GB of unified LPDDR5X memory. Other configurations and power limits also exist. The DGX Spark specification separately lists 20 Arm cores — 10 Cortex-X925 and 10 Cortex-A725 — and shared LPDDR5X. Sharing the Spark name does not make every specification interchangeable.
For RTX Spark, I distinguish two execution paths:
- A native Arm64 application: CPU instructions execute directly on the Arm cores, while GPU work supported by the application runs on Blackwell. CPU and GPU share physical memory. Synchronization, memory accesses and API constraints still carry costs, but the CPU instructions do not need x86 translation.
- An x86-64 application under Prism: CPU code passes through translation and a cache of translated blocks. Supported graphics API calls reach a native Arm64 driver through the relevant libraries, and that driver submits GPU work. GPU shaders are not translated from x86 to Arm; they have a separate compilation and execution path.
Shared memory does not mean a shared instruction set. It removes some transfers associated with a discrete GPU, while CPU and GPU retain distinct jobs. The NVIDIA Windows on Arm Porting Guide describes memory sharing in more detail.
The performance implication is straightforward: CPU translation matters more when CPU work determines frame time, and less when GPU work dominates. Actual results depend on the game, translator, driver and settings. Kernel components such as anti-cheat are a separate compatibility question requiring vendor support, not simply a faster translator.
7. Memory physics: SRAM, Flash and EEPROM in an MCU; DDR4 and DDR5 in a PC
Moving between PC and embedded programming raises an obvious question: if a computer can have 32 or 64 GB of fast DDR5, why does a microcontroller often have only kilobytes of SRAM, plus separate Flash and sometimes EEPROM?
The answer starts with semiconductor physics and the construction of one memory cell.
Three microcontroller memories: SRAM, NOR Flash and EEPROM
-
SRAM — Static Random-Access Memory: a conventional 6T SRAM cell contains two cross-coupled CMOS inverters, using four transistors, and two access transistors controlled by a wordline.
- Strengths: while powered, the bistable circuit retains its state without refresh. It can provide single-cycle access with suitable timing and connectivity. Retaining data during sleep requires power to the relevant bank; current depends on capacity, voltage and temperature.
- Cost: six transistors and their connections take substantial area. SRAM capacity is therefore a compromise between silicon cost and space for stacks, variables and DMA buffers: from hundreds of bytes in small PIC16 devices, through 2 KB in ATmega328P, to hundreds of kilobytes or around a megabyte in larger STM32 devices.
-
NOR Flash — non-volatile program memory: floating-gate or charge-trap structures retain charge after power is removed, shifting the transistor’s threshold voltage .
NOR organization supports random word reads and execute in place (XIP). Erasing charge uses high electric fields and mechanisms such as Fowler–Nordheim tunneling, with an internal charge pump supplying the necessary voltage. The controller exposes erase units, usually pages or sectors — examples include 1 KB, 4 KB or 128 KB. Erase operations take far longer than reads, and repeated programming/erasing wears the dielectric. Typical embedded Flash endurance is on the order of – erase cycles, depending on the device and conditions.
-
EEPROM — Electrically Erasable Programmable Read-Only Memory: consider saving an operating-hours counter, an axis position or sensor calibration. Erasing a whole Flash sector to update four bytes is wasteful and quickly consumes its endurance.
Many AVR and PIC16 parts therefore include EEPROM. Where it is absent, an external I2C/SPI EEPROM or Flash wear-leveling can provide persistent storage. Additional selection circuitry enables finer write granularity, often one byte; the cell design and page operations depend on the technology. The ATmega328P datasheet specifies 10,000 Flash and 100,000 EEPROM write/erase cycles. Writing the same counter every minute consumes 100,000 writes in less than 70 days, so EEPROM also needs a considered write rate or wear distribution.
Why does a PC use DRAM?
Building 64 GB of working memory out of 6T SRAM would require more than three trillion transistors for the cells alone, before adding decoders and sensing circuits. The area cost would be enormous. PCs, servers and application-class single-board computers instead use DRAM, where the conventional cell is 1T1C: one access transistor and one small capacitor.
This area saving comes with physical consequences:
-
Destructive sensing: a cell capacitance of roughly 10–30 fF is much smaller than the capacitance of its bitline. Opening the access transistor shares charge with the bitline, producing only a small voltage change:
A sense amplifier detects this difference, amplifies it to a logic level and restores the cell because charge sharing disturbed its original state.
-
Leakage and refresh: stored charge leaks away. The controller schedules refreshes of groups of rows. For example, a typical DDR4 refresh window is 64 ms under specified conditions, with commands nominally spaced about 7.8 µs apart. Temperature, density, generation and refresh mode change these parameters; there is no single refresh constant for all DRAM.
-
Rows and columns: to access a different row in an already active bank, the controller precharges it (
PRE, constrained by ), activates the new row (ACT, with before a read), and selects a column (RD, followed by CAS latency, ).
This is why a PC cannot begin using DDR immediately after power-on. On a typical PC motherboard, early UEFI/BIOS firmware comes from NOR Flash, usually attached over SPI. The platform maps firmware access, while early execution may use cache or internal memory. Firmware performs memory training — calibrating timing and reference voltages — and initializes DRAM before the operating system is loaded from storage.
What do DDR, DDR2, DDR3, DDR4 and DDR5 actually change?
Names such as DDR3-1600, DDR4-3200 and DDR5-6400 can blur the distinction between pin transfer rate and the time needed to open rows in the array. More MT/s does not mean every random access becomes proportionally faster. Throughput improves through wider internal transfers, more parallelism across banks and faster I/O.
Two central mechanisms are transfers on both clock edges — DDR, Double Data Rate — and prefetch. Rather than obtaining one bit per data pin from the array for every external transfer, the internal path retrieves a group of bits and serializes them through the faster I/O interface.
In a simplified transfer model:
Here is in transfers per second and the frequencies are in hertz. is the equivalent rate of supplying data batches to the interface, not the clock for opening arbitrary DRAM rows. Timings such as , and describe different constraints. The table uses selected operating rates; SDR transfers on one edge, so its I/O clock equals .
| Generation | Prefetch | Equivalent | I/O clock | Transfer rate | DIMM data organization and |
|---|---|---|---|---|---|
| SDR SDRAM | 133 MHz | 133 MHz | 133 MT/s | bits, 3.3 V | |
| DDR | 200 MHz | 200 MHz | 400 MT/s | bits, 2.5 V | |
| DDR2 | 200 MHz | 400 MHz | 800 MT/s | bits, 1.8 V | |
| DDR3 | 200 MHz | 800 MHz | 1600 MT/s | bits, 1.5 V; 1.35 V for DDR3L | |
| DDR4 (JESD79-4) | , bank groups | 400 MHz | 1600 MHz | 3200 MT/s | bits, 1.2 V |
| DDR5 (JESD79-5) | 400 MHz | 3200 MHz | 6400 MT/s | Two independent 32-bit subchannels, 1.1 V, module PMIC, on-die ECC |
The DDR4-to-DDR5 change has a useful consequence. Many CPUs use 64-byte cache lines, although this is not a universal property of Arm processors. A typical DDR4 data channel is 64 bits, or eight bytes, wide. A BL8 burst therefore transfers bytes of data, excluding additional system-ECC bits.
A standard DDR5 module has two independent 32-bit data subchannels and a default burst length of BL16. Each subchannel can therefore deliver the same 64-byte payload:
The subchannels let the controller schedule independent requests on one DIMM module. An individual DRAM chip is part of a subchannel, not the complete module. Micron explains the subchannel layout and BL16; its DDR4/DDR5 comparison also covers 8n/16n prefetch and voltages. The module’s PMIC supplies its circuits. On-die ECC corrects errors inside a chip; protecting the chip-to-controller path requires separate system-level ECC.
In practice — counting bytes in a DDR burst
When comparing DDR modules, multiply the transfers in a burst by the width of one data path. DDR4 sends 8 × 64 bits and a single DDR5 subchannel sends 16 × 32 bits. Either burst delivers 64 bytes.
8. Buses and peripherals: PCIe and SATA versus ADC, DMA and displays
The difference between a PC, an application-class single-board computer and a microcontroller becomes particularly clear when data has to cross into the outside world.
Why are PCI Express and SATA serial?
Older PC expansion and storage buses were parallel: conventional PCI, IDE/PATA ribbon cables and the printer port. More wires seemed the obvious route to higher bandwidth. At high signaling rates, however, PCB traces encounter clock/data skew, crosstalk and signal-integrity limits. At a few gigahertz, a signal travels only a few centimeters through FR-4 during a clock period. Millimeters of length mismatch consume timing margin; they do not have to delay a bit by a whole cycle to cause sampling errors.
High-speed, point-to-point serial links address these constraints. A leading example is PCI Express:
- Differential pairs and recovered timing: one PCIe lane has two unidirectional differential pairs, TX± and RX±, providing simultaneous traffic in both directions. The receiver recovers data timing from the stream; the link can also use a reference clock, REFCLK. PCIe 1.0/2.0 uses 8b/10b encoding, while 3.0–5.0 uses 128b/130b. At 64 GT/s, PCIe 6.0 uses PAM4, FEC and FLIT mode, as described by PCI-SIG. Clock and data recovery (CDR) and lane deskew allow an x16 link to reconstruct a stream of packets from parallel serial lanes.
- Packets and DMA: memory transactions are carried in Transaction Layer Packets (TLPs). A device can initiate DMA transactions instead of asking a CPU core to copy each byte. Buffers need suitable DMA mappings; when an IOMMU is active, it provides address translation and access isolation.
A workshop example: high-bandwidth industrial cameras. In machine vision and 3D scanning, high-resolution cameras producing 10- or 12-bit raw Bayer or monochrome images at tens of frames per second can generate tens of gigabits per second across the system. Handling every small packet with an interrupt and a CPU copy would consume processing time that belongs to image analysis.
When designing that path, I follow each frame all the way from the card to the processing algorithm. The driver prepares buffers and DMA descriptors, and the acquisition card or network controller writes the image through PCIe into mapped RAM. I keep track of buffer lifetimes and device mappings; application-owned memory may need pinned pages. I batch completions or use interrupt moderation so the CPU does not have to handle every small transfer separately. I get zero-copy only when subsequent stages also work with those same data without copying the frames. If I want peer-to-peer transfers directly into GPU memory, I check device, PCIe topology and driver compatibility when selecting the hardware.
Storage followed a related path. SATA replaced wide PATA cables with separate transmit and receive differential pairs. At 6 Gb/s, 8b/10b encoding leaves a 600 MB/s ceiling before protocol overhead; practical SSD throughput is often around 550 MB/s. SATA controllers commonly expose the AHCI programming interface, while SATA NCQ supports up to 32 queued commands per device.
NVMe connects storage controllers through PCIe — commonly x4 for an M.2 SSD, through either CPU or chipset. The protocol permits up to 65,535 I/O queues, though actual controller limits are usually much smaller.
The microcontroller: a hardware acquisition chain
Typical STM32, AVR and PIC16 devices do not have the PCIe/SATA interfaces of a PC. Instead, peripherals are integrated with the core and controlled through registers, often exposed as memory-mapped I/O (MMIO).
A well-designed embedded application delegates repetitive timing and transfers to those peripherals. Two practical tasks show how this works.
1. ADC acquisition for a microcontroller oscilloscope
Suppose an STM32-based acquisition system needs to sample an analog signal at a few megasamples per second.
Starting each ADC conversion from a timer interrupt adds software-dependent timing variation: interrupt entry can be delayed by other work or a critical section. For a sinusoid of amplitude and frequency , a small timing error produces an approximate maximum voltage error:
Jitter therefore becomes particularly costly at higher signal frequencies. A hardware path removes the software scheduling component:
- A timer produces a hardware TRGO event every timer clocks. This removes software-trigger jitter; oscillator and ADC timing still have physical limits.
- A SAR ADC (Successive Approximation Register) starts directly from the selected trigger. A comparator and internal DAC resolve the input through successive decisions. Some STM32 parts support interleaving multiple ADCs to increase sampling rate.
- The ADC requests DMA after conversion. DMA reads
ADC->DRand writes each 12- or 16-bit result into the next element of a circular SRAM buffer. - The application enables half-transfer (HT) and transfer-complete (TC) notifications. While DMA fills one half, the CPU processes the completed half with DSP/FFT code and prepares the display data. A hardware DMA double-buffer mode with two addresses is a separate mechanism. Processing must finish before overwrite; the SRAM must be accessible to DMA; and Cortex-M7 designs must handle cache coherency. ST AN4031 and AN4839 describe those details.
2. Displays and local interfaces: I2C, SPI, FSMC and LTDC
The same division of work applies to communication with chips and displays on a PCB:
- I2C: SDA and SCL use open-drain signaling and pull-up resistors. A shared bus can connect sensors, an RTC, EEPROM or a small OLED display. Common operating rates include 100 kHz, 400 kHz and 1 MHz.
- SPI: SCK, MOSI, MISO and chip select provide clocked, typically push-pull communication with full duplex in conventional four-wire operation. Rates of several to tens of megahertz are common. Quad-/Octal-SPI variants transfer over four/eight data lines and can support memory-mapped external Flash; supported SDR/DDR modes depend on the controller and memory. With DMA, SPI can refresh smaller displays while leaving the CPU available.
- FSMC/FMC and LTDC: a display with its own controller and an 8080 interface can attach to FSMC/FMC, accepting commands and pixels through mapped writes. LTDC is a different path: it fetches pixels from a framebuffer and generates RGB and synchronization signals for a panel. DMA2D can prepare images through operations such as layer blending and format conversion. ST AN4861 separates these roles.
Where do Raspberry Pi and Banana Pi fit?
An Arduino Uno with AVR, an STM32 board and a Raspberry Pi may all look like small circuit boards with GPIO pins. When choosing a board, I look first at its processor and memory. Even the Raspberry Pi name covers both application computers and MCU-based Pico boards:
- Raspberry Pi 4/5 and many Banana Pi models are application computers with an Arm processor, MMU and external DRAM. Depending on the model, they offer HDMI, USB, Ethernet and PCIe connectivity, and commonly run Linux.
- ATmega328P, PIC16F628A and many STM32 devices integrate Flash and SRAM on the same chip, making short, predictable control paths easier to build. For MCUs that use external program memory, I also account for its access time in the execution budget.
If I put a task in an ordinary Linux thread, I have to account for sharing the CPU with other work and system activity. PREEMPT_RT, priorities, CPU isolation and driver selection give me ways to improve predictability; measurements of worst-case latency then show whether I meet the project’s requirements. For precise pulses, I still prefer a hardware timer, controller or separate MCU. An SBC can also delegate that part of the work to its hardware peripherals.
In a larger device, the two classes of machine can cooperate:
- An MCU — Cortex-M, RISC-V or AVR — handles hardware timers, ADC/DMA chains, PID control, hardware interlocks and precise triggering of lights or drives.
- A PC or application SBC — x86-64 or Arm — handles large image streams, 3D reconstruction, GPU computation, databases, networking and the user interface.
9. Why I care about the whole stack, from transistor to application
Once computing and electronics are viewed as one connected system, details that first look like textbook curiosities become useful engineering tools:
- The short C program with
unsigned int a = -1andb = ~0leads to two’s-complement arithmetic in the ALU, while showing why language semantics still matter. - Variable-length decoding explains some of the front-end work needed for x86 compatibility. Regular A64 or base RISC-V encoding simplifies boundary detection; whole-CPU efficiency needs a separate comparison.
- Von Neumann, Harvard and modified Harvard explain why a classic AVR uses
LPMto read constants in program Flash, while Cortex-M or x86-64 can present shared addresses and separate instruction/data paths close to the core. - The 6T SRAM cell, 1T1C DRAM cell and charge-storage transistor explain why many MCUs execute from Flash and keep variables in SRAM, while PC memory needs initialization and training. Prefetch and fast I/O account for DDR throughput without making every row operation equally fast.
- Comparing
Timer → ADC → DMA → SRAMwith PCIe camera transfers helps decide when a project needs a microcontroller, an application SBC or a workstation — and when it needs all three.
For me, moving between those layers is one of engineering’s most satisfying parts: from etching a PCB with ferric chloride and handling individual assembly registers, through C/C++, to the architecture of complete systems. Understanding the compiler, decoder, caches and buses gives me concrete hypotheses to measure when a system runs slowly or behaves unreliably.
10. Documentation and further reading
- C and integer representations: ISO/IEC 9899:2024 (C23), with the accessible C11 N1570 and C23 N3096 drafts for comparison.
- Computer architecture: Hennessy and Patterson — Computer Architecture: A Quantitative Approach and Patterson and Hennessy — Computer Organization and Design, RISC-V Edition.
- Stored-program history: John von Neumann — First Draft of a Report on the EDVAC (1945).
- Arm profiles: Arm architecture documentation, Cortex-M4 Technical Reference Manual and Joseph Yiu — The Definitive Guide to ARM Cortex-M3 and Cortex-M4 Processors.
- RISC-V: the ISA specifications, including the instruction-length convention and extension naming.
- Eight-bit MCUs: AVR Instruction Set Manual, ATmega328P, PIC16F627A/628A/648A, and PIC16 family documentation (Microchip).
- Memory: Jacob, Ng and Wang — Memory Systems: Cache, DRAM, Disk, JEDEC DDR4 and DDR5.
- PCI Express: PCI-SIG specifications and Budruk, Anderson and Shanley — PCI Express System Architecture.
- Binary translation and Arm systems: Microsoft’s Prism documentation and DGX Spark hardware documentation.
- x86 encoding and ordering: Intel SDM and Optimization Reference Manual.
- DDR5 implementation: Micron DDR5 SDRAM and DDR5 module organization.
- STM32 DMA and graphics: ST AN4031, AN4839 on cache coherency and AN4861 on LTDC.
- RTX Spark: N1X platform specifications and NVIDIA Windows on Arm Porting Guide.