Presentation is loading. Please wait.

Presentation is loading. Please wait.

CDA 3100 Fall 2011. Special Thanks Thanks to Dr. Xiuwen Liu for letting me use his class slides and other materials as a base for this course.

Similar presentations


Presentation on theme: "CDA 3100 Fall 2011. Special Thanks Thanks to Dr. Xiuwen Liu for letting me use his class slides and other materials as a base for this course."— Presentation transcript:

1 CDA 3100 Fall 2011

2 Special Thanks Thanks to Dr. Xiuwen Liu for letting me use his class slides and other materials as a base for this course

3 6/23/2016CDA31003 About Me 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.

4 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

5 6/23/2016CDA31005 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 scientist

6 6/23/2016CDA31006 Career Potential for a Computer Science Graduate http://www.jobweb.com/studentarticles.asp x?id=904&terms=starting+salary

7 6/23/2016CDA31007 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)

8 Required Background Based on years of teaching this course, I find that you will suffer if you do not have the required C/C++ programming background. We will need assembly coding, which is more advanced than C/C++. If you do not have a clear understanding at this moment of array and loop, it is recommended that you take this course at a later time, after getting more experience with C/C++ programming.

9 Array – What Happens? #include int main (void) { int A[5] = {16, 2, 77, 40, 12071}; A[A[1]] += 1; return 0; }

10 Loop – What Happens? #include int main () { int A[5] = {16, 20, 77, 40, 12071}; int result = 0; int i = 0; while (result < A[i]) { result += A[i]; i++; } return 0; }

11 6/23/2016CDA310011 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 Blackboard will be used for posting the grades

12 6/23/2016CDA310012 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

13 6/23/2016CDA310013 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

14 6/23/2016CDA310014 Decimal Numbering System We humans naturally use a particular numbering system

15 6/23/2016CDA310015 Decimal Numbering System For any nonnegative integer, its value is given by – Here d 0 is the least significant digit and d n is the most significant digit

16 6/23/2016CDA310016 General Numbering System – Base X Besides 10, we can use other bases as well – In base X, – Then, the base X representation of this number is defined as d n d n-1 …d 2 d 1 d 0. – The same number can have many representations on many bases. For 23 based 10, it is 23 ten 10111 two 17 sixteen, often written as 0x17. –

17 6/23/2016CDA310017 Commonly Used Bases – Note that other bases are used as well including 12 and 60 Which one is natural to computers? – Why? BaseCommon NameRepresentationDigits 10Decimal5023 ten or 50230-9 2Binary1001110011111 two 0-1 8Octal11637 eight 0-7 16Hexadecimal139F hex or 0x139F0-9, A-F

18 6/23/2016CDA310018 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 http://www.math.ualberta.ca/~runde/jokes.html

19

20 Question How many different numbers that can be represented by 4 bits? Always 16 (2 4 ), because there are this number of different combinations with 4 bits, regardless of the type of the number these 4 bits are representing. Obviously, this also applies to other number of bits. With n bits, we can represent 2 n different numbers. If the number is unsigned integer, it is from 0 to 2 n -1.

21 6/23/2016CDA310021 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?

22 6/23/2016CDA310022 Conversion Between Bases From binary to decimal example 1514131211109876543210 2 15 2 14 2 13 2 12 2 11 2 10 2929 2828 2727 2626 2525 2424 23232 2121 2020 0001001110011111

23 Converting from binary to decimal Converting from binary to decimal. This conversion is also based on the formula: d = d n-1 2 n-1 + d n-2 2 n-2 +…+ d 2 2 2 + d 1 2 1 + d 0 2 0 while remembering that the digits in the binary representation are the coefficients. For example, given 101011 two, in decimal, it is 2 5 + 2 3 + 2 1 + 2 0 = 43.

24 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. QuotientRemainder 51 21 10 01

25 Digging a little deeper Why can a binary number be obtained by keeping on dividing by 2, and why should the last remainder be the first bit? Note that – Any integer can be represented by the summation of the powers of 2: d = d n-1 2 n-1 + d n-2 2 n-2 +…+ d 2 2 2 + d 1 2 1 + d 0 2 0 – For example, 19 = 16 + 2 + 1 = 1 * 2 4 + 0 * 2 3 + 0 * 2 2 + 1 * 2 1 + 1 * 2 0. – The binary representation is the binary coefficients. So 19 ten in binary is 10011 two.

26 Digging a little deeper In fact, any integer can be represented by the summation of the powers of some base, where the base is either 10, 2 or 16 in this course. For example, 19 = 1 * 10 1 + 9 * 10 0. How do you get the 1 and 9? You divide 19 by 10 repeatedly until the quotient is 0, same as binary! In fact, the dividing process is just an efficient way to get the coefficients. How do you determine whether the last bit is 0 or 1? You can do it by checking whether the number is even or odd. Once this is determined, you go ahead to determine the next bit, by checking ( d - d 0 2 0 )/2 is even or odd, and so on, until you don’t have to check any more (when the number is 0).

27 Conversion between Base 16 and Base 2 Extremely easy. – From base 2 to base 16: divide the digits in to groups of 4, then apply the table. – From base 16 to base 2: replace every digit by a 4- bit string according to the table. Because 16 is 2 to the power of 4.

28 Addition in binary 39 ten + 57 ten = ? How to do it in binary?

29 Addition in Binary First, convert the numbers to binary forms. We are using 8 bits. – 39 ten -> 00100111 2 – 57 ten -> 00111001 2 Second, add them. 00100111 00111001 01100000

30 Addition in binary The addition is bit by bit. We will run in at most 4 cases, where the leading bit of the result is the carry: 1.0+0+0=00 2.1+0+0=01 3.1+1+0=10 4.1+1+1=11

31 Subtraction in Binary 57 ten – 39 ten = ?

32 Subtraction in Binary 00111001 00100111 00010010

33 Subtraction in binary Do this digit by digit. No problem if – 0 - 0 = 0, – 1 - 0 = 1 – 1 – 1 = 0. When encounter 0 - 1, set the result to be 1 first, then borrow 1 from the next more significant bit, just as in decimal. – Borrow means setting the borrowed bit to be 0 and the bits from the bit following the borrowed bit to the bit before the current bit to be 1. – Think about, for example, subtracting 349 from 5003 (both based 10). The last digit is first set to be 4, and you will be basically subtracting 34 from 499 from now on.


Download ppt "CDA 3100 Fall 2011. Special Thanks Thanks to Dr. Xiuwen Liu for letting me use his class slides and other materials as a base for this course."

Similar presentations


Ads by Google