2. Definition of Computer
• Computer is a programmable machine.
• Computer is a machine that manipulates data
according to a list of instructions.
• Computer is any device which aids humans in
performing various kinds of computations or
calculations
3. Earliest Computer
• Originally calculations were computed by humans
• Human computers were typically engaged in the
calculation of a mathematical expression
• The calculations of this period were specialized
and expensive, requiring years of training in
mathematics
• The first use of the word "computer" was
recorded in 1613, referring to a person who
carried out calculations, or computations, and the
word continued to be used in that sense until the
middle of the 20th century.
44. Ideas
• The eight ideas that the computer architects have
been invented for computer design are as follows:
1. Design for Moore’s law:
Moore’s law states that integrated circuit
resources double every year 18-24 months. As
computer designers may take years, the resources
available per chip can easily double or quadruple
between the start and the completion of the
design. For this reason, the computer architects
must anticipate where the technology will be at
the completion of design rather than at the start
of design.
45. 2. Use abstraction to simplify design:
Computer architects must use abstractions to
represent the design at different levels to
representation instead of lower –levels details.
This reduces the design time considerably.
3. Make the common case fast:
In making a design a trade-off , it is better to
favor the frequent case over the infrequent case.
It makes design simple and can be done faster.
46. 4. Performance via Parallelism:
It is known that we get more throughput by
performing operations in parallel
5. Performance via Pipelining:
A pipeline is a set of data processing elements
connected in series, where the output of one
element is the input of the next one. The
elements of pipeline are often executed in
parallel to improve performance.
47. 6. Performance via Prediction:
In some cases it is better to predict and start
working rather than wait until we know for
sure assuming that the mechanisms to recover
from a mis-prediction is not too expensive and
our prediction is relatively accurate.
7. Hierarchy of memory:
Ideally, computer memory should be fast, large
and inexpensive. Unfortunately, it is
impossible to meet all the three of these
requirements using one type of memory
48. • Increased speed and size are achieved at increased
cost.
• The computer architects have found that they can
address these conflicting demands with a
hierarchy of memory with the fastest, smallest
and most expensive memory at the top of the
hierarchy and the slowest, largest and cheapest at
the bottom
8. Dependability via redundancy:
We know that computer should be fast and it also
should be dependable. In a computer system a
failure of any single component can shut down
the entire system. We can make system
dependable by including redundant components
that can take over the failure occurs.
49. Performance
• The performance is an important attribute of a
computer. It is an important criteria for
selection of a computer
• There are number of ways by which
performance of a computer can be measured.
50. Defining Performance
• When we say one computer is faster than another,
we compare their speeds and observes that the
faster computer runs a program in less time than
other computers
• The computer center manager running a large
server system may say a computer is faster when
it completes more jobs in an hour.
• The computer user is always interested in
reducing the time between the start and the
completion of the program or event i.e., reducing
the execution time
51. Contd..
• The execution time is also referred to as response time.
Reduction in response time increases the throughput ( the
total amount of work done in a given time). The
performance of the computer is directly related to
throughput and hence it is reciprocal of execution time.
• This means that for two components A and B is the
performance of A is greater than the Performance of B,
53. EXAMPLE
• If Computer A runs a program in 10seconds
and computer B runs the same program in
25seconds, how much faster is A than B?
54. EXAMPLE
• If Computer A runs a program in 10seconds and
computer B runs the same program in 25seconds,
how much faster is A than B?
55. Measuring Performance
• One of the important measure of a computer
performance is a time.
• The computer that performs same task in a
least time is the fastest. Program execution
time is measured in seconds per program.
56. CPU TIME
• CPU time is the time the CPU spends
computing for particular task and does not
include time spend waiting for I/O or other
programs
• CPU time can be divided into the CPU time
spend in the program called user CPU time.
• CPU time spent in the operating system
performing tasks on behalf of the program
called system CPU time
57. • Differentiating between system and user CPU time is difficult to do
accurately
• Because it is often hard to assign responsibility for operating system
activities to one user program rather than other and because of the
functionality differences among operating systems.
• So performance is measured by CPU execution time
• CPU execution Time = CPU clock cycles for a program x Clock cycle time
or
• CPU execution Time = CPU clock cycles for a program / Clock Rate
66. Power Wall
• Running a Processor at high clock speeds
allows for better performance.
• Processor runs at a higher speed, it generates
more heat and consumes more power
• Increase in clock rate increases the power
consumption
• Technology used for IC is CMOS. For CMOS the
dynamic power depends on the capacitive
loading of each transistor, voltage applied, and
the frequency that the transistor is switched.
67. • Power =Capacitive load x voltage^2 x Frequency
switched
• Example:
– If a new processor has 85% if the capacitive load of
old processor, it supply voltage is reduced by 20%
and new processor results in a 25% shrink in
frequency. What is the impact on power
consumption?
68. – Hence the new processor uses only 40.8% of the
power that the old processors
69. Power Consumption
• By lowering the power supply voltage it is
possible to reduce power consumption.
However, lowering supply voltage beyond
certain limit make the transistors too leaky
and it will increase power consumption due to
leakage
• By using large cooling device
• Turning off parts of chip that are not used in a
given clock cycle
70. Uniprocessor to Multiprocessor
• Due to limitation of power consumption there
is a change in the design approach of
microprocessor
• Instead of increasing speed of single
processor, designers came up with multiple
processor per chip.
• The intension was to increase throughput
rather than decrease response time
71. • Multicore processor support parallelism
concept
• Writing programs to support parallelism is not
a simple task for the following reasons
– It increases difficulty level of programming
– It is necessary to divide the programming task so
that each processor has roughly the same amount
to do at the same time. That is it needs load
balancing
– Need scheduling of sub task
72. • Needs to maintain coordination between
subtasks
• Needs to synchronize task
Advantages:
• Improves cost/performance ratio of the
system
• Several processors may be combined to fit the
needs of an application while avoiding the
expense of the unneeded capabilities of
centralized system. This system provide room
for expansion
73. • Tasks are divided among the modules. If
failure occurs, it sis easier and cheaper to find
and replace the malfunctioning processor
than replacing the failing part of complex
processor.
• In a multiprocessor systems, a failure or error
in one part has a limited effect on the rest of
the system. If fault occurs in one processor, a
second processor can take the responsibility
of performing the task of the failure processor.
This improves the reliability of the system at
the cost of some loss in the efficiency.
74. Addressing Mode
• Different kind of ways the programmer can
refer to data stored in the memory or I/O
devices
76. • Auto increment addressing mode
• Auto decrement addressing mode
• Stack addressing mode
77. Register Addressing mode
• The operand is the contents of processor
register. The name of register is specified in
the instruction
• Example; MOV R2,R1
• This instruction copies the content of register
R2 to R1
78. Absolute or direct addressing mode
• The address of the location of the operand is
given explicitly as a part of the instruction
• Example:
• MOV A, [2000]
• This instruction copies the content of memory
location 2000 in to register A.
79. Immediate Addressing mode
• The operand is given explicitly in the
instruction
• Example:
– MOV #20,A
This instruction copies operand 20 in the register A
The sign # in front of the value of an operand is used
to indicate that this value is an immediate
operand
80. Indirect Addressing Mode
• In this addressing mode, the instruction
contains the address of memory which refers
the address of the operand
• LOAD R1, @100
81. Register Indirect Addressing mode
• The effective address of the operand is the
contents of a register or the main memory
location whose address is given explicitly in
the instruction
• Example:
– MOV R0, A
82. Immediate addressing mode
• The addressing mode in which the data
operand is a part of the instruction itself is
known as immediate addressing mode.
• Example
• MOV CX, 4929 H,
• ADD AX, 2387 H,
• MOV AL, FFH
83. Register addressing mode
• It means that the register is the source of an
operand for an instruction.
• Example
• MOV CX, AX ; copies the contents of the 16-bit
AX register into ; the 16-bit CX register), ADD
BX, AX
84. Direct addressing mode
• The addressing mode in which the effective
address of the memory location is written
directly in the instruction.
• Example
• MOV AX, [1592H], MOV AL, [0300H]
85. Register indirect addressing mode
• This addressing mode allows data to be
addressed at any memory location through an
offset address held in any of the following
registers: BP, BX, DI & SI.
• Example
• MOV AX, [BX] ; Suppose the register BX
contains 4895H, then the contents ; 4895H are
moved to AX
86. Based addressing mode
• In this addressing mode, the offset address of
the operand is given by the sum of contents of
the BX/BP registers and 8-bit/16-bit
displacement.
• Example
• MOV DX, [BX+04], ADD CL, [BX+08]
87. Indexed addressing mode
• In this addressing mode, the operands offset
address is found by adding the contents of SI
or DI register and 8-bit/16-bit displacements.
• Example
• MOV BX, [SI+16], ADD AL, [DI+16]
A.Azhagu Jaisudhan M.E. (Ph.D)
88. Based-index addressing mode
• In this addressing mode, the offset address of
the operand is computed by summing the
base register to the contents of an Index
register.
• Example
• ADD CX, [BX+SI], MOV AX, [BX+DI]
89. Based indexed with displacement
mode
• In this addressing mode, the operands offset is
computed by adding the base register
contents. An Index registers contents and 8 or
16-bit displacement.
• Example
• MOV AX, [BX+DI+08], ADD CX, [BX+SI+16]
90.
91.
92.
93.
94. Auto Increment Addressing Mode
• The effective address of the operand is the contents
of a register specified in the instruction. After
accessing the operand, the contents of this register
are incremented to address the next location.
• Example: MOV R0,(R2)+
• The above instruction copies the content of register
R0 in to the memory location whose address is
specified by the content of register R2. After copy
operation, the contents of register R2 are
automatically incremented by 1
95. Auto decrement Addressing Mode
• The content of a register specified in the instruction
are decremented and then they are used as an
effective address to access a memory location.
Example: MOV -R0,(R1)
• This instruction, initially decrements the contents of
register R0 and then the decremented contents of
register R0 are used to address the memory location.
Finally, the contents from the addressed memory
location are copied in to the register R1.
96.
97.
98. Instructions
• The word of computers language are called
instructions.
• Instruction set of computers both in the form
of written by people and in the form read by
the computer.
• Language of computers would be as diverse as
those of people, but in reality computer
languages are quite similar.
• Many Instruction sets comes from MIPS
Technologies
99. Three popular instruction sets
• ARMv7 is similar to MIPS. More than 9 billion
chips with ARM processors were
manufactured in 2011, making it the most
popular instruction set in the world.
• The second example is the Intel x86, which
powers both the PC and the cloud of the post
PC era.
• The third example is ARMv8, which extends
the address size of the ARMv7 from32bits to
64bits. This instruction set is closed to MIPS
than ARMv7.
100. • This similarity of instruction sets occurs because
all computers are constructed from hardware
technologies based on similar underlying
principles.
• Computer designers have a common goal;
• To find a language that makes it easy to build the
hardware and the compiler while maximizing
performance and minimizing cost and energy.
• The simplicity of the equipment is as valuable a
consideration for today's computers as it was for
those of the 1950.
• This topic we discussed about showing both how it
is represented in hardware and the relationship
between high level language
101.
102.
103. Instruction Types
• According to operation
– Data Processing Instruction
– Data Storage Instruction
– Data movement Instruction
– Control Instruction
• According to number of addresses
– Three address instruction
– Two address instruction
– One address instruction
– Zero address instruction
104. According to operation
• Processor has a set of instruction that allows
the user to formulate any data processing ask.
• According to operations instruction are
classified
• Data Processing:
– Arithmetic and logic instruction – The arithmetic
instructions provide computational capabilities for
processing numeric data, whereas logic
instruction provide capabilities of performing
logical operations on the bits of a word
105. • Data Storage: Memory Instructions
– Arithmetic and logical operations are performed primarily on data
in CPU register. Therefore it is necessary to transfer data from
memory to CPU registers before operation and transfer data from
CPU registers to memory after operations.
– The instruction used for such function are belongs to data storage
instructions.
Data Movement:
Date movement instructions are the superset of data storage
instructions. These instructions include the instructions for
transfer of data between CPU register and transfer of data
between CPU registers and input/output devices.
Control:
Test and branch instructions- Test instructions are used to test the
value of a data word or the status of a computations. Branch
instruction are used to branch to a different set of instructions
depending on the decision made.
106.
107.
108. EXAMPLE
• Write a program to evaluate the arithmetic
statement : Y=(A+B)*(C+D) using three
address, two address, one address and zero
address instructions
113. TYPES OF OPERANDS
• Each instruction in a program specifies operation
to be performed and data to be processed. For
this reason, an instruction is divided into two
parts: Its operation code (opcode) and its operand
(data)
• Operand forms:
– Addresses
– Numbers
– Characters
– Logical data
114. Types of Operations
• Generally type of operations supported by
MIPS instruction set architecture can be
categorized as follows:
– Arithmetic
– Data Transfer
– Logical
– Conditional branch
– Unconditional jump
115. • MIPS assembly language simply refers to
the assembly language of the MIPS processor.
The term MIPS is an acronym which stands for
Microprocessor without Interlocked Pipeline
Stages, and it is a reduced-instruction set
architecture which was developed by an
organization called MIPS Technologies.
116. MIPS (RISC) Design Principles
• Simplicity favors 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
• Make the common case fast
– arithmetic operands from the register file (load-store
machine)
– allow instructions to contain immediate operands
• Good design demands good compromises
– three instruction formats
117. MIPS-32 ISA
• Instruction Categories
– Computational
– Load/Store
– Jump and Branch
– Floating Point
• coprocessor
– Memory Management
– Special
R0 - R31
PC
HI
LO
Registers
op
op
op
rs rt rd sa funct
rs rt immediate
jump target
3 Instruction Formats: all 32 bits wide
R format
I format
J format
118.
119.
120. MIPS Register File
Register File
src1 addr
src2 addr
dst addr
write data
32 bits
src1
data
src2
data
32
locations
32
5
32
5
5
32
• Holds thirty-two 32-bit registers
– Two read ports and
– One write port
Registers are
Faster than main memory
- But register files with more locations are
slower (e.g., a 64 word file could be as much
as 50% slower than a 32 word file)
- Read/write port increase impacts speed quadratically
Easier for a compiler to use
- e.g., (A*B) – (C*D) – (E*F) can do multiplies in any order vs. stack
Can hold variables so that
- code density improves (since register are named with fewer bits than a
memory location)
write control
122. MIPS Memory Access Instructions
• MIPS has two basic data transfer instructions for
accessing memory
lw $t0, 4($s3) #load word from
memory
sw $t0, 8($s3) #store word to
memory
• The data is loaded into (lw) or stored from (sw) a
register in the register file – a 5 bit address
The memory address – a 32 bit address – is formed by adding
the contents of the base address register to the offset value
123. Chapter 2 — Instructions: Language of the Computer — 123
Arithmetic Example
• C code:
f = (g + h) - (i + j);
• Compiled MIPS code:
add t0, g, h # temp t0 = g + h
add t1, i, j # temp t1 = i + j
sub f, t0, t1 # f = t0 - t1
124. Register Operands
• Arithmetic instructions use register
operands
• MIPS has a 32 × 32-bit register file
– Use for frequently accessed data
– Numbered 0 to 31
– 32-bit data called a “word”
• Assembler names
– $t0, $t1, …, $t9 for temporary values
– $s0, $s1, …, $s7 for saved variables
– Design Principle 2: Smaller is faster
125. Register Operand Example
• C code:
f = (g + h) - (i + j);
– f, …, j in $s0, …, $s4
• Compiled MIPS code:
add $t0, $s1, $s2
add $t1, $s3, $s4
sub $s0, $t0, $t1
126. Memory Operands
• Main memory used for composite data
– Arrays, structures, dynamic data
• To apply arithmetic operations
– Load values from memory into registers
– Store result from register to memory
• Memory is byte addressed
– Each address identifies an 8-bit byte
• Words are aligned in memory
– Address must be a multiple of 4
• MIPS is Big Endian
– Most-significant byte at least address of a word
– Little Endian: least-significant byte at least address
127.
128. Chapter 2 — Instructions: Language of the Computer — 128
Memory Operand Example 2
• C code:
A[12] = h + A[8];
– h in $s2, base address of A in $s3
• Compiled MIPS code:
– Index 8 requires offset of 32
lw $t0, 32($s3) # load word
add $t0, $s2, $t0
sw $t0, 48($s3) # store word
129. Chapter 2 — Instructions: Language of the Computer — 129
Registers vs. Memory
• Registers are faster to access than memory
• Operating on memory data requires loads and
stores
– More instructions to be executed
• Compiler must use registers for variables as
much as possible
– Only spill to memory for less frequently used
variables
– Register optimization is important!
130. Immediate Operands
• Constant data specified in an instruction
addi $s3, $s3, 4
• No subtract immediate instruction
– Just use a negative constant
addi $s2, $s1, -1
• Design Principle 3: Make the common case
fast
– Small constants are common
– Immediate operand avoids a load instruction
131. Chapter 2 — Instructions: Language of the Computer — 131
The Constant Zero
• MIPS register 0 ($zero) is the constant 0
– Cannot be overwritten
• Useful for common operations
– E.g., move between registers
add $t2, $s1, $zero
132.
133.
134.
135.
136.
137.
138.
139.
140.
141. The C Code Translation Hierarchy
C program
compiler
assembly code
assembler
object code library routines
executable
linker
loader
memory
machine code