Class 1.1 Computer Architecture. ISA. Numeration systems.pptx

Download Report

Transcript Class 1.1 Computer Architecture. ISA. Numeration systems.pptx

The Goal of this class
• Review of the numeration systems
• The hardware/software representation of the computer
and the coverage of that representation by this course.
• What is the instruction and ISA?
• CISC/RISC tradeoff.
Learning outcome
• by the end of this class the students should know the
main differences and distinguish RISC solutions from the
CISC solutions
Why to use the assembly and why we need this course at all?
How tens of programs work on one or couple of processors of your PC?
It’s organized by the Operating System.
Operating systems behavior cannot be understood without knowledge of
computer structure and the assembly language.
• PCB, context switch, threads, stack, heap, dynamic linking
Assembly language advantages versus High level languages
• The primary reason to program in assembly language is that the speed
or size of a program is critically important.
• A hybrid approach, in which most of a program is written in a highlevel language and time-critical sections are written in assembly
language, builds on the strengths of both languages
• Cases when no high-level language or compiler is available on a
particular computer
• Ability to exploit specialized instructions, for example, string copy or
pattern-matching instructions.
Human writes
the code
During the course we have to
• The•abstraction
go throughof
allthe
thedifferent
levels parts of computer hardware / software allows us
to create
different
of Representation / Interpretation.
• learn
each ofLevels
them separately
learn the
translation
from oneeach
to another
• This• makes
easier
to understand
part separately and get the whole picture
• Finally
we’llallput
together the learned material and get the final picture of
putting
together
components.
computer organization.
Course Organization, Evaluation
Student learning will be evaluated on the basis of the following weighted
components:
 Home assignments
20% of final grade
 Grade of midterm examinations, Quizzes
50%
 Grade of final examination
30%
 Bonus scores:
 Class attendance/participation
5-10%
 Bonus Projects (deadline of taking February 28)
5- 10%
• For the students who pass the waiver examination (2016.01.31 – 9:00 – 11:00)
the waiver examination grade could be passed as a final grade and student is
free to attend the classes.
• Waiver examination questions:
1. Write Assembly language program (cycles, i/o, arrays).
2. Representation of data in computers. (instructions, characters, numbers)
3. Create a simple combinational logic circuit.
Office Hours - Thursday 19:00, Saturday 12:00
Aidela Karamyan 093249954
Course Organization, Evaluation
• Handouts’ topics fully cover all examination questions. (No questions will be
out of handout topics).
• However handouts are not enough for full understanding the topics
included there. The students need either to attend the class or work on
textbooks for full understanding.
• Class attendance is graded with the bonus scores.
• Assignments are based only on the material of the current and previous
classes’ handouts and exercises.
• They contain personal identifiers to make them different for different
students.
• Assignments’ soft deadline is about a week. For example if the deadline is
on Sunday then the assignment should be sent to lecturer before the
Sunday evening 23:59. Delayed assignments’ grades are lowered.
• Assignments’ hard deadline is about 2 weeks. Assignments are not accepted
after the hard deadline.
The course material is on the Academic server
ac.aua.am
Grading Scale
a+
92-100
a
82-91
a-
73-81
b+
64-72
b
55-63
b-
46-54
c+
37-45
c
28-36
c-
20-27
d
10 -19
f
0-9
Instruction Set Architecture
• Basic job of a CPU: execute lots of instructions.
• Instructions are the primitive operations that the CPU
may execute.
• Different CPUs implement different sets of
instructions. The set of instructions a particular CPU
implements defines the Instruction Set Architecture
(ISA).
• Examples: Intel x86 (Pentium 4), Apple/IBM/Motorola
PowerPC, MIPS, Sun Sparc, ...
Computer architecture
The architecture of a computer is a
logical description of its components
+ its basic operations (ISA).
Machine Instruction
Memory Address
(Basic Operation of
Processor)
In pure assembly language one assembly
language statement corresponds to one
basic operation of the processor.
Assembly Language
statement
Set of Assembly Language statements (instructions) fully defines the operational part of architecture
Assembly Language
Instruction Set for
Sun Sparc platform
Assembly Language
Instruction Set for
MIPS platform
Assembly Language
Instruction Set for
Intel x86 platform
The architecture defined by the instruction set of assembly language we call ISA – Instruction Set
Architecture. We see 3 different ISA listed above.
CISC and RISC approaches
As the Memory was expensive – the programs should
have been short:
Early trend was
• to add more and more instructions to new CPUs to do
elaborate operations
• In order to have shorter programs to fit into the small memory
• VAX architecture had an instruction to multiply
polynomials.
• intel x86 had string or array operation instructions.
Memory becomes cheaper – the programs could be
longer:
• RISC philosophy – Reduced Instruction Set
Computing.
• Keep the instruction set small and simple, makes it easier
to build fast hardware.
• Let software do complicated operations by composing
simpler ones.
Complex Instruction Set Computer
Short programs
with powerful
instructions
Many different types of instructions
Small and expensive Memory
Processor (very complex)
Complex and powerful instructions
memc = mema + memb
z = (a + b)(c + d)
arr2[1..n] = arr1[1..n]
bool1 = str1 cmp str2
short
long instr
longer instr
instr
. . .
memc = mema + memb
z = (a + b)(c + d)
bool1 = str1 cmp str2
Reduced Instruction Set Computer
Many and Long
programs with
simple instructions
a = mema
b = memb
x = a + b
y = c + d
c = a + b
memc = c
z = x * y
z = x * y
memc = c
Complex and powerful instructions
memc = mema + memb
z = (a + b)(c + d)
arr2[1..n] = arr1[1..n]
bool1 = str1 cmp str2
short
long instr
longer instr
instr
. . .
Simple, uniform size instructions
Few types of
instructions
Processor (very simple but fast with
possibility to make parallelism)
c = a + b
a = mema
Many different types of instructions
Large and cheap Memory
c = a + b
z = x * y
inst ...
MIPS Architecture
• MIPS – semiconductor company that built
one of the first commercial RISC
architectures.
• We will study the MIPS architecture in detail
in this course.
• Why MIPS instead of Intel 80x86?
• MIPS is simple.
RISC, CISC architectures tradeoff






CISC
RISC
(Complex Instruction Set Computers)
(Reduced Instruction Set Computers)
complexity is put on the hardware
the program code size is small, needs
less memory (very expensive at the
time)
large instruction set
instructions can perform very complex
operations
CISC based CPUs
variable
lengthPentium I
Intel - x86,instruction
80386, 80486,
large number
Motorola
- 68k of addressing modes


complexity is put on the software
(compilers)
the program code size could be large


relatively few instructions
simple instructions
RISC based CPUs
 Sun
uniform
instruction length
- SPARC
 Silicon
simple
addressing
modes, only load/store
Graphics
- MIPS
instructions
access
memory
Acorn
RISC Machine
- ARM
IBM - 360/370
 DEC
few -registers
 Hitachi
many
registers
– SH
PDP11, VAX
 machine instructions implemented with
 IBM
no- microcode
PowerPC, (because the instructions
microcode (flexibility).
are simple)
 low performance due to complexity
 allows high performance due to simplicity
with simple instructions)
More or less CISC, RISC (pipelines
based CPUs


From Intel Pentium Pro to Pentium III
Pentium 4, Xeon, Core 2, Core i5, Core i7
High and Low level languages
C Program
C++ Program
Assembly Program
Sun Sparc
Java Program
C#, .net Program
Assembly Program
MIPS
Assembly Program
Intel x86

In assembly language the program is written totally in terms of the processor.
The assembly program of one processor cannot run on the processor of other
architecture (platform).

Programs in high level languages such as C or Pascal are (mostly)
independent of the processor they run on.

Programs in Java are totally independent of the processor (because they run on
special environment – Java Virtual Machine, Java Application Server, TomCat
server – implemented on different platforms to understand the same Java
language for different architectures).
Numeration systems
Review
One plus one always equals to two,
no matter how you symbolize one, one and two.
 Just Lions:

Roman numbers
 Decimal numbers
 Binary numbers
 Hexadecimal numbers
I
1
1
1
+
+
+
+
I
1
1
1
=
=
=
=
II
2
10
2
Doing binary correct operations in the computer we are sure that the
translated result to decimal also is correct.
Numeration systems
Numeration Systems
 Non Positional systems:
Roman numbers
IV, VII
The I everywhere is “one” in this system.
I
 Positional (radix) systems:
o Decimal number system
o Binary number system
o Hexadecimal number system
The general form of positional numbers is:
n
Number = ∑
Integer Part
i = -k
di x Ri
Fractional Part
dn ... d2 d1 d0 . d –1 d –2 d –3 ... d –k
R – The base or radix of numerical system.
A radix R number system requires R different symbols to represent the digits
(d) from 0 to R -1.
i – weight of digit or position.
Numeration systems
Decimal Numeration System
(Human use ten fingers on both hands for calculation)
R = 10
d – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
1+1+1+1+1 + 1+1+1+1+1 + 1+1
------------------------------------------
= 12
----10
10
12
Decimal 12 means:
12 = (1 x 10) + (2 x 1)
12 = 10 + 2
hundreds’ place
tens’ place
ones’ place
Decimal 1206 means:
1206 = 1000 + 200 + 0 + 6
1206 = (1 x 1000) + (2 x 100) + (0 x 10) + (6 x 1)
1206 = (1 x 103) + (2 x 102) + (0 x 101) + (6 x 100)
Numeration systems
Binary (two based) Numeration System
(The human who used this kind of system has a single hand with only one finger on it)
R=2
1+1
--------
+
1 = 112
d – 0, 1
102
= 210
102
= 210
---
bits (two based digits)
112
= 310
Fours’ place Twos’ place
Ones’ place
110102 = (1 x 24) + (1 x 23) + (0 x 22) + (1 x 21) + (0 x 20)
110102 = (1 x 16) + (1 x 8) + (0 x 4) + (1 x 2) + (0 x 1)
110102 = 16 + 8 +0 + 2 + 0 = 2610
The base is needed to distinguish
different numeration systems
Most Significant Bit
Least Significant Bit
Binary system in computers
Why we use binary system in computers ?

Easy to represent two cipher states 0,1 electronically (a simple flip-flop is the
basic device which stores the binary bit and consists from several semiconductors).

Needs simple hardware and simple procedures for calculations (all mathematical
operations could be done by simple shift, invert, add operations)

Binary numeration also lends itself well to the storage and retrieval of numerical
information on magnetic media (magnetized – 1, demagnetized –0) or optical
disks (laser burned pit –1, not burned – 0).
Bit patterns
A bit can be 0 or 1. With one bit there are two possible patterns.
How many patterns can be formed with two
bits? Here is a complete list:
00
01
10
11
Looks like 4 patterns.
How many patterns can be formed with three
bits? Let's list them:
000
001
010
011
100
101
110
111
Looks like 8 patterns.
Number of possible patterns of N bits = 2N
Many calculations involving bit patterns use the following familiar fact of arithmetic. (Although the
fact is familiar, confusion is even more familiar. Be sure you know this fact.)
2(N+M) = 2N × 2M
Bit grouping






BIT GROUPINGS
Bit
- 1 bit (0,1)
Nibble
- 4 bits
Byte
- 8 bits
Half word
- 16 bits for MIPS 32
Word
- 32 bits for MIPS 32
Double word
- 64 bits for MIPS 32
- 16, 32, 64 bits depended on a system
MIPS 32 architecture - word, half word and double word representation.
Half
Half
Half
Word
Half
Word
Double
Hexadecimal (sixteen based) Numeration System
serves as a "shorthand" comfortable method of denoting a number represented in binary form
R = 16
Decimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Binary
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
1 0000
1 0001
1 0010
1 0011
1 0100
d – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Hexadecimal
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
10
11
12
13
14
The binary number
1011 0111 1000 01012
the hexadecimal
equivalent
B
7
8
5
16
the decimal value
3
2
1
0
(11 x 16 ) + (7 x 16 ) + (8 x 16 ) + (5 x 16 )
(11 x 4096) + (7 x 256) + (8 x 16) + (5 x 1)
45056 + 1792 + 128 + 5 = 46981
Conversion Example From Decimal to Binary
Convert the decimal 54.4062510 to binary:
Repeated division for the integer portion:
Repeated multiplication for the fractional portion:
54
0.40625 x 2 = 0.8125 Integer portion of product = 0
--- = 27.0 Remainder = 0
2
0.8125 x 2 = 1.625 Integer portion of product = 1
27
0.625 x 2 = 1.25 Integer portion of product = 1
--- = 13.5 Remainder = 1 (0.5 x 2)
2
0.25 x 2 = 0.5 Integer portion of product = 0
0.5 x 2 = 1.0 Integer portion of product = 1
13
--- = 6.5 Remainder = 1 (0.5 x 2)
2
PARTIAL ANSWER: 0.4062510 = 0.011012
6
COMPLETE ANSWER:
--- = 3.0 Remainder = 0
2
5410 + 0.4062510 = 54.4062510
3
1101102 + 0.011012 = 110110.011012
--- = 1.5 Remainder = 1 (0.5 x 2)
2
1
--- = 0.5 Remainder = 1 (0.5 x 2)
2
PARTIAL ANSWER: 5410 = 1101102