Week1_BasicComputerOrganization
Week1_BasicComputerOrganization
https://ceng240.github.io
Web–site: https://ceng240.github.io
https://pp4e-workbook.github.io
Course conduct: Course workbook: https://pp4e-
https://pp4e-workbook.github.io
workbook.github.io
Weekly 2 hour courses,
Office hours with the assistants,
Lab exams,
Midterm exam and final exam
Grading
• A total of 8 lab exams
• You can ask any questions about grading and course conduct by sending
an email to: [email protected]
Basic Computer
Organization
CENG 240
Middle East Technical University
Outline
• Components of the von Neumann Architecture
• The Memory
• The CPU
• The Fetch-Decode-Execute Cycle
• The Stored Program Concept
• Pros and Cons of the von Neumann Architecture
• Peripherals of a computer
• The running of a computer
• The startup process
• The Operating System
• Important Concepts
The von Neumann Architecture
• The von Neumann Architecture defines the basic structure used
in most computers today
• Proposed in 1945 by von Neumann
• Consists of two distinct units:
• An addressable memory
• Central Processing Unit (CPU)
The von Neumann Architecture
• All the encoded actions and data are stored together in the
memory
• The CPU queries the instructions stored in memory and
executes them one by one, sequentially.
Instruction1
Instruction2
Instruction3
…
Data1
Data2
Data3
…
The von Neumann Architecture
• The CPU communicates with the memory using three sets of
wires:
• Address bus (e.g., 8 wires)
• Data bus (e.g., 8 wires)
• R/W wire (1 wire)
• Each wire contains either 0 or 1 as information
• 0 or +5 Volts
Instruction1
Instruction2
Instruction3
…
Data1
Data2
Data3
…
The Memory
• The memory can be imagined as
locations organized as rows.
• Each row has eight locations (bits)
• A bit can store 0 or 1,
• Each row consists of 8 bits
• Called a Byte
• 1 Byte = 8 bits
• Each byte of the memory has a
unique address
Reading a byte from the Memory
• When the CPU wants to read the byte at address 8700;
• The CPU sets the address bus to the binary value of 8700,
• It sets the R/W write to 0 to indicate a read operation,
• The byte value at address 8700 is then read using the data
bus
Instruction1
Instruction2
Instruction3
…
Data1
Data2
Data3
…
Writing a byte to the Memory
• When the CPU wants to write a value (e.g., 00110011)
at address 8700:
• The CPU sets the address bus to the binary value of 8700,
• It sets the R/W write to 1 to indicate a write operation,
• It provides the value 00110011 at the data bus
• The value 00110011 is then gets written at the byte at
address 8700
Instruction1
Instruction2
Instruction3
…
Data1
Data2
Data3
…
Memory
• The information stored in the memory stays until the power
is turned off.
• The memory in computers are called RAM
• RAM: Random Access Memory
Instruction1
Instruction2
Instruction3
…
Data1
Data2
Data3
…
The Memory
• Random access means that, accessing any
address of the memory takes a constant
amount of time.
Instruction1
Instruction2
Instruction3
…
Data1
Data2
Data3
…
Arithmetic Logic Unit (ALU)
• The Arithmetic Logic Unit (ALU) performs operations such as:
• Addition
• Multiplication
• Division
• Logic (less than, greater than, equal to tests)
• Control Unit provides the data which ALU operates on (e.g.,
numbers to add, compare etc. )
Instruction1
Instruction2
Instruction3
…
Data1
Data2
Data3
…
Registers
• Registers are mainly storage units on the CPU for storing:
• The instruction being executed,
• The affected data,
• Outputs
• Temporary values
• Sizes and numbers of registers differ from CPU model to model.
• Most registers are 64 bits: a single register can store 64 bit values,
• Most CPU’s have between 10 and 20 of these registers
Instruction1
Instruction2
Instruction3
…
Data1
Data2
Data3
…
Registers
• The two special purpose registers are:
• Program counter
• Instruction Register
• Input/Output connections connect the CPU to other
components (keyboard, mouse, etc.)
Instruction1
Instruction2
Instruction3
…
Data1
Data2
Data3
…
The Fetch-Decode-Execute Cycle
• The CPU is a state machine
• A machine that has a representation of its current state
• The state of the CPU is what is stored in the registers
• Until it is powered off, it continues fetching, decoding and
executing instructions stored in the memory
• The Control Unit is responsible for functioning of this cycle.
Instruction1
Instruction1
Instruction2
Instruction2
Instruction3
Instruction3
…
…
Data1
Data2
Data3
…
The Fetch Phase
• The CPU has the address of the next instruction in the Program Counter
(PC) register
• The address bus is set to this address stored in the PC
• R/W wire is set to Read (0)
• The memory responds to this by providing the instruction stored in that
address via the data bus.
• The bytes which comprise the instruction are received into the instruction
register (IR).
Instruction1
Instruction2
Instruction3
…
Data1
Data2
Data3
…
The Decode Phase
• The content of the IR stores the instruction to be executed
• The first part of this content triggers some action
• Every CPU has an electronical circuit (instruction table) in
which every operation (e.g., addition multiplication)
corresponds to a binary code
• This is operation code is called the opcode.
• The instruction table differs from CPU brand to brand.
8 bit Instruction.
First 4 bits are the opcode, remaining 4 bits are
the data or address related to the operation
The Decode Phase
Instruction1
Instruction2
Instruction3
…
Data1
Data2
Data3
…
The Stored Program Concept
• When you open the an application on your phone (e.g., Music app), the CPU
fetches the instructions of the application and executes them,
• The instructions operate on the data (e.g., songs) stored in the memory of your
phone,
• Eventually, your phone plays the music by using the instructions of the app and
the data (songs) stored in the memory of your phone
Instruction1
Instruction2
Instruction3
…
Song1
Song2
Song3
…
The Stored Program Concept
• Below is an example of a stored program
• This is the real extract from the memory
• This program multiplies two integer numbers in two
different locations of memory
• It stores the result of multiplication in another location of
the memory
Assembler
Pros and Cons of the von Neumann
Architecture
• Advantages:
• CPU retrieves the data and instructions from the
memory using the same way.
• This simplifies the design of the CPU
When you press a key at the keyboard, the memory address at 8000 is set to the code for that key.
CPU can then read the byte value at 8000 to understand which key you pressed.
Program1
..
Program2
..
Data
Keyboard
Mouse
Printer
Peripherals of a Computer
• The CPU can either poll the address 8000 continuously to
detect your key presses,
• This is called polling.
• The CPU will check address 8000 even if you don’t press anything
on the keyboard.
• This slows down the CPU a lot.
Program1
..
Program2
..
Data
Keyboard
Mouse
Printer
Peripherals of a Computer
• Alternatively, the keyboard can send an interrupt to the CPU when you
press a key
• Using the interrupt mechanism, the keyboard somehow can tell the CPU
that a keyboard event has occurred.
• The CPU then stops its normal tasks and checks the address 8000 to see
which key the user has pressed.
Program1
..
Program2
..
Data
Keyboard
Mouse
Printer
The running of a
computer
• When you press the power button of a
computer:
• BIOS (Basic Input-Output System)
stores a special startup program, and
that program gets loaded into the
memory.
• Power-On Self Test (POST) is
performed
• CPU and RAM is checked for
errors,
• Peripherals are identified and
initialized
Examples of Operating
Windows, Linux, MAC OS
Systems:
Memory management
Process management
Device management
It is responsible for: File management
Security
User Interface
Wrap up – Concepts to remember
• The von Neumann Architecture,
• The interaction between the CPU and the memory using:
• Address bus
• Data bus
• R/W line
• The components of the CPU:
• The control unit
• Arithmetic logic unit
• Registers
• The fetch-decode-execute cycle
• The stored program concept
• Operating system and its responsibilities
Further Reading
• For the curious: check the Further reading topics at the end of Chapter 1
in the book.