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:
a <= b and c;: Synthesizable. Forms a physical combinational AND gate.wait for 4 ns;: Not Synthesizable. Physical silicon has no inherent concept of arbitrary nanosecond pauses. Delays belong only in simulation testbenches.c <= not c after 1 ns;: Not Synthesizable. Theafter 1 nsconstruct cannot be synthesized into static logic.signal g : signed(5 downto 0) := to_signed(-12, 6);: Synthesizable. Initializes 6 physical registers with the two's complement value of -12 (110100) during FPGA bitstream configuration.TH : entity work.module port map (...);: Synthesizable. Instantiates a modular hardware component and wires its inputs and outputs.
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
- RISC (Reduced Instruction Set Computer): Small set of fundamental, fixed-length instructions. Strict load/store architecture (only LOAD and STORE access memory; computations occur solely in registers). Programs require more lines of assembly, but pipelining is straightforward.
- CISC (Complex Instruction Set Computer): Large instruction set featuring complex, variable-length instructions. Operations can directly read from and write to memory (e.g.
ADD [mem], reg). Programs require fewer assembly instructions, but decoding hardware is more complex.
Function Calls & The Call Stack
During a function call in C, the processor coordinates three essential registers:
- Program Counter (PC): Holds the memory address of the next instruction to fetch and execute.
- Stack Pointer (SP): Points to the top of the stack in memory (stacks typically grow downwards towards lower memory addresses).
- Frame Pointer (FP): Points to the fixed base of the current function's stack frame, providing a stable reference for local variables.
Interactive Call Stack Visualiser
Step through a C function execution: int mul(int a, int b) { int c = a * b; return c; }
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
- Set bits (make 1): Use bitwise OR:
*reg |= (1 << bit); - Clear bits (make 0): Use bitwise AND with inverted mask:
*reg &= ~(1 << bit); - Toggle bits (switch 0 to 1, or 1 to 0): Use bitwise XOR:
*reg ^= (1 << bit); - Read bits: Mask with bitwise AND:
int state = (*reg >> bit) & 1;
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.
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):
- Execution Time (T_exec): Total time required to complete the scheduled tasks.
- Maximum Sample Rate (f_max):
f_max = 1 / T_exec(assuming non-pipelined execution). - Resource Utilisation:
Utilisation (%) = (Total Task Work / (Number of Cores * T_exec)) * 100
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:
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?
- Hardware Abstraction: Standardised Device Drivers hide register-level complexities from application software.
- Preemptive Multitasking: A scheduling kernel interrupts low-priority tasks to run time-critical tasks via hardware timer interrupts.
- Memory Protection: The Memory Management Unit (MMU) isolates process memory to prevent crashes from affecting the entire system.
System Boot Process
- Stage 0 (Power-on Reset): CPU executes initial boot ROM code burned onto the silicon.
- Stage 1 Bootloader: Loads minimal configuration, sets up RAM clocks.
- Stage 2 Bootloader (e.g. U-Boot, UEFI): Loads the operating system kernel image into system memory.
- Kernel Initialization: Configures drivers, page tables, interrupts, and memory spaces.
- 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.
1 0 0 1Feedback Bit (Bit 3 XOR Bit 0): 1 XOR 1 = 0
Sequence History: 1001