Salta al contenuto
Note per Studenti Computer Architecture Report

Computer Architecture

In questa pagina 9

This note describes how a computer is organized: the von Neumann model, the CPU and its instruction cycle, the types of memory and their units, the bus, input/output devices and the motherboard of a PC. It builds on the idea of program from Introduction to Computer ScienceComputer science is about problems, algorithms and computation, not about machines; the Turing machine fixed what is computable, complexity classes say what is feasible, a program is a sequence of simple operations and decisions, and an algorithm is a finite, executable method that always terminates (examples: doubling an investment, Sieve of Eratosthenes, divide and conquer, plus the Traveling Salesman and Halting problems).Introduction to Computer Science →; how programs are expressed for the CPU is in Programming FundamentalsThe CPU only executes machine instructions (opcodes) of its own instruction set; assembly languages give them mnemonic names and an assembler translates them one-to-one, but they are CPU specific; high-level languages are CPU independent and are translated by a compiler (executable code is CPU specific) or run by an interpreter; compiled languages are generally more efficient, interpreted languages more portable, and Java aims at both.Programming Fundamentals →, and how information is encoded in bits in Representation of InformationEverything in a computer is a sequence of bits, so each kind of information needs a coding. Natural numbers use positional notation in base 2 (conversion by repeated division by 2); signed integers use two's complement (range from minus 2 to the n minus 1 up to 2 to the n minus 1, minus 1), where negation is invert-all-bits-and-add-1, sums are plain binary sums and overflow is detected on the two top carries; hexadecimal groups bits in fours; fractions use fixed point or IEEE 754 floating point (sign, exponent in excess 127, 23-bit fraction) and are only approximate; characters are unsigned integers in a code table (ASCII, Unicode); images, video and sound are stored as numbers too (pixels, frame differences, samples).Representation of Information →.

1. Von Neumann's model

  • In 1945-46 John von Neumann developed a theoretical model of the architecture of a computer that is still valid and widely used (the EDVAC, Electronic Discrete Variable Automatic Computer).
  • The first document describing an electronic machine in whose memory both data and program are stored is von Neumann's First Draft of a Report on the EDVAC (Moore School of Electrical Engineering, University of Pennsylvania, June 30, 1945).
  • The architecture of modern computers is very similar to that document, so they are called von Neumann machines (stored-program computera machine whose memory holds both the data and the program instructions). The most notable exceptions are some parallel processing machines.
  • The model is important because it represents different situations in a homogeneous way.

Original model. Blocks:

Block Meaning
CPU Central Processing Unit, made of CA (Central Arithmetic) and CC (Central Control)
M central memory
I input devices
O output devices
R auxiliary memory

Modified model (the version used in the course): a bus with three groups of lines (control, address, data) connects one or more CPUs, the central (primary) memory, the input/output interfaces PP(I/O) and the auxiliary (mass) memory, e.g. a disk.

2. Central processing unit (CPU)

The CPU is responsible for processing data:

  • it locates and executes program instructions;
  • it performs arithmetic and logical processing with its logical-arithmetic unit;
  • it acquires data from primary and mass memory and from other input/output devices, and sends them back after processing.

Physically it is a chip (microprocessor). A chip, or integrated circuitan electronic component with external metal connectors (pins) and internal connections (wires), made mainly of silicon and housed in a plastic or ceramic package, has very complex internal connections: for example the AMD Instinct MI355X (2025) has more than 185 billion interconnected transistors.

Moore's law (graph on the slide): the number of transistors on microchips doubles about every two years, from a few thousand in the 1970s to tens of billions.

Parts of the CPU

Part Function
ALU (logical-arithmetic unit) performs arithmetic and logical operations
Control unit governs the operation
Registers a limited set of fast-access memory cells for temporary data storage
Cache special memory, small but very fast

Clock

CPU operation is cyclical, and the period of the cycle is synchronized by the system clock, which produces a periodic signal.

  • The clock frequency is one of the most important technical characteristics of the CPU, measured in cycles per second, i.e. Hz (Hertz). Example: 3 GHz = 3×1093\times 10^9 = 3 billion cycles per second.
  • Frequency and period: freq=1/τ\text{freq} = 1/\tau where τ\tau is the period. A periodic signal satisfies f(t)=f(t+τ)f(t) = f(t+\tau).

Instruction cycle (fetch-decode-execute)

The CPU operating cycle has three steps:

  1. Access (fetch): the instruction to execute is loaded from primary memory and stored in the Instruction Register; the value of the Program Counter register is increased.
  2. Decode: the instruction is decoded (selection of the devoted circuits).
  3. Execute: the instruction is executed.

The position in primary memory of the instruction to load during the access phase is held in a special register, the program counter (PC). It is increased by one unit at each cycle at the end of the access phase, so that instructions are executed in sequence (jump instructions modify the PC, see Programming FundamentalsThe CPU only executes machine instructions (opcodes) of its own instruction set; assembly languages give them mnemonic names and an assembler translates them one-to-one, but they are CPU specific; high-level languages are CPU independent and are translated by a compiler (executable code is CPU specific) or run by an interpreter; compiled languages are generally more efficient, interpreted languages more portable, and Java aims at both.Programming Fundamentals →).

Flow chart of the cycle: start -> PC takes the address of the first instruction (entry point) -> if not end: fetch and PC increment, decode, execute, and repeat; if end: stop.

On a chip photograph the slide marks the areas of instruction fetch (access), instruction decode, and the integer execution units (execute, integer arithmetic).

3. Memory

Memory stores both data and programs inside the computer. It is divided into cells (memory locations) arranged in sequence. Each cell contains a predefined number of bits, usually eight.

  • bit: an elementary data item that can take two values, conventionally zero and one;
  • byte (B): a set of eight bits, the unit of measurement of memory capacity. Example: 512 MB = 512×106512 \times 10^6 bytes.

The word "bit" has three meanings depending on the context:

Meaning Description Example
unit of information the basic unit used to measure information (discussed in more advanced courses)
binary digit a digit in base 2, value 0 or 1 a 32-bit binary integer has 32 binary digits
storage device a bi-stable device able to store one symbol of a binary alphabet a 12-bit register can store 12 bits

Units

System Prefixes
International System (SI) k (kilo) = 10310^3, M (Mega) = 10610^6, G (Giga) = 10910^9
IEC/ISO (binary prefixes) ki (kibi) = 2102^{10} = 1024, Mi (Mebi) = 2202^{20} = 1 048 576, Gi (Gibi) = 2302^{30} = 1 073 741 824

So 1 GB = 10910^9 bytes while 1 GiB = 2302^{30} bytes. The byte is usually the minimum unit of memory that can be accessed individually. (The slide also shows the Ubuntu command free -h, which reports memory in Gi/Mi.)

Address of a memory cell

Each cell is associated with a progressive integer starting from zero, called its address. A primary memory structured in bytes is a list of 8-bit cells with addresses 0, 1, 2, ...

There are two types of memory: primary and secondary (mass).

4. Central (primary) memory

Central memory is fast but expensive. It consists of memory chips made with the same (silicon) technology as the CPU, in two kinds: ROM and RAM.

"Random access" means the time to access a location does not depend on its position in memory. The slide notes that RAM should really be called read-and-write memory, because even ROM is random access: what distinguishes them is the ability to write.

ROM (read-only memory)

  • Retains data and programs even when the computer is turned off: it is retentive (non-volatile).
  • It is written only once, directly at manufacture (firmwareprograms stored permanently in ROM at manufacture distribution).
  • It contains the programs needed to start the computer, which must always be available. On PCs they are called UEFI (Unified Extensible Firmware Interface) or BIOS (Basic Input/Output System).
  • The ROM category also includes: PROM (programmable ROM, programmable with a special device), EPROM (erasable PROM, erased with ultraviolet rays), EEPROM (electrical EPROM, multiple writes).

RAM (random access memory)

  • Allows reading and writing of the data and programs it contains: it holds data being processed and programs that must be immediately available for execution.
  • It loses data when the computer is turned off: it is non-retentive (volatile).
  • Intermediate devices between RAM and ROM exist, such as non-volatile flash memories, which can be rewritten a limited number of times (for example 100,000).

RAM vs ROM

Aspect RAM ROM
Full form Random Access Memory Read Only Memory
Definition temporarily stores data and instructions the CPU is currently using stores data or instructions permanently or semi-permanently
Nature temporary memory permanent or semi-permanent
Volatility volatile (data lost when power is off) non-volatile (data retained without power)
Speed fast relatively slow
Use store data temporarily while programs run firmware, boot instructions and essential system data
Data change can be read and written can only be read (not easily changed)
Examples DDR4 RAM, DDR5 RAM BIOS ROM, EEPROM, flash ROM

5. Secondary (mass) memory

  • Non-volatile medium, less expensive per memory unit than primary memory (about a hundred times: 0.04 Euro/GByte against 7 Euro/GByte) and slower.
  • Programs and data reside in secondary memory, are loaded into RAM when needed, and are updated again when needed.
  • It is usually a hard disk; recently it can be a solid state memory (SSD).
  • Access times: about ns for RAM, about 10 ms for a hard disk, about 100 microseconds for an SSD.
  • A hard disk is made of rotating platters coated with magnetic material, with read/write heads. Current size: many hundreds of GB up to TB (Tera, 101210^{12} bytes). The slides show standard (longitudinal) and perpendicular magnetic recording.

Other kinds of secondary memory:

Technology Examples and properties
Magnetic tape very high capacity, very cheap, but very slow: access is sequential rather than random (you must wind or unwind the tape instead of moving a head over a disk surface)
Solid state SSD, based on rewritable semiconductor (flash) memories; USB pen drive, flash memory with a USB interface
Optical CD-ROM (read by a laser, read-only, high capacity of 750 Mbyte, very cheap and reliable, used to distribute programs and information); CD-R (can be written by the user once, several times if CD-RW); DVD (high capacity, Gbyte); Blue-Ray (very high capacity, many Gbytes)

Write-once optical disks cannot be physically altered (immutability).

6. Hierarchy of computer memory

From top to bottom the pyramid goes from small, fast and expensive memory to large, slow and cheap memory (size grows going down, speed grows going up):

Level Size Persistence Speed (approximate times on the slide)
Processor registers bytes power on, immediate term very fast, very expensive, about 1 ns
Processor cache KB/MB power on, immediate term very fast, very expensive, about 10 ns
Random access memory (primary) GB power on, very short term fast, affordable, about 100 ns
Flash / USB memory (secondary) SSD, GB power off, short term slower, cheap, about microseconds
Hard drives (secondary) TB power off, mid term slow, very cheap, about 10 ms
Tape backup (tertiary) PB/EB power off, long term very slow, affordable, about 100 ms

7. Bus

The bus consists of three distinct components:

  • data bus: data travel to and from the CPU on it;
  • address bus: carries memory addresses;
  • control signal bus: carries control signals.

Address and control buses carry memory addresses and control signals that usually come from the CPU. The CPU, memory, and input/output devices are all connected to this system bus.

8. Input/output devices

Devices on the slide: keyboard, mouse, scanner, joystick (input); microphone, printer, speaker, monitor. An important input and output device is the network connection, which lets the computer exchange data with remote systems. The connection can be direct (at high speed), through a local network, or remote (at lower speed) through a telephone line and a modem; it can also be made via radio (wireless).

9. A look into the personal computer

A PC has a basic architecture similar to that of high-performance computers, but differs significantly in scale and performance. In the block diagram a set of bus lines connects the CPU, the memory, the ports (to which printer, mouse/trackpad, keyboard, microphone and video camera are attached), the disk controller (with secondary storage) and the network controller (to the Internet); the monitor and speakers are also output devices.

Motherboard

Inside the PC is the motherboard, which holds the CPU, primary memory, the bus and expansion slots for controlling peripherals. The CPU, the central memory (RAM and ROM) and the electronic circuits controlling the hard disk and other peripherals are interconnected by a set of electrical lines forming the bus. Data travel along the bus from memory and peripherals to the CPU and vice versa.

The annotated motherboard photograph shows, among others: CPU socket, CPU fan and heatsink mount, DIMM memory slots, BIOS flash chip, southbridge, CMOS backup battery, PCI and PCI Express slots, SATA and IDE connectors, 24-pin ATX power connector, integrated graphics processor, and connectors for integrated peripherals (keyboard and mouse, serial and parallel port, VGA, USB, Ethernet, audio).

Versione ripasso

Von Neumann model. Data and programs share the same memory: a stored-program computera machine whose memory holds both the data and the program instructions. Blocks: CPU, central memory, input and output devices, auxiliary memory, connected by a bus with three groups of lines: control, address, data.

CPU. Executes instructions, performs arithmetic and logic, moves data between memory and devices. Parts: ALU (arithmetic and logic), control unit, registers (few, fast), cache (small, very fast). A integrated circuitan electronic component with external metal connectors (pins) and internal connections (wires), made mainly of silicon and housed in a plastic or ceramic package is the physical chip.

Clock. Sets the cycle period τ\tau; frequency freq=1/τ\text{freq} = 1/\tau (3 GHz = 3×1093\times 10^9 cycles per second). Moore's law: transistor count doubles about every two years.

Instruction cycle (fetch, decode, execute).

  1. Fetch: load the instruction from memory into the Instruction Register, increase the program counter (PC).
  2. Decode: select the circuits for the instruction.
  3. Execute: run the instruction.

Jumps change the PC, so instructions normally run in sequence.

Memory.

  • Bit = 0 or 1; byte = 8 bits; memory is an array of byte cells with addresses 0, 1, 2, ...
  • SI prefixes use powers of 10 (10310^3, 10610^6, 10910^9); binary prefixes use powers of 2 (2102^{10}, 2202^{20}, 2302^{30}). So 1 GB is 10910^9 bytes, 1 GiB is 2302^{30} bytes.
  • Primary memory: RAM (read and write, volatile) and ROM (non-volatile; holds the start-up code, UEFI or BIOS; PROM, EPROM, EEPROM are variants). Both are random access: the access time does not depend on the position.
  • Secondary memory: non-volatile, cheaper per unit and slower. Hard disk (about 10 ms), SSD (about 100 microseconds), magnetic tape (sequential access, very slow), optical discs.

Hierarchy (fast and small at the top, large and cheap at the bottom): registers (about 1 ns), cache (about 10 ns), RAM (about 100 ns), SSD, hard disk (about 10 ms), tape backup.

Bus and motherboard. Data bus carries data, address bus carries addresses, control bus carries control signals. The motherboard holds the CPU, RAM, the bus and the slots for peripherals.

Common mistakes: confusing GB with GiB; calling RAM non-volatile or ROM not random access; reading "bit" in the wrong sense (unit of information, binary digit, storage device); assuming secondary memory is as fast as RAM.

Teoria collegata