CS 222 : Computer Organization
Lecture 1. Basic Computer
Organization
Course Objectives
⚫ The organization of a typical computing system from the high level
language, machine level and digital logic perspectives.
⚫ The high level programming language capabilities and limitations as
they relate to the computer hardware.
⚫ Understanding the reasons for using different formats to represent
numerical data.
⚫ Summarize how instructions are represented, at both the machine
and assembly levels, for a specific instruction set design.
⚫ Analyze a computer system's expected performance.
⚫ Understanding the principles of memory management.
⚫ The various forms of data representation within a computer system.
⚫ Pre-requisites: CS 221 (Logic Design).
Lectures Outline
Lecture 1- Basic Computer Organization
Lecture 2- Basic Operational Concepts
Lecture 3- Computer Performance
Lecture 4- Machine Instructions and Programs
Lecture 5- Instructions Representation
Lecture 6- Addressing Modes
Lecture 7- Basic Processing Unit
Lecture 8- The Memory System and IO Organization
Grading
⚫ Assignments 10%
⚫ Quizzes 10%
⚫ Mid-Term Exam 10%
⚫ Final Practical Exam 10%
⚫ Final Exam 60%
⚫ Participation (Extra Credit)
REFERENCE BOOKS
⚫ “Computer Organization,” by Carl Hamacher, Zvonko
Vranesic and Safwat Zaky. 6th Edition McGraw-Hill, 2005.
⚫ Computer Organization and Design: The Hardware/Software
Interface, Third Edition, by David Patterson & John Hennessy,
2005, Morgan-Kaufmann.
⚫ Structured Computer Organization, 4th Edition, Andrew S.
Tanenbaum, Prentice - Hall, 1999.
What is Computer
Organization?
⚫ What is inside a computer?
⚫ How does it execute my program?
Differences between Computer
Architecture and Computer Organization
Computer Types
According to the principles of operation three types of computers are
❑ Analog Computers
❑ Digital Computers
❑ Hybrid Computers
➢ ANALOG COMPUTER is a computing device that works on continuous
range of values
➢ DIGITAL COMPUTER operates on digital data such as numbers. It uses
binary number system in which there are only two digits 0 and 1. Each one
is called a bit.
➢ A HYBRID COMPUTER combines the desirable features of analog and
digital computers. It is mostly used for automatic operations of complicated
physical processes and machines. Analog-to-digital and digital-to-analog
converters are used for transforming the data into suitable form for either
type of computation.
Digital Computers
⚫ Based on the purpose, Digital computers can be further classified as,
❑ General Purpose Computers
❑ Special Purpose Computers
⚫ There are four different types of computers when we classify them based on their
performance and capacity. The four types are
❖ Super computers
❖ Mainframe Computers
❖ Mini Computers
❖ Micro Computers
Digital Computers
⚫ Super Computers:
✓ They are the best in terms of processing capacity and also the most expensive
ones.
✓ These computers can process billions of instructions per second.
✓ Used for applications such as stock analysis, weather forecasting scientific
simulations, (animated) graphics, fluid dynamic calculations, nuclear energy
research, electronic design, and analysis of geological data.
✓ The best known super computer manufacturer is Cray Research.
⚫ Mainframe Computers
✓ Process data at very high speeds ,
✓ Hundreds of million instructions per second
✓ Quite expensive.
✓ Used in banking, airlines and railways etc for their applications.
Digital Computers
⚫ Mini Computers
✓ Lower to mainframe computers in terms of speed and storage capacity.
✓ Less expensive than mainframe computers.
✓ Features of mainframes will not be available in mini computers.
✓ Hence, their performance also will be less than that of mainframes.
⚫ Micro Computers
✓ The invention of microprocessor (single chip CPU) gave birth to the much
cheaper micro computers. They are further classified into
❖ Desktop Computers
❖ Laptop Computers
❖ Handheld computers or Personal Digital Assistants (PDAs)
Functional Units
Arithmetic
Input and
logic
Memory
Output Control
I/O Processor
Basic functional units of a computer.
Functional Units
⚫ A computer can:
o process data, pictures, sound and graphics.
o solve highly complicated problems quickly and accurately.
o The Five Classic Components of a Computer are:
⚫ Input (mouse, keyboard, …)
⚫ Output (display, printer, …) Input
⚫ Memory
⚫ main (DRAM), cache (SRAM)
⚫ secondary (disk, CD, DVD, …)
⚫ ALU Processor Output
⚫ Control (CPU) Processor
Control
Memory
1001010010110000
0010100101010001
1111011101100110
1001010010110000
ALU 1001010010110000
1001010010110000
Input / Output Unit
▪ Input Unit
▪ Computers accept coded information through input
units, which read the data.
▪ The most well-known input device is keyboard.
▪ Output Unit
▪ Its function is to send processed result to the outside
world.
▪ Example printer.
Memory Unit
⚫ Storage device (fast access) for preserving binary data
and instructions
⚫ Organized into consecutive addressable memory words
⚫ Each is usually a standard size or fixed-length
⚫ Each memory word has a unique address for random
access
Memory Unit
⚫ Random Access ⚫ Read Only Memory
Memory (RAM) (ROM)
⚫ readable ⚫ readable
⚫ writeable ⚫ permanent
⚫ usually volatile (e.g., ⚫ nonvolatile
Dynamic RAM or ⚫ special-purpose
DRAM) storage for data and
⚫ general storage instructions
Central Processing Unit (CPU)
⚫ Manages the instruction-execution cycle
⚫ FETCH – DECODE – EXECUTE
⚫ Coordinates the activities of other devices
Inside the CPU
FETCH the instruction
1. address of the
next instruction is
transferred from
PC to MAR
2. the instruction is
located in memory
FETCH the instruction
3. instruction is
copied from
memory to MDR
DECODE the instruction
4. instruction is
transferred to
and decoded in
the IR
EXECUTE the instruction
5. control unit
sends signals
to appropriate
devices to cause
execution of the
instruction
Registers
The processor contains a number of registers used for
several purposes:
⚫ PC (Program Counter) – holds the address of the next instruction to
be fetched from memory
⚫ MAR (Memory Address Register) – holds the address of the next
instruction or data to be fetched from memory.
⚫ MDR (Memory Data Register) – hold the information (word) to be
sent to/from memory.
⚫ AC (Accumulator) – a special register which holds the data to be
manipulated by the ALU.
⚫ IR (Instruction Register) – holds the instruction to be decoded by
the Control Unit (CU).
⚫ n general purpose registers R0 to Rn-1.
Using Registers
⚫ Registers are faster
⚫ Shorter instructions
⚫ The number of registers is smaller (e.g. 32 registers need 5
bits)
⚫ Potential speedup
⚫ Minimize the frequency with which data is moved
back and forth between the memory and processor
registers
Arithmetic and Logic Unit
(ALU)
⚫ Most computer operations are executed in ALU of the
processor:
⚫ load the operands into memory
⚫ bring them to the processor
⚫ perform operation in ALU
⚫ store the result back to memory or retain in the processor
(registers).
⚫ Registers
⚫ Fast control of ALU
Control Unit
⚫ All computer operations are controlled by the control unit.
⚫ The timing signals that govern the I/O transfers are also
generated by the control unit.
⚫ Control unit is usually distributed throughout the machine
instead of standing alone.
⚫ Operations of a computer:
➢ Accept information in the form of programs and data through an input
unit and store it in the memory
➢ Fetch the information stored in the memory, under program control, into
an ALU, where the information is processed
➢ Output the processed information through an output unit
➢ Control all activities inside the machine through a control unit
Instruction Cycle
⚫ Two steps:
⚫ Fetch
⚫ Execute
Fetch Cycle
⚫ Program Counter (PC) holds address of next instruction to fetch
⚫ Processor fetches instruction from memory location pointed to by PC
⚫ Increment PC
⚫ Unless told otherwise
⚫ Instruction loaded into Instruction Register (IR)
⚫ An Instruction consists of 2 parts:
⚫ Operation code (Opcode)
⚫ The operation to be performed (e.g., ADD, I/O)
⚫ Operands (address)
Instruction Format
opcode address
⚫ The data/operands are stored in memory.
⚫ The individual instruction are brought from the memory to the
processor.
⚫ Processor interprets instruction and performs required actions
Execute Cycle
⚫ Processor - memory
⚫ Data transfer between CPU and main memory
⚫ Processor - I/O
⚫ Data transfer between CPU and I/O module
⚫ Data processing
⚫ Some arithmetic or logical operation on data
⚫ Control
⚫ Alteration of sequence of operations
⚫ e.g. jump
⚫ An instruction’s execution may involve a Combination of
above
Computer Components:
Top Level View
Example of Program Execution
⚫ Consider a machine that includes the characteristics
listed in the following figure:
Example of Program Execution
⚫ Show the execution of the program that adds the
contents of the memory word at address 940 to the
contents of the memory word at address 941 and
stores the result at address 941.
Example of Program Execution
⚫ The processor contains a single data register, called an
accumulator (AC).
⚫ Both instructions and data are 16 bits long.
⚫ The instruction format provides 4 bits for the opcode, so that
there can be as many as 24 = 16 different opcodes, and up to
212 = 4096 (4K) words of memory can be directly addressed.
Solution (1)
Solution (2)
⚫ Step 1: 1940 → IR;
⚫ Step 2: 3 → AC
⚫ Step 3: 5941 → IR;
⚫ Step 4: 3 + 2 = 5 → AC
⚫ Step 5: 2941 → IR;
⚫ Step 6: AC → 941
Solution (3)
In this example, three instruction cycles, each consisting of a fetch cycle and an execute
cycle, are needed to add the contents of location 940 to the contents of 941 as follows:
1. The PC contains 300, the address of the first instruction. This instruction (the
value 1940 in hexadecimal) is loaded into the instruction register IR and the PC is
incremented. Note that this process involves the use of a memory address register
(MAR) and a memory data register (MDR) (memory buffer register (MBR)).
2. The first 4 bits (first hexadecimal digit) in the IR indicate that the AC is to be
loaded. The remaining 12 bits (three hexadecimal digits) specify the address (940)
from which data are to be loaded.
3. The next instruction (5941) is fetched from location 301 and the PC is
incremented.
4. The old contents of the AC and the contents of location 941 are added and the
result is stored in the AC.
5. The next instruction (2941) is fetched from location 302 and the PC is
incremented.
6. The contents of the AC are stored in location 941.
Use of the MAR and MBR:
⚫ The program execution of the previous example is
described using six steps.
⚫ Expand this description to show the use of the MAR and
MBR.
Use of the MAR and MBR:
⚫ Step 1: ⚫ Step 4:
⚫ 300 → MAR ⚫ 941 → MAR
⚫ 1940 → MBR ⚫ 0002 → MBR
⚫ 1940 → IR ⚫ 0003 + 0002 = 0005 → AC
⚫ Step 2: ⚫ Step 5:
⚫ 940 → MAR ⚫ 302 → MAR
⚫ 0003 → MBR ⚫ 2941 → MBR
⚫ 0003 → AC ⚫ 2941 → IR
⚫ Step 3: ⚫ Step 6:
⚫ 301 → MAR ⚫ 941 → MAR
⚫ 5941 → MBR ⚫ 0005 → MBR
⚫ 5941 → IR ⚫ 0005 → 941
Example of Program Execution
⚫ The hypothetical machine also has two I/O instructions:
⚫ 0011 = Load AC from I/O
⚫ 0111 = Store AC to I/O
⚫ Show the execution of the following program:
⚫ Load AC from device 5.
⚫ Add contents of memory location 940.
⚫ Store AC to device 6.
Solution
⚫ Step 1: 3005 → IR;
⚫ Step 2: 3 → AC
⚫ Step 3: 5940 → IR;
⚫ Step 4: 3 + 2 = 5 → AC
⚫ Step 5: 7006 → IR;
⚫ Step 6: AC → Device 6
Types of Processor
Operations
⚫ Data Movement ⚫ Arithmetic and Logical
Operations Operations
⚫ moving data from ⚫ integer arithmetic
memory to the CPU ⚫ comparing two
⚫ moving data from quantities
memory to memory ⚫ shifting, rotating bits in
⚫ input and output a quantity
⚫ testing, comparing,
and converting bits
Types of Processor
Operations
⚫ Program Control
⚫ starting a program
⚫ halting a program
⚫ skipping to other
instructions
⚫ testing data to decide
whether to skip over
some instructions