comp1200 notes arch1 -...
Transcript of comp1200 notes arch1 -...
Computer ArchitecturePerspectives on Computing COMP1200
Chris Johnson
The Australian National UniversitySemester 1 2005
Acknowledgment
The Lecture Slides Were Written by Eric McCreath with Minor Modificationsby Weifa Liang 2004 and Chris Johnson
2005
lecture 1: Computer ArchitectureBinary Information
Storing, transferring, and processing information.
Basic Bits.
Interpretation of binary information:
nonnegative integers, integers, floating number, and characters.
Measuring information.
Information
Information is the life blood of a computer system. That is, a computer is a machine that operates upon information.
This information must bestored, processed and transferredvia a physical medium. There are many possible media.
Binary information is the simplest way of storing information.
Informationstorage, processing, and transfer
The physical medium that information is stored in places limitations on the amount that can be stored.
The physical medium that information is processed within places bounds on the speed at which it may be processed.
Finally, the physical medium that information is transferred via places limitations on the speed (or rate) it can be transferred.
Binary information
A single bit is in one of two states, these are usually labeled either 0 or 1.
By collecting a number of bits together more than two states can be represented within a computer.
n bits can represent 2n states.
000000001100102
:111115
:4bits16 states
The Byte
A byte consists of 8 bits.
A byte forms a basic unit of binary information.
A byte can represent 256 states.
A nibble refers to 4 bits.
2, 4, or 8 bytes are placed together to form a word. The word size is dependent on the architecture in question.
Decimal
Binary is often a cumbersome representation for humans to manipulate. One approach is to use decimal.
Binary can be changed to decimal:
Decimal can also be simply changed to binary:
However, this is a slow and error prone task for humans to undertake.
bn−1 bn−2 .... b2 b1 b0∑k=0
n−1
bk 2k
bk=d÷2k mod 2
Hexadecimal
A more common way of representing binary information is using base 16. This is known as Hexadecimal.
It is easy and quick to change between Hex and binary. e.g.
10008100191010 A1011B1100C1101D1110E1111F
000000001100102001130100 4010150110601117
00011010110001001 AC 4
Octal
Octal is sometimes used. Octal is base 8.
Changing between Octal and Binary is also simple. e.g.
00000011010201131004101511061117
010111001271
MemoryA contiguous list of bytes forms the memory within the computer. These bytes are indexed with binary addresses.
Larger amounts of memory are specified using the prefixes: K(kilo), M(mega), G(giga), and T(tera). These have different meanings from their standard scientific meaning.
Prefix Scientific ComputerK 103=1000 210=1024M 106=1000000 220=1048576G 109=1000000000 230=1073741824T 1012=1000000000000 240=1099511627776
Memory
These prefixes are used inconsistently within the computer industry.
For example:2 MB means 2×210 bytes
5 Mb /sec means 5×106 bits are transfered per second .
Interpretation of Binary InfoAn interpretation is placed upon a binary pattern. This gives the binary information meaning.
It is important that the intended interpretation is used on this information.
Consider the binary pattern:
01100001
If it was interpreted as an ASCII character then it would be the letter 'a'. However, if it is interpreted as an integer then it would be the number 97 !!!!
NonNegative
The nonnegative integers are the numbers 0,1,2,.... This is an infinite set and hence it can't be represented with a fixed sized binary pattern.
However, we can simply bound the integers represented.
A binary pattern can be interpreted as a binary number. e.g. 01100001 is 97.
A ProblemOne problem that often arises is determining what order to interpret the bit pattern. Is the first bit the least or most significant bit?
Also a question remains over the ordering of bytes when larger integers are considered.
It is important that there is consistency across all interpretations.
Fortunately the architecture/compiler does most of this work.
Integers
We also wish to be able to represent negative numbers.
A simple way of doing this is to use the first bit to indicate the sign of the number. With 0 meaning a positive number and 1 meaning that it is negative.
We end up with two zeros!
This wastes a bit pattern and makes equality more complex.
10001010−1000001001 900000000 010000000 0
Integers
The most common approach for representing negative numbers is twoscomplement.
The first bit also indicates that the number is negative.
To negate a number you "invert all bits and add one".
This removes the problem of multiple zeros.
0111 70110 60101 50100 40011 30010 20001 10000 01111−11110−21101−31100−41011−51010−61001−71000−8
Twoscomplement
The twoscomplement approach also simplifies arithmetic operations as an ordinary adder(operates on nonnegatives) will correctly handle negative numbers.
Often representations are selected to simplify computation.
00111011
1110
3−5−2
Floating Point NumbersFloating point numbers provided a way of approximating continuous/real numbers.
The binary pattern is divided up into two parts, the mantissa and the exponent. The exponent operates on the mantissa shifting it left or right.
This representation works in a similar way to that of scientific notation.
0.314×101
Mantissa ExponentSign
Floating Point Numbers
The IEEE Standard Double is 64 bits with a 52 bit mantissa and a 11 bit exponent.
If 'm' is the mantissa and 'e' is the exponent and 's' is the sign bit then the value of the floating point number is:
Rounding errors can often be introduced due to the inexact nature or floating point numbers.
V=−1s×1. m×2e−1024
ASCII
ASCII is the American Standard Code for Information Interchange. It is a 7 bit code.
See "man ascii".
The ISO 8859 standard includes several 8 bit extensions to the ASCII character set.
Boolean DataThe boolean data type is another basic data type within a computer system. A boolean variable is either "true" or "false".
The operations performed on booleans include: not, or, and, xor, ...
Booleans are central to conditional operations.
A single bit would be sufficient to capture a boolean, however, an entire word is often used given the way memory is used.
Other Interpretations
There are many other ways binary information is interpreted. These include: strings, records, arrays, list, images, sounds, etc.
Binary information does not have meaning in and of itself. It only has meaning when an interpretation is placed upon it.
Communication
We often wish to communicate binary information.
There are a number of important parameters which characterize the communication channel. These include:
Latency time to communicate empty package.
Transfer rate number of bits per second that can be transmitted for one message.
MeasuringThe simplest way of measuring the amount of binary information is to count the number of bytes. However, if a message contains the same information repeated over and over, it may be many bytes long, but contains only a small amount information.
Shannon and Weaver (1949) usedentropy to measure and amount of information in a communication channel.
00000000. ......000000001−0.99 lg 0.99−0.01 lg 0.01=0.081 bits /symbol
00110111. ......101011000−0.5 lg0.5−0.5 lg 0.5=1bit /symbol
Reading and Self Assessment
Chapter 1 (Required reading)
1.1, 1.2, 1.4, 1.5, 1.6, 1.7
Questions/Exercises (Students are encouraged to do all questions in the sections that are required reading. However, the list below give a set of questions to help you gain some feedback on how you are going. You are strongly encouraged to do these. Questions like this make good exam questions!)
1.1 : 1,6,7 (Note that we come back to this section in the next lecture.)
1.2 : 1,3. 1.4 : 1,3,5,6. 1.5 : 3,4. 1.6 : 1,2,5. 1.7 : 1,2.
Challenge
This challenge is just for fun.
Write the shortest program(you may use any language) that will output to standard out the following string:
01010101010101010101010101010101010101010101010101010101
How about this string?01101101011101011000001011101001100011010101101011110101