CDA 3100 Fall2009
Special Thanks
• Thanks to Dr. Xiuwen Liu for letting me use his class slides and other materials as a base for this course
05/03/23 CDA3100 3
Class organization
• My name is Zhenghao Zhang– Why I am teaching this course: I worked for two
years as an embedded system engineer, writing codes for embedded controllers.
• Class web page– http://www.cs.fsu.edu/~zzhang/CDA3100_Fall_20
09.htm
05/03/23 CDA3100 4
Class Communication
• This class will use class web site to post news, changes, and updates. So please check the class website regularly
• Please also make sure that you check your emails on the account on your University record
05/03/23 CDA3100 5
Required Textbook
• The required textbook for this class is – “Computer Organization and Design”
• The hardware/software interface
– By David A. Patterson and John L. Hennessy– Fourth Edition
05/03/23 CDA3100 6
Lecture Notes and Textbook• All the materials that you will be tested on will be
covered in the lectures
– Even though you may need to read the textbook for review and further detail explanations
– The lectures will be based on the textbook and handouts distributed in class
What you will learn to answer (among other things)
• How does the software instruct the hardware to perform the needed functions
• What is going on in the processor • How a simple processor is designed
05/03/23 CDA3100 8
Why This Class Important?• If you want to create better computers
– It introduces necessary concepts, components, and principles for a computer scientist
– By understanding the existing systems, you may create better ones
• If you want to build software with better performance
• If you want to have a good choice of jobs• If you want to be a real computer science major
05/03/23 CDA3100 9
Career Potential for a Computer Science Graduate
http://www.jobweb.com/studentarticles.aspx?id=904&terms=starting+salary
05/03/23 CDA3100 10
Career Potential for a Computer Science Graduate
Source: NACE Fall 2005 Report (http://www.jobweb.com/resources/library/Careers_In/Starting_Salary_51_01.htm)
05/03/23 CDA3100 11
Computer System Overview
• A computer system consists of hardware and software that are combined to provide a tool to solve problems (with best performance)– Hardware includes CPU, memory, disks, screen,
keyboard, mouse ...– Software includes
• System software – A general environment to create specific applications
• Application software– A tool to solve a specific problem
05/03/23 CDA3100 12
Steps to Run a C Program – First, compiling it into machine code
05/03/23 CDA3100 13
Steps to Run a C Program• Then we need to run the program
– The operating system locates where the program is
– Then it loads the program into memory– The instructions in the program are then executed
one by one– When the program is done, the operating system
then releases the memory and other resources allocated to the program
05/03/23 CDA3100 14
Opening the Box
05/03/23 CDA3100 15
A Pentium 4 Processor Chip
05/03/23 CDA3100 16
Numbers• Numbers are abstraction of quantities
– http://www.debtclock.com/– How do we represent these quantities?
05/03/23 CDA3100 17
Decimal Numbering System• We humans naturally use a particular numbering system
05/03/23 CDA3100 18
Decimal Numbering System• For any nonnegative integer , its
value is given by
– Here d0 is the least significant digit and dn is the most significant digit
011 dddd nn
011
00
11
11
0
10)10)10)100((((
1010101010
dddd
ddddd
nn
nn
nn
n
i
ii
05/03/23 CDA3100 19
General Numbering System – Base X
• Besides 10, we can use other bases as well– In base X, the value of 011 dddd nn
011
00
11
11
0
)))0(((( dXdXdXdX
XdXdXdXdXd
nn
nn
nn
n
i
ii
05/03/23 CDA3100 20
Commonly Used Bases
– Note that other bases are used as well including 12 and 60
• Which one is natural to computers?– Why?
Base Common Name Representation Digits
10 Decimal 5023ten or 5023 0-9
2 Binary 1001110011111two 0-1
8 Octal 11637eight 0-7
16 Hexadecimal 139Fhex or 0x139F 0-9, A-F
05/03/23 CDA3100 21
Meaning of a Number Representation
• When we specify a number, we need also to specify the base– For example, 10 presents a different quantity in a
different base•
– There are 10 kinds of mathematicians. Those who can think binarily and those who can't... http://www.math.ualberta.ca/~runde/jokes.html
05/03/23 CDA3100 23
Conversion between Representations
• Now we can represent a quantity in different number representations– How can we convert a decimal number to binary?– How can we then convert a binary number to a
decimal one?
05/03/23 CDA3100 24
Conversion Between Bases
• From binary to decimal example15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
215 214 213 212 211 210 29 28 27 26 25 24 23 22 21 20
0 0 0 1 0 0 1 1 1 0 0 1 1 1 1 1
50231248161282565124096
222222222 0123478912
Conversion Between Bases
• Converting from decimal to binary: – given a number in decimal, repeatedly divide it by
2, and write down the remainder from right to the left, until the quotient is 0
– Example: 11. Quotient Remainder
5 1
2 1
1 0
0 1
05/03/23 CDA3100 26
Signed Numbers• How to represent negative numbers?
– Sign and magnitude• We use an additional bit to represent the sign of the
number– If the sign bit is 1, it represents a negative number– If the sign bit is 0, it represents a positive number
• How about zero then?• There are other shortcomings of this representation
– Related to the hardware implementation of adders– An extra step is required in general to set the sign since the
proper sign can not be determined in advance
• It is not widely used for integer representations
05/03/23 CDA3100 27
Signed Numbers• Two’s complement
– The negative of a two’s complement is given by inverting each bit from 0 to 1 and 1 to 0 and then adding 1
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 0 0 1 1 1 0 0 1 1 1 1 1
1 1 1 0 1 1 0 0 0 1 1 0 0 0 0 1
2’s complement
• In any computer, if numbers are represented in n bits, the non-negative numbers are from 0000…00 to 0111…11, the negative numbers are from 1000…00 to 1111…11.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0ten
1ten
2ten
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
… …
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
… …
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 -3ten
-2ten
-1ten
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1• The positive half from 0 to 2,147,483,647
• The negative half from -2,147,483,648 to -1
05/03/23 CDA3100 30
Two’s Complement Representation
• Properties– All negative numbers have a 1 in the most
significant bit• Hardware only needs to test this bit to see if a number
is positive or negative• The leading bit is often called the sign bit
– For , the decimal value is 011 dddd nn
Why use 2’s complement? • For example, consider 01101 +(– 00011) = 01101 – 00011 = 01010 (13-3=10 in
decimal). • 01101 – 00011 = 01101 + 100000 – 00011 – 100000
= 01101 + (100000 – 00011) – 100000 = 01101 + 11101 – 100000
= 101010 – 100000 = 01010
• 11101 is the 2’s complement of 00011.• Means that computer (the adder) does not have to be specifically redesigned for
dealing with negative numbers, make life easier for the computer • The reason is, assume you are subtracting a with b , where 2^{n}>a>b>0. Note
that a-b=a+2^{n+1}-b-2^{n+1}. But 2^{n+1}-b is the 2’s complement of b. Also note that 2^{n}>a-b>0. So if represented in binary forms, a+2^{n+1}-b will be having a 1 bit in bit n+1 and some thing in bit 0 to bit n-1 equal to a-b. Bit n will be 0. So you take what is in bit 0 to bit n and it must be a-b.
Top Related