Prerequisites

Instruction set architectures

A instruction set architecture (ISA) describes the functions of a processor. It specifies:

In this way, the ISA is a contract between chip architects and compiler designers. A microarchitecture is a hardware design that implements an ISA. Instruction sets come in two forms, reduced instruction and complex instruction sets.

Complex instruction sets

Complex instruction sets were popular until the 1980s. They had features to make assembly programming easier:

  1. Complex operations like (x86) movsb (copying a byte string in memory)
  2. ALU operands can be specified directly from memory (as opposed to load-store architecture)
  3. Complex addressing modes

They are distinguished by variable instruction lengths, smaller executables, but are very hard to pipeline.

Reduced instruction sets

Reduced instruction sets are distinguished by their set of simple operations.

Literature from the period emphasized the transition from code largely being written in hand-assembly, where complex instructions reduced development time and were easier to optimize, to high-level languages where a reduced instruction set was easier for compilers to use.1

RISC ISAs:

A comparison: the RISC must load the memory into a register before performing any operations.

CISC (M68000)RISC (ARM)
add d0, labelldr r1,=label
ldr r2,[r1]
add r2,r0,r2
str r2,[r1]

LEGv8

LEGv8 is a simplified version of the ARMv8 ISA. Its instructions are all 32 bits wide. Its registers each store 64 bits and are numbered from x0 ... x31. Representative instructions include add, ldr, str, and cbz.

LEGv8 has three instruction formats or encodings:

ARMv7 assembly

Memory-mapped I/O

LPC178x system diagram

The LPC1768 memory map is of the form

Starting address (hex)Description
0000 0000Memory (flash, ram, rom)
2000 0000I/O data
GPIO ports
4000 0000APB (UART, CAN, WDT)
AHB (ENET, USB, DMA)
6000 0000Unused
E000 0000System services (interrupt controller, system tick)

The device bus interface is provided by any I/O device connected to the microcontroller unit (MCU). It consists of five elements:

  1. Address decoder: recognizes addresses for its registers
  2. Bus logic: combinational logic that responds to bus operations
  3. Control register(s): affect device behaviour
  4. Status register(s): describe device state
  5. Data register(s): pass data to and from the processor

Polling I/O

When given a time-varying signal, we often need to sample the data at regular periods $T_0$. Polling I/O accomplishes this by polling, or checking, the device status registers until it sees that the device is ready for an operation. The steps are:

  1. Read status register
  2. Check "done" bit
  3. If not set, goto (1)
  4. Read and write to the data register
  5. Process the data
  6. Goto (1)

Interrupts

Vector table

The vector table is a table in memory of handler addresses.

  1. I/O device asserts its IRQ signal
  2. Interrupt controller (IC) looks up the handler address in the vector table
  3. IC invokes the handler
  4. Handler runs (IRQ is dropped)
  5. IC resumes the interrupted program

References

1

David A Patterson, David R. Ditzel, The Case for the Reduced Instruction Set Computer, Published 1980, https://inst.eecs.berkeley.edu/~n252/paper/RISC-patterson.pdf

2

Arm Ltd, Procedure Call Standarde for the Arm Architecture, Release 2019Q1