Embedded Systems & Hardware Architecture

An interactive, hands-on master guide to digital hardware, processor design, real-time task scheduling, memory manipulation, and concurrency.

1. FPGAs & Digital Logic 2. CPU Architectures & The Stack 3. Memory-Mapped I/O & C Registers 4. Parallel Computing & Scheduling 5. OS Kernels & Concurrency

Module 1: FPGAs, Digital Logic & VHDL

Digital computing begins with hardware design. Microcontrollers run sequences of fixed instructions on pre-etched silicon. In contrast, Field Programmable Gate Arrays (FPGAs) are reconfigurable arrays of logic blocks, lookup tables, and flip-flops wired together on demand.

Hardware Comparison

Device Type Architecture Execution Nature Best Use Case
Microcontroller (MCU) Pre-configured processor, fixed digital logic, unified bus. Sequential instruction execution (cycles). Low power control tasks, sensing, small devices.
FPGA Configurable Logic Blocks (CLBs), Look-Up Tables (LUTs), Flip-Flops. True hardware concurrency (parallel gates). High-speed signal processing, custom hardware protocols.
System on Chip (SoC) Processing Subsystem (PS with ARM cores) + Programmable Logic (PL). Hybrid: high-level OS alongside custom hardware pipelines. Advanced robotics, vision pipelines, software-defined radio.

VHDL Synthesizability Rules

Hardware Description Languages (HDLs) do not execute sequentially like C or Python. Statements outside of a process run concurrently in physical silicon. Some statements are purely for testbenches and simulations, while others synthesize into real gates:

Finite State Machines: Moore vs Mealy

Feature Moore FSM Mealy FSM
Output Depends On Current state only. Current state AND current external inputs.
State Count Often requires more states to represent distinct outputs. Often requires fewer states.
Timing & Glitches Synchronous and glitch-free (outputs change with clock state). Outputs react instantly to input changes, but can glitch.

Interactive VHDL Synthesizability Checker

Select a VHDL code snippet to test your understanding of hardware synthesis:

Module 2: Processor Architectures & The Stack

Every central processing unit relies on structural units: the Control Unit (CU) to decode instructions, the Arithmetic Logic Unit (ALU) to execute math, and Registers for fast storage.

Memory Architecture: Von Neumann vs Harvard

Architecture Memory & Bus Structure Key Advantages Key Limitations
Von Neumann Single shared memory and bus for both instructions (code) and data. Simple wiring, flexible memory allocation. Von Neumann bottleneck: cannot fetch code and data in the exact same cycle.
Harvard Separate physical memories and separate buses for instructions and data. Simultaneous instruction fetch and data read/write. Faster throughput. More complex bus wiring and pin layout.

Instruction Sets: RISC vs CISC

Function Calls & The Call Stack

During a function call in C, the processor coordinates three essential registers:

Interactive Call Stack Visualiser

Step through a C function execution: int mul(int a, int b) { int c = a * b; return c; }

Current: main() before call
Click "Step Next" to trace the Program Counter, Stack Pointer, and Frame Pointer.

Module 3: Memory-Mapped I/O & C Registers

Embedded systems interact with timers, GPIO pins, and network controllers through Memory-Mapped Input/Output (MMIO). Hardware registers appear as regular addresses in the CPU memory space.

Address Calculation Formula

Every peripheral has a Base Address assigned by the hardware bus interconnect, while individual registers are located at fixed Offsets:

Absolute Address = Base Address + Register Offset

For example, if a timer peripheral has a base address of 0x4400 and the Control/Status Register (TCSR1) has an offset of 0xC0, its absolute address is 0x4400 + 0xC0 = 0x44C0.

Bitwise Manipulation Rules in C

Live 16-Bit Register Bitboard

Click on any bit to toggle it, or use the quick operation buttons below to observe the generated C code and hexadecimal values.

Hex: 0x0000 | Decimal: 0
volatile uint16_t *reg = (volatile uint16_t *)0x44C0;
// Click a button to generate register C code

Module 4: Parallel Computing & Task Scheduling

Real-time digital signal processing and embedded algorithms require careful execution scheduling across single or multiple processor cores.

Flynn's Taxonomy

Class Definition Real-World Example
SISD Single Instruction, Single Data. Simple 8-bit microcontroller running sequential code (e.g. gate remote receiver).
SIMD Single Instruction, Multiple Data. Graphics processing units (GPUs), vector extensions modifying pixel brightness across an image.
MISD Multiple Instruction, Single Data. Fault-tolerant redundant voting systems (e.g. triple modular redundancy in flight control computers).
MIMD Multiple Instruction, Multiple Data. Multi-core processors handling independent user web requests (e.g. streaming servers).

Precedence Graphs, Critical Paths & Utilisation

To schedule an algorithm, break it down into primitive tasks (atomic multiplications and additions), map the data flow into a Directed Acyclic Graph (DAG), and identify the critical path (the longest sequence of dependent tasks):

Interactive Multi-Core Scheduling Calculator

Calculate execution metrics for an algorithm with 9 primitive tasks (each taking 1 μs) with a critical path of 4 μs:

Total Active Work: 9 μs
Scheduled Execution Time: 4 μs
Maximum Sample Rate: 250 kHz
Resource Utilisation: 75%

Module 5: Operating Systems, Concurrency & Hardware Security

Embedded systems progress from bare-metal super-loops to Real-Time Operating Systems (RTOS) or full embedded Linux platforms to manage complex multi-tasking workloads.

Why Use an Operating System?

System Boot Process

  1. Stage 0 (Power-on Reset): CPU executes initial boot ROM code burned onto the silicon.
  2. Stage 1 Bootloader: Loads minimal configuration, sets up RAM clocks.
  3. Stage 2 Bootloader (e.g. U-Boot, UEFI): Loads the operating system kernel image into system memory.
  4. Kernel Initialization: Configures drivers, page tables, interrupts, and memory spaces.
  5. User Space: Spawns user applications and background daemons.

Concurrency: Mutexes, Race Conditions & Deadlocks

When multiple threads share variables, a race condition occurs if both threads write to memory at the same time. To secure a critical section, developers employ mutual exclusion (mutexes):

pthread_mutex_lock(&lock);
// Critical section: read and write shared data safely
shared_counter++;
pthread_mutex_unlock(&lock);

A deadlock occurs when two threads wait indefinitely for locks held by each other. Preventing circular waits and locking resources in consistent order eliminates deadlocks.

Pseudo-Random Number Generators (LFSRs)

A Linear Feedback Shift Register (LFSR) shifts bits through flip-flops while feeding back an XOR/XNOR combination of specific taps. LFSRs are deterministic: given the same initial seed, they always reproduce the identical pseudo-random sequence.

Interactive 4-Bit LFSR Simulator

Initial state: 1001. Tap polynomial: Bit 3 XOR Bit 0.

Current Register State: 1 0 0 1
Feedback Bit (Bit 3 XOR Bit 0): 1 XOR 1 = 0
Sequence History: 1001