17
Chapter 1 Digital Computers and Information

Chapter 1

Embed Size (px)

DESCRIPTION

Chapter 1. Digital Computers and Information. 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. A Generic Computer. Memory = RAM, caches I/O = keyboard, terminal, hard disk - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter 1

Chapter 1

Digital Computers and Information

Page 2: Chapter 1

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

Page 3: Chapter 1

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

Page 4: Chapter 1

CSC 480 – Winter 2002

Number Systems Radix r number represented as:

An-1 ... A1 A0 . A-1 A-2 ... A-m

Value is An-1rn-1 + An-2rn-2 + ... A1r1 + A0r0 + A-1r-1 + ... A–mr-m

Digit range: 0 - (r-1) An-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)

Page 5: Chapter 1

CSC 480 – Winter 2002

Base R WishlistWe 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

Page 6: Chapter 1

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!

Page 7: Chapter 1

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 = an-1

for i=n-2 to 0 by –1

w = w*r + ai

Ex: Convert (2504)6 to decimal2 * 6 + 5 = 1717 * 6 + 0 = 102

102 * 6 + 4 = 616 This is actually more efficient as well

Page 8: Chapter 1

CSC 480 – Winter 2002

Power of 2 ConversionsThe trick(s)

Base 8 (octal) is Base 2 “cubed”

23 = 8 So, 3 bits equals one octal digit

Base 16 (hex) is Base 2 to the 4th power

24 = 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

Page 9: Chapter 1

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 10.25 * 2 = 0.5, use 00.5 * 2 = 1.0, use 1Answer is whole numbers in order:

(101)2

Again, you can check work in decimal.

Page 10: Chapter 1

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 octal169 / 8 = 21 R121 / 8 = 2 R52 / 8 = 0 R2

Answer is reverse of remainders (251)8

Check our work:

(251)8 = 2*8*8 + 5*8 + 1 = 169

Page 11: Chapter 1

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

Page 12: Chapter 1

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

Page 13: Chapter 1

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

Page 14: Chapter 1

CSC 480 – Winter 2002

Multiplying Let’s multiply:(3A)16 * (69)16

Labor-intensive, error-prone with multiple steps

Page 15: Chapter 1

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

Page 16: Chapter 1

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 8th bit often added for parity check Only for English-language characters

Page 17: Chapter 1

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