U1-Introduction To Computer Architecture
U1-Introduction To Computer Architecture
Organisation
Course Objectives:
• to provide basic concepts of computer architecture and
Computer organization
• to impart the knowledge of implementation of arithmetic
operations in the computer.
• to develop a deeper understanding of the hardware
environment upon which all processing are carried out.
• to provide knowledge about internals of memory system,
interfacing techniques and subsystem devices.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
1
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
CSE2003- Computer Architecture and
Organisation
A student who successfully fulfills the course requirements will
be able to:
1. Identify and explain the building blocks of computer.
2. Recognize addressing modes, and data/instruction formats.
3. Perform the arithmetic operations using various algorithms and number
systems.
4. Design the single cycle data path for an instruction format for a given
architecture.
5. Compare various cache memory mapping techniques.
6. Explain memory control, direct memory access, interrupts, and memory
organization.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
2
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
CSE2003- Computer Architecture and
Organisation
Student Outcomes (SO): a, b, c
a. An ability to apply the knowledge of mathematics, science and computing
appropriate to the discipline
b. An ability to analyze a problem, identify and define the computing
requirements appropriate to its solution.
c. An ability to design, implement and evaluate a system / computer‐based
system, process, component or program to meet desired needs
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
3
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
CSE2003- Computer Architecture and
Organisation
U1- Introduction to Computer Architecture: Introduction to computer systems - Overview of
Organization and Architecture -Functional components of a computer -Registers and register files-
Interconnection of components- Organization of the von Neumann machine and Harvard architecture-
Performance of processor Introduction to ISA (Instruction Set Architecture)-Instruction formats-
Instruction types and addressing modes- Instruction execution (Phases of instruction cycle)-
Assembly language programming-Subroutine call and return mechanisms-Single cycle
U2 -
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
4
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
CSE2003- Computer Architecture and
Organisation
Text books:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc
Graw Hill, Fifth edition , 2011, ISBN: 9781259005275.
2. W. Stallings, “Computer organization and architecture: Designing for
Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
7
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Functional Units of a Computer
What does they do?
Input unit accepts Arithmetic and logic unit(ALU):
information: •Performs the desired
Memory
•Human operators, Arithmetic operations on the input
•Electromechanical devices Input information as determined
Instr1 & Logic
(keyboard) Instr2 by instructions in the memory
•Other computers Instr3
Control unit coordinates
Data1
Output unit sends Output Data2 Control various actions
results of processing: •Input,
•To a monitor display, •Output
•To a printer I/O Processor •Processing
Stores information:
•Instructions,
•Data
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
8
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Input Unit
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
9
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Memory Unit
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
10
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Memory Unit (cont.)
Processor reads/writes to and from memory based on the
memory address:
Access any word location in a short and fixed amount of time
based on the address.
Random Access Memory (RAM) provides fixed access time
independent of the location of the word.
Access time is known as “Memory Access Time”.
Memory and processor have to “communicate” with each other in
order to read/write information.
In order to reduce “communication time”, a small amount of
RAM (known as Cache) is tightly coupled with the processor.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
11
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Memory Unit: Primary Storage
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
12
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Memory Unit: Secondary Storage
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
13
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Instructions
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
14
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Instructions (cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
15
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Data
Results of the operations are stored back in the memory or retained in the
processor for immediate use.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
17
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Registers
Registers are the top of the memory hierarchy, and are the
fastest way for the system to manipulate data.
They are normally measured by the number of bits they can
hold, for example, an “8-bit register” or a “32-bit register”,
“64-bit register”, actually according to the memory word size
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
18
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Registers (cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
19
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Special Purpose Registers
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
20
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Output Unit
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
21
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Control unit
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
22
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Control unit (cont.)
Operations of Input unit, Memory, ALU and Output unit are coordinated by
Control unit.
Instructions control “what” operations take place (e.g. data transfer,
processing).
Control unit generates timing signals which determines “when” a particular
operation takes place.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
23
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Buses
Input Output Memory Processor
Bus
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
What is a Bus?
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Data Bus
Carries data
Remember that there is no difference between “data” and “instruction” at this level
Width is a key determinant of performance
8, 16, 32, 64 bit
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Address bus
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Control Bus
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Bus Interconnection Scheme
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Big and Yellow?
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Physical Realization of Bus Architecture
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Single Bus Problems
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Traditional (ISA)
(with cache)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
High Performance Bus
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Bus Types
Dedicated
Separate data & address lines
Multiplexed
Shared lines
Address valid or data valid control line
Advantage - fewer lines
Disadvantages
More complex control
Ultimate performance
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Below the Program
Applications software
Systems software
Hardware
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
37
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Below the Program (cont.)
System software
Operating system – supervising program that interfaces the user’s program
with the hardware (e.g., Linux, MacOS, Windows)
Handles basic input and output operations
Allocates storage and memory
Provides for protected sharing among multiple applications
Compiler – translate programs written in a high-level language (e.g., C, Java)
into instructions that the hardware can execute
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
38
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
From a High-Level Language to the Hardware
Language
A high-level programming language is composed of words and
algebraic notation that can be translated by a compiler into
assembly language
Assembly language symbolically represents machine instructions
An assembler translates a symbolic version of a machine
instruction into its binary version
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
39
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
From a High-Level Language to the Hardware
Language (cont.)
Machine language is the binary representation of machine
instructions
Instructions and data are just collection of binary digits (bits)
Instructions are individual commands that computers understand
and obey
Hardware executes machine instructions (extremely simple low-
level instructions)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
40
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
From a High-Level Language to the Hardware
Language (cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
42
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Instruction Set Architecture (ISA)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
46
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Interrupts
Normal execution of programs may be interrupted if some
device requires urgent servicing
To deal with the situation immediately, the normal execution of the current
program must be interrupted
Programmed
Generated by some condition that occurs as a result of an
instruction execution such as arithmetic overflow, division
by zero, attempt to execute an illegal machine instruction,
or reference outside a user’s allowed memory space
Timer (Timed)
Generated by a timer within the processor. This allows the
operating system to perform certain functions on a regular
basis
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
48
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Classes of Interrupts (cont.)
I/O
Generated by an I/O controller, to signal normal
completion of an operation or to signal a variety of
error conditions
Hardware failure
Generated by a failure such as power failure or
memory parity error
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
49
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Performance
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
50
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Performance Introduction
– The computer that performs the same amount of work in the least time is the
fastest
• The actual time the CPU spends computing a task’s lines of code
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
54
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
CPU Time
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
55
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise (1)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
56
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise (1) (cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
57
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Defining Performance
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
58
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise (2)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
59
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise (3)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
60
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise (3)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
61
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Clock Cycle
• Clock cycles indicate when events take place in the hardware
• Instead of reporting execution time in seconds, we often use
cycles
• We can count the number of CPU clock cycles for a program
• Clock rate (clock cycles per second in MHz or GHz) is inverse
of clock cycle time (clock period)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
62
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Clock Cycle vs. Clock Rate
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
64
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
CPU Clock Cycle
Total CPU clock cycles for a certain program can be calculated by looking at
various instruction classes and their individual CPIs
𝒏
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
65
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
CPU Time
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
66
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise(4)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
67
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise(4)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
68
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Memory Organizations
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
69
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Memory organization
Information is stored in the memory as a collection of bits.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
71
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Memory Words
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
72
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Memory Words … Cntd.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
73
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Memory organization
Word #0 Byte 0
Byte 1
Byte 2
Byte 3 Consider a memory organization:
16-bit memory addresses
Word #1 Byte 4 Size of the memory is ?
Bytes
16
2
Word length is 4 bytes
Number of words = Memory size(bytes) = ?
Word length(bytes)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
75
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Registers in the control path
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
76
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Basic Processor Architecture
PC R0
R1 General purpose
IR registers
Instruction that is
currently being ALU
executed R(n-1)
-
general
n purpose
registers Processor
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
77
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Basic processor architecture (cont.)
Control Data
Path Path
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
79
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Fetch/Execute cycle (cont.)
Instruction execute:
Instruction in the IR is examined (decoded) to determine which operation is to be
performed.
Fetch the operands from the memory or registers.
Execute the operation.
Store the results in the destination location.
Basic fetch/execute cycle repeats indefinitely.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
80
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Byte 0 Word #0
Byte 1
Byte 2
MAR Byte 3
Byte 4 Word #1 MDR
MAR register
contains the
address of the
memory location
addressed
A high-level language enables the programmer to use constants, local and global
variables, pointers, and arrays
When translating a high-level language program into assembly language, the
compiler must be able to implement these constructs using the facilities in the
instruction set of the computer
The different ways in which the location of an operand is specified in an
instruction are referred to as addressing modes
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
84
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Addressing Modes (cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
85
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Addressing Modes (cont.)
Immediate mode
Operand is given explicitly in the instruction.
E.g. Move R0, 200
Can be used to represent constants.
Register mode
Operand is the contents of a processor register.
Address of the register (its Name) is given in the instruction.
E.g. Clear R1 or Move R1, R2
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
86
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Addressing modes (cont.)
Absolute mode
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
87
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Addressing Modes: Indirection and Pointers
Indirect mode:
the effective address of the operand is the contents of a register
or memory location whose address appears in the instruction
E.g. Move R1, (R2): in this case R2 contains the address of the
operand to be loaded in R1
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
88
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Register Indirect Addressing Diagram
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
89
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Addressing Modes: Indexing and Arrays
Index mode
the effective address of the operand is generated by adding a constant
value to the contents of a register.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
92
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise (1)
Write a MIPS assembly code that places the sum of the four
integer variables b, c, d, and e into integer variable a, then
subtracts integer variable f from a and puts the result in
integer variable g.
C code:
a = b + c + d + e;
g = a - f;
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
93
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise (1) Sol.
Write a MIPS assembly code that places the sum of the four integer variables b, c, d, and
e into integer variable a, then subtracts integer variable f from a and puts the result in
integer variable g.
C code:
a = b + c + d + e;
g = a - f;
MIPS code:
add a, b, c # b + c → a
add a, a, d # a + d → a
add a, a, e # a + e → a
sub g, a, f # a - f → g
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
94
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
MIPS Operands
MIPS has only 32 registers (limited number!) • For MIPS, a word is 32 bits
(or 4 bytes) •
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
95
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
MIPS Registers
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
96
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise (2)
The following C statements contain the six integer variables e, f, g, h, i, j:
f = (g + h) - (i + j);
e = f;
Suppose that the compiler associates variables e, f, g, h, i, and j with
registers $s0 through $s5, respectively.
What is the compiled MIPS assembly code?
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
97
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise (2) Sol.
The following C statements contain the six integer variables e, f, g, h, i, j:
f = (g + h) - (i + j);
e = f;
Suppose that the compiler associates variables e, f, g, h, i, and j with
registers $s0 through $s5, respectively.
What is the compiled MIPS assembly code?
MIPS code:
add $t0, $s2, $s3 # $t0 is a temporary register
add $t1, $s4, $s5 # $t1 is a temporary register
sub $s1, $t0, $t1
add $s0, $s1, $zero # copy f ($s1) to e ($s0)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
98
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Data Transfer Instructions
Data transfer instructions: transfer data between memory and registers
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
100
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise (3) Sol.
Registers $s1 and $s2 of a computer contain the decimal values 1200 and 4600.
What is the effective address of the memory operand in each of the following
instructions? And explain their action.
lw $S4,20($S1)
sw $S5, 1000($S2)
For the instruction: lw $S4,20($S1)
The address is:20+1200=1220
it reads the word in the memory location 1220 and loads it in the register $s4
For the instruction: sw $S5, 1000($S2)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
102
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise (4) Sol.
Lets also assume that the base address of the integer array d is in register $s4
and a value is in register $s1
Compile the following C statement into MIPS assembly code:
d[3] = d[2] + a;
MIPS code:
lw $t0, 8($s4) # Memory [$s4 + 2*4] → $t0
add $t0, $t0, $s1 # $t0= $t0+ $t1
sw $t0, 12($s4) # $t0 → Memory [$s4 + 3*4]
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
103
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise (5)
Lets assume that the compiler has associated integer variables h and i with
registers $s2 and $s4, respectively
Lets also assume that the base address of the integer array A is in register $s3
Compile the following C statement into MIPS assembly code:
A[i] = h + A[8];
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
104
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise (5) Sol.
Lets assume that the compiler has associated integer variables h and i with
registers $s2 and $s4, respectively
Lets also assume that the base address of the integer array A is in register $s3
Compile the following C statement into MIPS assembly code:
A[i] = h + A[8];
MIPS code:
lw $t0, 32 ($s3) # Memory [$s3 + 8*4] → $t0
add $t0, $s2, $t0 # h + A[8] → $t0
add $t1, $s4, $s4 # $t1 = 2*i
add $t1, $t1, $t1 # $t1 = 4*i
add $t1, $t1, $s3 # $t1 = $s3 + 4*i (address of A[i])
sw $t0, 0 (t1) # $t0 → Memory [$t1]
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
105
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Instructions
106
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Small Constant or Immediate Operands
A faster way is to use the arithmetic instruction version in which one
operand is a constant of up to 16 bits
addi $s3, $s3, 4 # add immediate
# $s3 = $s3 + 4
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
108
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Logical (Bitwise) Instructions
NOT is implemented using a NOR with one operand being $zero for regularity
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
109
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 1
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
110
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 1 Sol.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
111
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 2
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
112
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 2 Sol.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
113
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Large Constants Handling
To handle larger constants, use the instruction load upper
immediate (lui) to set the upper 16 bits of a constant in a
register (filling the lower 16 bits with 0s), then use ori to
specify the lower 16 bits
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
114
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 3
What is the MIPS assembly code to load the following 32-bit
constant into register $s0?
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
115
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 3 Sol.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
116
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Decision Making Instructions
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
117
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Decision Making Instructions
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
118
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 4
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
119
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 4 Sol.
C Code:
if(i == j)
gotoL1;
f = g + h;
L1:f = f -i;
MIPS Code:
beq $s3, $s4, L1
add $s0, $s1, $s2
L1:sub $s0, $s0, $s3
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
120
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 5
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
121
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 5 Sol.
C Code: if(i == j)
f = g + h;
else
f = g -h;
MIPS Code:
bne $s3, $s4, Else
add $s0, $s1, $s2
j Exit
Else:sub $s0, $s1, $s2
Exit:
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
122
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Register Compare
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
123
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Compare and Branch
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
124
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Pseudoinstructions
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
125
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 6
Use MIPS instructions to implement the following pseudo-
instructions:
clear $s3 # 0 →$s3
move $s3, $s4 # $s4 →$s3
not $s3, $s4 # not($s4) →$s3
blt $s3, $s4, Less # branch on less
than
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
126
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 6 Sol.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
127
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 7
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
128
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 7 Sol.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
130
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 8 Sol.
add $s2, $zero, $zero #i=0
For: slt $t0, $s2, $s3 # test if i < n
beq $t0, $zero, Exit
sll $t1, $s2, 2 # $t1 = 4*i
add $t1, $t1, $s4 # $t1 has address of A[i]
lw $t2, 0 ($t1) # $t2 = A[i]
add $s1, $s1, $t2
addi $s2, $s2, 1 # increment i
j For
Exit:
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
131
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 1
Assuming A is an integer array with base in $s4 and that the
compiler associates the integer variables g, i, and n with the
registers $s1, $s2, and $s3, respectively
What is the compiled MIPS assembly code for the following
C code segment?
i=0;
while(i < n)
{
g = g + A[i];
i++;
}
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
132
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 1 Sol.
add $s2, $zero, $zero #i=0
while: slt $t0, $s2, $s3 # test if i < n
beq $t0, $zero, Exit
sll $t1, $s2, 2 # $t1 = 4*i
add $t1, $t1, $s4 # $t1 has address of
A[i]
lw $t2, 0 ($t1) # $t2 = A[i]
add $s1, $s1, $t2
addi $s2, $s2, 1 # increment i
j while
Exit:
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
133
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Decision Making Instructions (cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
134
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 2
Assume the six integer variables f through k correspond to the six registers $s0 through $s5
What is the compiled MIPS assembly code for the following C code segment?
switch (k)
{
case 0: f = i + j; break;
case 1: f = g + h; break;
case 2: f = g -h; break;
case 3: f = i -j; break;
}
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
135
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
switch (k)
{
Exercise 2 Sol. case 0: f = i + j; break;
case 1: f = g + h; break;
case 2: f = g -h; break;
Chain of if-else case 3: f = i -j; break;
}
beq $s5,$zero, L0 # if k=0 branch to L0
add $t0,$zero, $zero # $t0=0
addi $t0, $t0, 1 # $t0=1
beq $s5, $t0, L1 # if k=1 branch to L1
addi $t0, $t0, 1 # $t0=2
beq $s5, $t0, L2 # if k=2 branch to L2
addi $t0, $t0, 1 # $t0=3
beq $s5, $t0, L3 # if k=3 branch to L3
j Exit
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
137
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 2 Sol.
switch (k)
Jump Table {
case 0: f = i + j; break;
slt $t3,$s5, $zero # test if k < 0 case 1: f = g + h; break;
bne $t3,$zero, Exit # exit if k < 0 case 2: f = g -h; break;
slti $t3,$s5, 4 # test if k < 4 case 3: f = i -j; break;
}
beq $t3,$zero, Exit # exit if k ≥4
sll $t1,$s5, 2 # $t1 = 4*k
add $t1,$t1, $t4 # JumpTable[k] address
jr $t1 # jump register
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
140
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Instruction Formats (cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
141
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
142
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 3
Show the real MIPS machine language version for the instruction represented
symbolically as
add $t0, $s1, $s2
Registers have numbers: $t0 = 8, $s1 = 17, $s2 = 18
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
143
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 3 Sol.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
144
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 4
Show the real MIPS machine language code for the following instruction:
sll $t2, $s0, 4
Registers have numbers: $t2 = 10, $s0 = 16
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
145
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 4 Sol.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
146
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 5
Assemble the following MIPS instruction into real MIPS machine code:
lw $t0, 32 ($s3)
Registers have numbers: $t0 = 8, $s3 = 19
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
147
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 5 Sol.
lw $t0, 32 ($s3)
$t0 = 8, $s3 = 19
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
148
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 6
Show the real MIPS machine language version for the instruction
addi $s1, $s2, 4
Registers have numbers: $s1 = 17, $s2 = 18
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
149
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 6 Sol.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
150
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 7
Assuming that integer array A has its base in $t1 and that $s2 corresponds to
integer variable h, show the real MIPS machine language code for
A[300] = h + A[300];
Registers have numbers: $t0 = 8, $t1 = 9, $s2 = 18
MIPS: lw $t0,1200($s1)
add $t0,$s2,$t0
sw $t0,1200($s1)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
151
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Exercise 7 Sol.
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
152
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
The Processor
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
153
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Introduction
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
154
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Introduction (cont.)
A simple implementation that uses a single long clock cycle for every
instruction will be shown
Every instruction begins execution on one clock edge and completes
execution on the next clock edge
clock
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
155
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
MIPS Summary
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
156
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
MIPS Summary (cont.)
Instruction Format op funct Instruction Format op funct
add R 010 3210 lw I 35
addi I 8 nor R 0 39
and R 0 36 or R 0 37
andi I 12 ori I 13
beq I 4 sb I 40
bne I 5 sh I 41
j J 2 sll R 0 0
jal J 3 slt R 0 42
jr R 0 8 slti I 10
lb I 32 srl R 0 2
lh I 33 sub R 0 34
lui I 15 sw I 43
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
MIPS Summary (cont.)
MIPS Registers
Register number Preserve on
Name Usage
(decimal) call?
$zero 0 the constant value 0 n.a.
$at 1 reserved for the assembler n.a.
procedure return values and expression
$v0-$v1 2-3 no
evaluation
$a0-$a3 4-7 procedure arguments (parameters) no
$t0-$t7 8-15 temporary registers no
$s0-$s7 16-23 general purpose saved registers yes
$t8-$t9 24-25 more temporary registers no
$k0-$k1 26-27 reserved for the OS n.a.
$gp 28 global pointer yes
$sp 29 stack pointer yes
$fp 30 frame pointer yes
$ra 31 procedure return address yes
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
MIPS Summary (cont.)
Simplicity and regularity
fixed size instructions
small number of instruction formats
opcode always the first 6 bits
Smaller is faster
limited instruction set
limited number of registers in register file
limited number of addressing modes
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
159
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
MIPS Summary (cont.)
Base or Index addressing: the operand is at the memory location whose address is the sum of
a register and a constant in the instruction
lw $s1, 100($s2)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
160
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
MIPS Summary (cont.)
PC-relative addressing: the address is the sum of the current PC and a constant (multiplied
by 4) in the instruction
beq $s1, $s2, 100
Pseudodirect addressing: the jump address is a constant (26 bits) in the instruction
(multiplied by 4) concatenated with the upper 4 bits of the PC
j 2500
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
161
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Clocking Methodology
Typical execution
read contents of state elements -> send values through combinational logic -> write results to
one or more state elements
The time necessary for the signals to reach state element 2 defines the length of the
clock cycle
The value stored in a state element is changed only when the write control signal is
sent from the control unit and a clock edge occurs
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
163
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Clocking Methodology (cont.)
Fetch
PC = PC+4
Exec Decode
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
165
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Generic Implementation (cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
166
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Generic Implementation (cont.)
After using the ALU, the actions required to complete various instruction
classes differ:
A memory-reference instruction accesses the data memory either to
write data for a store or read data for a load
An arithmetic-logical instruction writes the data from the ALU back
into a register
A branch instruction may need to change the next instruction address
based on the comparison; otherwise the PC should be incremented by 4
to get the address of the next instruction
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
167
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Basic processor architecture
Control Data
Path Path
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
169
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Datapath Elements (1) (cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
170
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Fetching Instructions
Fetching instructions involves:
reading the instruction from the Instruction
Memory
Add
Add
Instruction
Memory
PC Read Instruction
Address
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
172
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Datapath Elements (2)
Register file:
A collection of the processor 32
general-purpose registers in which any
register can be read or written by
specifying its number in the file
The register file contains the register
state of the computer
Writes are controlled by the write
control signal (RegWrite)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
173
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Datapath Elements (2) (cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
174
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Decoding Instructions
31 25 20 15 10 5 0
R-type: op rs rt rd shamt funct
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
176
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Executing R Format Operations (cont.)
4 ALU operation
Read
register 1 Read
Read data 1 ALU
Instructio n register 2 Zero
Registe rs ALU
Write result
register Read
Write data 2
data
Reg Write
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
177
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Executing Load and Store Operations
Load and store operations involves:
ALU compute memory address by adding the base
register (read from the Register File during decode) to
the 16-bit signed-extended offset field in the
instruction
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
178
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Executing Load and Store Operations (cont.)
A L U o p e r a ti o n
Read 4
re g is te r 1 M e m W ri t e
Read
d a ta 1
Read
re g is te r 2 Zero
I n s t r u c ti o n
R e giste r s ALU ALU
W ri t e Read
re s ult A d d re s s
re g is te r d a ta
Read
d a ta 2
W ri t e
D a ta
d a ta
m e m o ry
R e g W ri t e W ri t e
d a ta
16 32
S ig n Mem Read
e x te n d
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
179
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Executing R-type instructions and memory
instructions:
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
180
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
add $s0, $s1, $s2
$s1
$s1 content
$s2
$s0
$s2
content
$s1 content + $s2 content
Ref:
Write the result to register $s0
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
181
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
addi $s0, $s1, 20
$s1
$s1 content
$s0
16 bit 32 bit
represents represents
20 20
$s1 content + 20
Ref:
Write the result to register $s0
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
182
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
lw $s0, 100($s1)
Calculated memory address
$s1
$s1 content
$s0
16 bit 32 bit
represents represents
100 100 memory address
content
Ref:
Write memory address content to register $s0
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
183
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
sw $s0, 100($s1)
Calculated memory address
$s1
$s1 content
$s0
16 bit 32 bit
represents represents
100 100
Data to be written in
Ref:
the memory address
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
184
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Executing Branch Operations
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
185
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Executing
Branch
Operations
(cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
186
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Executing Jump Operations
Add
4 4
Jump
Instruction Shift address
Memory left 2
28
PC Read Instruction
Address 26
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
187
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
The Main Control Unit
The control unit takes inputs and generates a write signal for state
elements (memory or registers), the selector control for multiplexors,
and the ALU control
The control unit uses the 6-bit opcode field to generate these control
signals
MIPS regularity and simplicity means that a simple decoding process can
be used to determine how to set the control lines
The datapath operates in a single clock cycle and the signals within the
datapath can vary during the clock cycle
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
188
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
The Operation of the Datapath
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
189
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
The Operation of the Datapath (cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
190
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
The Operation of the Datapath (cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
191
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Single Cycle Disadvantages & Advantages
lw sw Waste
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
192
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
How Can We Make It Faster?
LOOK into it in Unit 4
Start fetching and executing the next instruction before the
current one has completed
Pipelining – all modern processors are pipelined for performance
Remember the performance equation:
CPU time = CPI * CCT * IC
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
193
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
The Five Stages of Load Instruction
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
195
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
A Pipelined MIPS Processor (cont.)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
196
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Single Cycle versus Pipeline
lw sw Waste
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
197
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Pipelining the MIPS
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
198
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
MIPS Pipeline Datapath
IF:IFetch ID:Dec EX:Execute MEM: WB:
MemAccess WriteBack
Add
Shift Add MEM/WB
4
left 2
Read Addr 1
Instruction Read Data
Register
Memory Memory
Read Addr 2 Data 1
Read File
PC
Read
Address ALU Address
Write Addr Data
Read
Data 2 Write Data
Write Data
Sign
16 Extend 32
System
Ref:
Clock
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
199
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Graphically Representing MIPS Pipeline
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
200
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Why Pipeline? For Performance!
Time (clock cycles)
ALU
I Inst 0 IM Reg DM Reg one instruction is
n completed every cycle,
s so CPI = 1
ALU
t Inst 1 IM Reg DM Reg
r.
ALU
O Inst 2 IM Reg DM Reg
r
d
ALU
e Inst 3 IM Reg DM Reg
r
ALU
Inst 4 IM Reg DM Reg
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
202
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
A Single Memory Would Be a Structural Hazard
Time (clock cycles)
ALU
I Mem Reg Mem Reg
n
s
ALU
t Inst 1 Mem Reg Mem Reg
r.
ALU
O Inst 2 Mem Reg Mem Reg
r
d
ALU
e Inst 3 Mem Reg Mem Reg
ALU
Inst 4 Mem Reg Mem Reg
Reading instruction from
memory
❑ Fix with separate instruction and data memories (I$ and D$)
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
203
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
How About Register File Access?
Time (clock cycles)
ALU
I IM Reg DM Reg by doing reads in the second
n half of the cycle and writes
s in the first half
ALU
t Inst 1 IM Reg DM Reg
r.
ALU
O Inst 2 IM Reg DM Reg
r
d
ALU
e add $s2,$s1, IM Reg DM Reg
r
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
204
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Register Usage Can Cause Data Hazards
Dependencies backward in time cause hazards
ALU
add $s1, IM Reg DM Reg
ALU
sub $s4,$s1,$s5 IM Reg DM Reg
ALU
and $s6,$s1,$s7 IM Reg DM Reg
ALU
or $s8,$s1,$s9 IM Reg DM Reg
ALU
IM DM Reg
xor $s4,$s1,$s5 Reg
The compiler inserts two nops (no operation instruction) before the and instruction
add $s1, $s2, $s3
nop
nop
sub $s4, $s1, $s5
and $s6, $s1, $s7
or $s8, $s1, $s9
xor $s4, $s1, $s5
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
206
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
One Way to “Fix” a Data Hazard
Can fix data hazard by
add $s1, waiting
ALU
I IM Reg DM Reg
n
s
t nops
r.
O nops
r
d
sub $s4,$s1,$s5
ALU
e IM Reg DM Reg
r
ALU
and $s6,$s1,$s7 IM Reg DM Reg
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
207
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Another Way to “Fix” a Data Hazard
Fix data hazards by
forwarding results as soon
ALU
I add $s1, IM Reg DM Reg
as they are available to
n where they are needed
s
ALU
IM Reg DM Reg
t sub $s4,$s1,$s5
r.
ALU
IM Reg DM Reg
r and $s6,$s1,$s7
d
e
ALU
r IM Reg DM Reg
or $s8,$s1,$s9
ALU
IM Reg DM Reg
xor $s4,$s1,$s5
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
208
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)
Loads Can Cause Data Hazards
Dependencies backward in time cause hazards
ALU
I lw $s1,4($s2) IM Reg DM Reg
n
s
ALU
t sub $s4,$s1,$s5 IM Reg DM Reg
r.
ALU
O and $s6,$s1,$s7 IM Reg DM Reg
r
d
ALU
e or $s8,$s1,$s9 IM Reg DM Reg
r
ALU
IM DM Reg
xor $s4,$s1,$s5 Reg
beq
ALU
I IM Reg DM Reg
n
s
ALU
t lw IM Reg DM Reg
r.
ALU
O Inst 3 IM Reg DM Reg
r
d
ALU
IM Reg DM Reg
e Inst 4
r
Ref:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky, “Computer organization”, Mc Graw Hill, Fifth edition , 2011, ISBN: 9781259005275. Only for internal use. Adarsh Patel, SCAI (SCSE), CSE2003
2. W. Stallings, “Computer organization and architecture: Designing for Performance”, Prentice-Hall, 9th edition, 2013, ISBN: 978-9332518704.
3. David A. Patterson and John L. Hennessy “Computer Organization and Design-The Hardware/Software Interface”, Morgan Kaufmann, 5th edition, 2011.
210
Intrim Semester 2024-25 (04Sep-24Dec-MTE-06-16Nov-TEE-26Dec-11Jan25)