Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 1 Digital Computers and Information. CSC 480 – Winter 2002 Digital Computer Basics Digital values represented as voltage values, e.g. Logic 1.

Similar presentations


Presentation on theme: "Chapter 1 Digital Computers and Information. CSC 480 – Winter 2002 Digital Computer Basics Digital values represented as voltage values, e.g. Logic 1."— Presentation transcript:

1 Chapter 1 Digital Computers and Information

2 CSC 480 – Winter 2002 Digital Computer Basics Digital values represented as voltage values, e.g. Logic 1 is 4.0-5.0 V Logic 0 is 0.0-1.0 V Why digital? Why binary? Simplest Cheapest

3 CSC 480 – Winter 2002 A Generic Computer Memory = RAM, caches I/O = keyboard, terminal, hard disk CPU Datapath= performs basic instructions CPU = supervisor, flow MMU = memory management FPU = floating point specialist

4 CSC 480 – Winter 2002 Number Systems Radix r number represented as: A n-1... A 1 A 0. A -1 A -2... A -m Value is A n-1 r n-1 + A n-2 r n-2 +... A 1 r 1 + A 0 r 0 + A -1 r -1 +... A –m r -m Digit range: 0 - (r-1) A n-1 is the “most significant digit” A -m is the “least significant digit” Notation: (6342) 7 – use parens and subscript to indicate number base, in this case 7 4 common bases: 2 (binary), 8 (octal), 10 (decimal), 16 (hex)

5 CSC 480 – Winter 2002 Base R Wishlist We want to be able to “handle” radix R numbers, including: Decimal shortcut - Convert to decimal a number in any radix Power of 2 shortcut - Power of 2 conversions between binary, octal, and hex numbers General radix conversion - convert a number in radix R1 to radix R2 We also want to be able to perform the standard math operations

6 CSC 480 – Winter 2002 Convert to Decimal We use decimal (r=10), so conversion from other bases to decimal is common... Ex: Convert (43.2) 5 to decimal Trick: Just expand each digit. We know how to manipulate decimal numbers which makes this process “easy”. Ans: 4 * 5 + 3 * 1 + 2 *.2 = 23.4 Note 1: Conversion from decimal is handled by standard technique, no shortcut Note 2: We are lucky. We can easily convert to decimal to check our work!

7 CSC 480 – Winter 2002 Convert to Decimal, cont There is another way (shortcut?) called Horner’s rule (not in the text except as a homework problem W = a n-1 for i=n-2 to 0 by –1 w = w*r + a i Ex: Convert (2504) 6 to decimal 2 * 6 + 5 = 17 17 * 6 + 0 = 102 102 * 6 + 4 = 616 This is actually more efficient as well

8 CSC 480 – Winter 2002 Power of 2 Conversions The trick(s) Base 8 (octal) is Base 2 “cubed” 2 3 = 8 So, 3 bits equals one octal digit Base 16 (hex) is Base 2 to the 4 th power 2 4 = 16 So, 4 bits equals one hex digit Convert to Binary Ex: (743.2) 8 Expand each octal digit into its 3-bit value Ans: (111 100 010. 010) 2 Convert from Binary Ex: (10010101) 2 to hex Trick: Collapse each 4 bit group into its hex value Ans: (95) 16

9 CSC 480 – Winter 2002 General Conversion, cont. Don’t forget fractions Handle fractional parts separately Similar process as integer part, except multiply and use whole numbers, not remainders Ex. (0.625) 10 to binary 0.625 * 2 = 1.25, use 1 0.25 * 2 = 0.5, use 0 0.5 * 2 = 1.0, use 1 Answer is whole numbers in order: (101) 2 Again, you can check work in decimal.

10 CSC 480 – Winter 2002 General Number Conversion Trick: To convert to radix R, successively divide your number by R and the remainders are your converted value. Ex: Convert (169) 10 to octal 169 / 8 = 21 R1 21 / 8 = 2 R5 2 / 8 = 0 R2 Answer is reverse of remainders (251) 8 Check our work: (251) 8 = 2*8*8 + 5*8 + 1 = 169

11 CSC 480 – Winter 2002 Arithmetic Operations We want to add, subtract and multiply numbers of radix R Good news: Same basic rules as decimal math Bad news: Your decimal brain may rebel at the non-decimal carries, borrows, etc. More good news: Convert to decimal to verify your work

12 CSC 480 – Winter 2002 Adding Let’s add: (3A) 16 + (69) 16 Watch the carries! Carry value is now worth 16 (the base) Double check with decimal values

13 CSC 480 – Winter 2002 Subtracting Let’s subtract: (69) 16 - (3A) 16 Watch the borrows! Borrow value is now worth 16 (the base) Double check with decimal values

14 CSC 480 – Winter 2002 Multiplying Let’s multiply: (3A) 16 * (69) 16 Labor-intensive, error-prone with multiple steps

15 CSC 480 – Winter 2002 Binary-coded Decimals BCD = binary-coded decimal “Human” binary coding of decimal numbers Convert number one digit at a time: Ex: 17 = 0001 0111 BCD addition Add each digit separately Carry is “special” If sum for any digit >= 10, add 6 (0110) to sum to get proper BCD result Ex. 8 + 5 = 1000 + 0101 = 1101 (Add 0110!) = 0001 0011

16 CSC 480 – Winter 2002 Alphanumeric codes ASCII – encoding for alphanumeric data 7 bits long Covers a-z, A-Z, 0-9, !@#$ and many other special characters See table on page 21 for complete mapping 8 th bit often added for parity check Only for English-language characters

17 CSC 480 – Winter 2002 Chapter 1 Summary Most important: Generic computer & information Understand radix R number systems Radix conversion (general and shortcuts) Radix math operations BCD encoding and addition ASCII code basics


Download ppt "Chapter 1 Digital Computers and Information. CSC 480 – Winter 2002 Digital Computer Basics Digital values represented as voltage values, e.g. Logic 1."

Similar presentations


Ads by Google