Tour of Computer Systems
CPU
CPU - the engine that interprets and executes instructions
the “brain” of the computer
Responsible for applications running on the computer, and for maintaining system operations (ex. reading from / writing to memory, switching between processes, etc.)
The CPUs in your personal computers are likely executing billions of instructions per second
The CPU operates according to a fetch-and-execute cycles, also referred to as the instruction cycle:
1. Fetch instructions from memory
2. Interpret those instructions
3. Execute those instructions
Program Counter (PC)
Program Counter - word-sized register
Keeps track of the next memory address that the processor needs to load for the fetch stage of the fetch and execute cycle
Once an instruction is fetched, the program counter updates to the address of the next instruction. This could be a simple increment, or something more complex (ex. branching / jumping)
The Program Counter has a reset vector - the default memory address it points to when you boot the machine
For most CPUs, this is hardwired into the machine. Configurable boot options may allow you to change the reset vector, whereas others may be static.
Then, depending on what occurs in the machine (e.g. which programs you run), the Program Counter jumps to the appropriate memory address and works from there
Register File
Register File - a set of registers contained in the CPU
Registers - temporary storage locations that the CPU can access while performing its operations
Because these registers are located directly in the CPU, they are much faster to access than any other type of memory
Will contain both general purpose registers (GPRs) and special purpose registers (SPRs)
GPRs hold operands (i.e. data values, intermediate results, etc.) for use during computation
SPRs have more specific purposes, such as pointing to memory addresses or holding instructions. The Program Counter is an SPR, as is the Instruction Register that holds the CPU’s current instruction
Arithmetic/Logic Unit (ALU)
ALU - performs mathematical and logical calculations
This is where arithmetic operations occur
Logical operations (and/or) and value comparisons also occur here (==, <, >, etc.)
Generally speaking, this is where “computing” in computers is done
The ALU receives two values (i.e. operands) and an operation to perform (e.g. addition, subtraction, etc.)
The operands are obtained from registers within the CPU, and the operation is sent as a control signal determined by the most recently-decoded instruction
The ALU is a combinational circuit; it has no internal memory (finish notes here)
The actual operations within the ALU are performed using logic gates, which are the building blocks of digital circuits
Logic gates are made from transistors - switches that control the flow of electrical currents to produce a desired outcome
These gates make up the foundation of binary manipulation: AND, OR, NOT, XOR, etc.
Bus Interface
Connects the CPU to the system bus
System Bus - carries information between the processor and other parts of the computer, such as memory and input/output devices
The bus can be divided into the address bus, the data bus, and the control bus
Address Bus - carries the address of the data that the CPU will be reading from or writing to
Data Bus - Carries the data value that is being transferred between components
Control Bus - carries the command that is being performed
fetch, decode, and execute phase goes here
Main Memory
Main memory - where the computer stores data while the machine is running
Any time you run a program, that program’s code is loaded into main memory so it can then be accessed by the CPU
Any active data (e.g. changes to text files / word documents, unsaved game progress, etc.) is stored in the computer’s main memory
Main memory is temporary and volatile
It does not retain data permanently; once a program terminates or the machine is shut down, anything stored in main memory will disappear
Similarly, if the program or machine crashes, or if the power is removed, anything stored in main memory will disappear
Main memory largely consists of random-access-memory (RAM)
The phrase random access refers to the fact that any memory address in RAM can be accessed instantly, without traversal
Consequently, the access time for all RAM data is the same. Program speed will not vary based on the location of data in RAM
Main memory is organized as a linear array of bytes, each with its own memory address
So, if the CPU needs to access data in main memory, it uses the address of that data’s storage location (sent on the address bus).
The data is then sent from main memory along the data bus, to be processed in the CPU.
One might ask the question: “If we have registers directly in the CPU, why do we need main memory?”
Registers are significantly more expensive to produce, and they take up space directly on the CPU.
Registers require more power and generate more heat than main memory
Modern processors tend to have 16 and 32 GPRs, with each GPR’s size determined by the architecture
In contrast, most modern personal computers wil have 8-64 GB of RAM in main memory, and some may have 1 TB or more
Conseqeutnly:
CPU: 16 GPRs * 32 bits = 512 bits; 512/8 = 64 bytes
Main memory: 8 GB = 8,589,934,592 bytes
Memory Bus
Simply the part of the system bus that connects to the main memory
in most architectures, the memory bus is just a part of the broader system bus, which also connects with other components such as I/O devices
In special cases (e.g. high performance computing), the memory bus might connect directly and only to the CPU, to reduce latency.
DIsk Memory
Disk memory - refers to storage devices that retain data indefinitely
Disk memory is permanent and non-volatile; it survives even after the machine is powered off.
The term “disk” comes from early storage devices that tused magnetized rotating disks to hold binary data
IN modern ocomputing, the term disk mgiht reger to any of the following:
HDDS - data stored on spinning magnetic plates
SSDs - uses trapped electrical charges
Virtual Hard Disk (VHDs) - Software defined storage used in virtual machines and cloud computing.
Removeable Stroage - Devices such as USBs, SD cards, etc. that can be used to transfer data between devices.
Just as main memory is slower and cheaper than CPU registers, disk storage is slower and cheaper than main memory.
Disk storage is optimized for large amounts of cheap, permanent storage, at the cost of slower access time.
Modern computers might have between 256GB and 4TBs of disk storage
Disk Controller
Manages communication betwen disk storage and other parts of hte computer system, chiefly main memory
When a request is made to read/write from disk memoo