Download Class 1.1 Computer Architecture. ISA. Numeration systems

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Computer Architecture. ISA.
Numeration systems review.
Goal – Introduction to the course and review of numeration systems:
o The hardware/software representation/interpretation levels of the computer and the
coverage of that representation by this course.
o What is the instruction and what is the instruction set architecture (ISA)?
o Computer Architecture definition.
o Why to choose MIPS assembly for this course ?
o Numeration systems (Binary, decimal, hexadecimal)
o Bits. Bit Patterns. Bit Grouping
Learning outcome - by the end of this class the students:
o should understand what is the architecture of the computer, what is ISA and be
aware of which part of the numeration systems they should know for this course.
1
1. Levels of representation / interpretation
The abstraction of the different parts of computer hardware / software allows us to create
different Levels of Representation / Interpretation. This makes easier to understand each part
separately and get the whole picture putting together all components.
On below picture you see the C program code which swaps to elements of array “v”. That
program is represented on the high level language C. It’s written by human.
To allow that code to work and to produce a result it should be compiled by compiler and be
translated to the another representation. That representation is called assembly language
representation of the same program.
The assembly program representation is closer to the computer hardware than the C program
however it cannot run directly on the computer hardware. The assembly program should be
translated to the machine language representation (numbers or bits) to be understood by
computer hardware and to run.
The hardware also could be represented on high or lower levels. It could be described as blocks
representation (the architecture) like “registers” or “Arithmetical Logical Unit” allowing us to see
how the machine instructions are processed on the hardware.
The lower level representation, like Logic Circuit Description, shows the implementation of
those blocks of the higher level.
During the course we have to go through all the levels, learn each of them separately, learn
the translation from one to another. Finally we’ll put together the learned material and get the
final picture of computer organization.
The slide is taken from UC Berkeley CS61C Fall 2012 course.
2
2. Computer architecture definition. ISA
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.
When a programmer writes in assembly language the programmer is asking for the basic
operations of the processor. The architecture of the processor is visible in every statement of the
program. 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 is an
Instruction Set Architecture (ISA).
Pure assembly language is rare. Most application programs are written in a high level language.
Even when assembly language is used it usually has been enhanced. Features are added to it to
make it more programmer-friendly. This extended assembly language includes statements that
correspond to several basic machine operations. The MIPS extended assembly language does
this, but the processor chip is still visible.

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).
3
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 high-level 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 (if compilers cannot figure out to use them).
4
3. Numeration Systems
The type of numeration system used to represent numbers has no impact upon the outcome of any arithmetical function
(addition, subtraction, multiplication, division, roots, powers, or logarithms). A number is a number; one plus one will
always equal two, no matter how you symbolize one, one and two.
Non Positional Systems
The Romans devised a system, which used a variety of symbols (or ciphers) to represent increasingly large quantities.
The notation for 1 is the capital letter “I”. The notation for 5 is the capital letter “V”. Other ciphers possess increasing
values:
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
X = 10
L = 50
C = 100
D = 500
M = 1000
If a cipher is accompanied by another cipher of equal or lesser value to the immediate right of it, with no ciphers greater
than that other cipher to the right of that other cipher, that other cipher's value is added to the total quantity. Thus, VIII
symbolizes the number 8, and CLVII symbolizes the number 157. On the other hand, if a cipher is accompanied by
another cipher of lesser value to the immediate left, that other cipher's value is subtracted from the first. Therefore, IV
symbolizes the number 4 (V minus I), and CM symbolizes the number 900 (M minus C).
Positional Systems
We owe one of the most important ideas in numeration to the ancient Babylonians, who were the
first (as far as we know) to develop the concept of cipher position, or place value, in representing
larger numbers. Instead of inventing new ciphers to represent larger numbers, as the Romans
did, they re-used the same ciphers, placing them in different positions from right to left.
This is called Positional or Radix Numeric System.
The general form of positional numbers is:
Number =
n
∑ di x Ri
i =-k
The radix ( R ) is the base of numerical system. A radix R number system requires R different
symbols to represent the digits 0 to R -1.
Our own decimal numeration system uses this concept, with only ten ciphers (0, 1, 2, 3, 4, 5, 6, 7,
8, and 9) used in "weighted" positions to represent very large and very small numbers. Each
cipher represents an integer quantity, and each place from right to left in the notation represents a
multiplying constant, or weight, for each integer quantity. For example, if we see the decimal
notation "1206", we know that this may be broken down into its constituent weight-products as
such:
5
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 = ∑
di x Ri
i = -k
Integer Part
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.
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)
6
1206 = (1 x 103) + (2 x 102) + (0 x 101) + (6 x 100)
1206 = (1 x 1000) + (2 x 100) + (0 x 10) + (6 x 1)
1206 = 1000 + 200 + 0 + 6
Each cipher is called a digit in the decimal numeration system, and each weight, or place value, is
ten times that of the one to the immediate right. So, we have an ones place, a tens place, a
hundreds place, a thousands place, and so on, working from right to left.
The decimal numeration system uses ten ciphers, and place-weights that are multiples of ten.
What if we made a numeration system with the same strategy of weighted places, except with
fewer or more ciphers?
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 numeration system
The binary numeration system is such a system. Instead of ten different cipher symbols, with
each weight constant being ten times the one before it, we only have two cipher symbols, and
each weight constant is twice as much as the one before it.
The two allowable cipher symbols for the binary system of numeration are "1" and "0" and these
ciphers are arranged right-to-left in doubling values of weight. The rightmost place is the ones
place, just as with decimal notation. Proceeding to the left, we have the twos place, the fours
place, the eights place, the sixteens place, and so on.
For example, the following binary number can be expressed as a sum of each cipher value times
its respective weight constant:
7
11010 = (1 x 24) + (1 x 23) + (0 x 22) + (1 x 21) + (0 x 20)
11010 = (1 x 16) + (1 x 8) + (0 x 4) + (1 x 2) + (0 x 1)
11010 = 16 + 8 +0 + 2 + 0 = 26
This can get quite confusing, as I've written a number with binary numeration (11010), and then
shown its place values and total in standard, decimal numeration form (16 + 8 + 2 = 26).
To avoid unnecessary confusion, we have to denote which form of numeration we're using when
we write (or type!).
Typically, this is done in subscript form, with a "2" for binary and a "10" for decimal, so the binary
number 110102 is equal to the decimal number 2610.
The subscripts are not mathematical operation symbols like superscripts (exponents) are. All they
do is indicate what system of numeration we're using when we write these symbols for other
people to read. If you see "310", all this means is the number three written using decimal
numeration.
However, if you see "310", this means something completely different: three to the tenth power
(59,049). As usual, if no subscript is shown, the cipher(s) are assumed to be representing a
decimal number.
Commonly, the number of cipher types (and therefore, the place-value multiplier) used in a
numeration system is called that system's base. Binary is referred to as "base two" numeration,
and decimal as "base ten". Additionally, we refer to each cipher position in binary as a bit rather
than the familiar word digit used in the decimal system.
Now, why would anyone use binary numeration? The decimal system, with its ten ciphers, makes
a lot of sense, being that we have ten fingers on which to count between our two hands.
The primary reason that the binary numeration system is used in modern electronic computers is
because of the ease of representing two cipher states (0 and 1) electronically. With relatively
simple circuitry, we can perform mathematical operations on binary numbers by representing
each bit of the numbers by a circuit which is either on (current) or off (no current).
We simply add more circuits to give us more bits to symbolize larger numbers. Binary
numeration also lends itself well to the storage and retrieval of numerical information: on
magnetic tape (spots of iron oxide on the tape either being magnetized for a binary "1" or
demagnetized for a binary "0"), optical disks (a laser-burned pit in the aluminum foil representing
a binary "1" and an unburned spot representing a binary "0"), or a variety of other media types.
The bit on the far right side is called the Least Significant Bit (LSB), because it stands in the
place of the lowest weight (the one's place). The bit on the far left side is called the Most
Significant Bit (MSB), because it stands in the place of the highest weight. Remember, a bit
value of "1" means that the respective place weight gets added to the total value, and a bit value
of "0" means that the respective place weight does not get added to the total value.
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 of several semiconductors).

Needs simple hardware and simple procedures for calculations (all mathematical
operations could be done by simple shift, invert, add operations)
4. Bits. Bit Patterns. Bit Grouping
Binary numeration also lends itself well to the storage and retrieval of numerical
information on magnetic media (magnetized – 1, demagnetized –0) or optical
8
disks (laser burned pit –1, not burned – 0).

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 GROUPINGS
In digital, electronic computer design, it is common to design the system for a common "bit width:"
a maximum number of bits allocated to represent numerical quantities. Early digital computers
handled bits in groups of four or eight. More modern systems handle numbers in clusters of 32
bits or more.
To more conveniently express the "bit width" of such clusters in a digital computer, specific labels
were applied to the more common groupings.
Eight bits, grouped together to form a single binary quantity, is known as a byte.
Four bits, grouped together as one binary number, is known by the humorous title of nibble, often
spelled as nybble.



Bit: A single, bivalent unit of binary notation. Equivalent to a decimal "digit."
Nibble, or Nybble: Four bits.
Word: (system dependent).
The most ambiguous term by far is word, referring to the standard bit-grouping within a particular
digital system. For a computer system using a 32 bit-wide "data path," a "word" would mean 32
bits. If the system used 16 bits as the standard grouping for binary quantities, a "word" would
mean 16 bits.
9
Context dependence is likewise true for derivative terms of word, such as double word and longword (both meaning twice the standard bit-width), half-word (half the standard bit-width), and
quad (meaning four times the standard bit-width).






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
10
5. Hexadecimal numeration system
Another system is called hexadecimal, because it is a place-weighted system with a base of
sixteen.
Valid ciphers include the normal decimal symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9, plus six
alphabetical characters A, B, C, D, E, and F, to make a total of sixteen. As you might have
guessed already, each place weight differs from the one before it by a factor of sixteen.
Let's count from zero to twenty using decimal, binary and hexadecimal to contrast these systems
of numeration:
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
(11 x 163) + (7 x 162) + (8 x 161) + (5 x 160)
(11 x 4096) + (7 x 256) + (8 x 16) + (5 x 1)
45056 + 1792 + 128 + 5 = 46981
Hexadecimal numeration system is used to serve as a "shorthand" method of denoting a number
represented electronically in binary form. Because the bases of hexadecimal (sixteen) are even
multiples of binary's base (two), binary bits can be grouped together and directly converted to or
from their respective hexadecimal digits.
The binary bits are grouped in four's to form the hexadecimal number.
The binary number
the hexadecimal equivalent
the decimal value
1011 0111 1000 01012
B
7
8
5 16
(11 x 163) + (7 x 162) + (8 x 161) + (5 x 160)
(11 x 4096) + (7 x 256) + (8 x 16) + (5 x 1)
45056 + 1792 + 128 + 5 = 46981
Hexadecimal notation is more popular, because binary bit groupings in digital equipment are
commonly multiples of eight (8, 16, 32, 64, and 128 bit), which are also multiples of 4.
11
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
12