Topic 2 - Computer Architecture
IB Computer Science
What is computer architecture?
- What is going on “under the hood”
- Focus on how different components work together
- CPU
- Storage
- OS
CPU (Central Processing Unit)
- “The Brain”
- Processing all instructions
- Code is executed here
- Arithmetic, logical, input/output
operations
CPU (Von Neumann Model)
ALU
ACC
Fetch-Decode-Execute Cycle (FDE Cycle)
- Process starts at the PC
- PC sends the next address to be checked to the MAR
- MAR sends address to RAM, stores result in MDR.
- MDR sends data to the CIR (Current Instruction Register) for decoding.
- CIR passes the decoded instructions on to the ALU, which does everything
that’s needed to be done.
- ALU gives address to MAR if it needs and further instructions.
Fetch-Decode-Execute Cycle (FDE Cycle)
1) PC → MAR PC = Program Counter
2) MAR → RAM MAR = Memory Address
3) RAM → MDR Register
4) MDR → CIR/CU RAM = Random Access
5) CU → ALU Memory
6) ALU → output MDR = Memory Data
Register
Fetch 1)-3)
CU = Control Unit
Decode 4)
ALU = Arithmetic Logic Unit
Execute 6)
Notes on CPU/FDE Cycle
- FDE cycle orchestrated by Control Unit (CU)
- 2 cores = 2 ALUs
- Processor Speed = # of FDE Cycles per second
- 2GHz = 2 billion cycles per second
- FDE Cycle = Machine-Instruction Cycle
Primary Memory (RAM)
- Random Access Memory
- “Short term memory”
- Address → Data
- Volatile - data lost when
computer turned off
- Non-persistent storage
Primary Memory (ROM)
- Read-only Memory
- Used to store permanent
instructions
- Instruction to boot computer
(BIOS)
- Instructions written in factory
- Keeps data without electricity
Cache
- Stores frequently used
instructions from RAM
- Processor checks cache first
- L1 (Fastest) and L2 Cache
- Cache memory more expensive
Secondary Memory
- Hard Drive
- “Long-term Memory”
- Persistent storage
- Holds all data not currently in use
- Data for running programs
transferred from secondary to
primary memory
- Slower and cheaper than primary
- Not directly connected to CPU
- Much larger amounts
Virtual Memory
- When primary memory
overloaded, data sent to
secondary
- Slower
- Temporary
- Returned to primary memory
as needed
- Stored in units called
“pages”
Operating System
Operating Systems
- “set of software that controls computer’s hardware and resources and
provides services for computer programs”
- 5 roles
- User interface
- Memory Management
- Peripheral Management
- Multitasking
- Security
User Interface
- Link between user and hardware
- 4 types of UI
- GUI (Graphical User Interface) -
menus, point and click
- CLI (Command Line Interface) - type
in commands
- NLI (Natural Language Interface) -
speak to computer (Siri)
- MBI (Menu Based Interface) - Like CLI,
but no commands, only menu option
Memory Management
- Keep track of storage devices (HDD,
Flash Drive)
- Allocate memory (RAM) to programs
- Modify memory locations
- Sort data on disk drives and RAM for
efficiency
- Organize data into folders
- Copy and delete files
Peripheral Management
- Peripherals - keyboard, mouse,
monitor, etc.
- Coordinate with BIOS (basic
input/output system)
- Use device drivers to interface with
peripherals
- Device drives translate peripheral
signal
Multitasking
- Allocates CPU cycles to
concurrent programs based on
priority and time
- Each program given a slice of
time, or a “turn” to use CPU
- Slices vary in length of time
Security
- Username and password
- User permissions
- File permissions for reading and
writing
Application Software
- Word Processors
- Spreadsheets
- Database Management System (DBMS)
(MS Access)
- Email Client (Outlook)
- Web Browser
- Computer Aided Design (CAD)
- Graphic Processing Software
(Photoshop)
Data Representation
Bits and Bytes
Binary
- Language of the CPU and modern computing
- 1, 0
- Base 2
Binary→Denary
Examples
- 11101001→233
- 10001101→141
Denary→Binary
Examples
- 168→10101000
- 83→01010011
Hexadecimal
- More efficiently represents large binary values
- Colors
- Memory addresses (esp. in assembly)
- MAC Addresses
- Base 16
Hexadecimal→Denary
Examples
- 3B → 59
- 18E → 398
Denary→Hexadecimal
Examples
- 480 → 1E0
- 232 → E8
Hexadecimal ↔ Binary
- Each hexadecimal digit represents 4 binary bits
- 111011 → 3B
- 11010110 → D6
- 92 → 10010010
How is text displayed?
- Strings are made up of
characters
- Each character is
represented by a certain
number of bytes
- Two formats: ASCII and
Unicode
ASCII
- Use 8 bits for each character
- 7 bits used for each character, 1
bit is parity bit
- 2^7 or 128 possible characters
- Lower case, capitals, numbers,
symbols, spaces, punctuation
included
Unicode
- Used to represent multiple
languages
- More bits, so more
characters can be
represented
- UTF-8 → 8 bits
UTF-16 → 16 bits
UTF-32→32 bits
How are images displayed?
- Each display (monitor, phone screen, etc.) is divided
into pixels
- pixel = “little square” in grid
- pixel = smallest controllable element in display
- Each pixel has a different color
- Each pixel has one color at one moment
- The color is combination of red, blue and green
- Pixels together display image
- 1024x764 screen resolution →1024 pixels high, 764
wide
- 1080p, HD, 4K refers to number of pixels in screen
Pixels
- Each color in each pixel represented by
6 digit hexadecimal value( Ex: 70EF5A)
- First two values represent red, second
two represent green and last two
represent blue (Ex:70EF5A)
- 16^2*16^2*16^2 = 256*256*256
possible color combinations
Logic Gates
Logic Gates
- Processors/chips made up of millions
of “switches” called logic gates
- Each logic gate takes 1-2 inputs and
1 output
- Possible inputs are 1 or 0
- 1 = high voltage, 0 = low voltage
- Voltage = “pressure that forces
charged electrons” to flow through
circuit
Examples
- X OR NOT Y
- (A XOR B) AND NOT C
- (A OR B) AND NOT(A AND C)
IB Questions
Answers
https://drive.google.com/file/d/1SzuKvNN7ybuq7jsR4C9pBF4i6xHxUiOq/view?usp=shar
ing