what is a computer? a computer is a device that: –accepts input –processes data –stores data...

42
What is a computer? What is a computer? A computer is a device that: A computer is a device that: Accepts input Accepts input Processes data Processes data Stores data Stores data Produces output Produces output Let’s examine components in more Let’s examine components in more detail… detail…

Upload: jessica-burns

Post on 01-Jan-2016

221 views

Category:

Documents


2 download

TRANSCRIPT

What is a computer?What is a computer?

A computer is a device that:A computer is a device that:– Accepts inputAccepts input– Processes dataProcesses data– Stores dataStores data– Produces outputProduces output

Let’s examine components in more Let’s examine components in more detail…detail…

What is a computer?What is a computer?

A computer is a device that:A computer is a device that:– Accepts input: Accepts input: Input devicesInput devices

Name as many as you can:Name as many as you can:

What is a computer?What is a computer?

A computer is a device that:A computer is a device that:– Accepts input: Accepts input: Input devicesInput devices

Name as many as you can:Name as many as you can:

Keyboard, mouse, scanner, bar code Keyboard, mouse, scanner, bar code reader, light pen, infrared sensor, reader, light pen, infrared sensor, video camera and many more…video camera and many more…

What is a computer?What is a computer?

A computer is a device that:A computer is a device that:– Processes data: Processes data: ProcessorsProcessors

Name as many as you can:Name as many as you can:

What is a computer?What is a computer?

A computer is a device that:A computer is a device that:– Processes data: Processes data: ProcessorsProcessors

Name as many as you can:Name as many as you can:

CPU, graphics processor, video controller, CPU, graphics processor, video controller, modem, and many more…modem, and many more…

What is a computer?What is a computer?

A computer is a device that:A computer is a device that:– Stores data: Stores data: Storage devicesStorage devices

Name as many as you can:Name as many as you can:

What is a computer?What is a computer?

A computer is a device that:A computer is a device that:– Stores data: Stores data: Storage devicesStorage devices

Name as many as you can:Name as many as you can:

Main memory, hard drive, CD-ROM, DVD-Main memory, hard drive, CD-ROM, DVD-ROM, memory card, tape drive, ZIP disk, ROM, memory card, tape drive, ZIP disk, floppy disk, floppy disk,

What is a computer?What is a computer?

A computer is a device that:A computer is a device that:– Produces output: Produces output: Output devicesOutput devices

Name as many as you can:Name as many as you can:

What is a computer?What is a computer?

A computer is a device that:A computer is a device that:– Produces output: Produces output: Output devicesOutput devices

Name as many as you can:Name as many as you can:

Monitor, printer, speaker, indicator light, and Monitor, printer, speaker, indicator light, and many more…many more…

Data RepresentationData RepresentationA computer is a device that:A computer is a device that:

– Accepts inputAccepts input– Processes dataProcesses data– Stores dataStores data– Produces outputProduces output

Input data transformed into Input data transformed into output.output.

Data can be stored for repeated Data can be stored for repeated output.output.

Data RepresentationData Representation

Spreadsheet data Spreadsheet data graphs graphs

3D models 3D models animation animation

Vocals and MIDI Vocals and MIDI Song Song

Bar code Bar code Price of item Price of item

Card and Pin # Card and Pin # Money from ATM Money from ATM

Data Representation Data Representation

How can we represent How can we represent information in a way that can be information in a way that can be stored and manipulated by a stored and manipulated by a computer?computer?

Data Representation Data Representation and Storageand Storage External representation: External representation:

computers use decimal digits computers use decimal digits (base ten), 26-character alphabet (base ten), 26-character alphabet for easier human interaction via for easier human interaction via keyboard, terminal, printerkeyboard, terminal, printer

Internal representation: Internal representation: computers use binary system for computers use binary system for numbers, letters, graphics, etc.numbers, letters, graphics, etc.

Data RepresentationData Representation

Internally, computers represent Internally, computers represent information as patterns of information as patterns of bitsbits

A A bitbit (binary digit) is either 0 or 1; (binary digit) is either 0 or 1; these are symbols and have no these are symbols and have no numeric meaningnumeric meaning

Storing a bit requires that a device Storing a bit requires that a device can be in one (and only one) of just can be in one (and only one) of just two states; analogous to true and two states; analogous to true and falsefalse

Bit StorageBit Storage

Why only two states? Why not use Why only two states? Why not use ten states to correspond with the ten states to correspond with the base ten numbering system?base ten numbering system?

Data RepresentationData Representation

Binary Numbers!!!Binary Numbers!!!

Sound Sound pitch pitch number number binary number binary number

Letter Letter number number binary number binary number

ImageImage color at each pixel color at each pixel number number binary numberbinary number

Decimal Number Decimal Number SystemsSystems

Base 10Base 10 Digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9Digits - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 e.g. 342e.g. 3421010 = =

= 3 x 10= 3 x 1022 + 4 x 10 + 4 x 1011 + 2 + 2 x10x1000

= 3 x 100 + 4 x 10 + 2 = 3 x 100 + 4 x 10 + 2 x 1x 1

= 300 + 40 + 2= 300 + 40 + 2

Binary Number SystemBinary Number System

Base 2Base 2 Digits 0, 1Digits 0, 1 e.g. 110e.g. 1102 2 ==

= 1 x 2= 1 x 222 + 1 x 2 + 1 x 211 + 0 x 2 + 0 x 200

= 1 x 4 + 1 x 2 + 0 x = 1 x 4 + 1 x 2 + 0 x 11

= 4 + 2 + 0= 4 + 2 + 0

= 6= 6

Counting in BinaryCounting in Binary

DecimalDecimalBinaryBinary

0 00 0

1 11 1

2 102 10

3 113 11

4 1004 100

5 1015 101

DecimalBinary

6 110

7 111

8 1000

9 1001

10 1010

11 1011

Place and valuePlace and value

In a decimal number, each place value In a decimal number, each place value is 10 times greater than the place to is 10 times greater than the place to its right.its right.

In a binary number, each place value is In a binary number, each place value is 2 times greater than the place to its 2 times greater than the place to its right.right.

For convenience, we group every four For convenience, we group every four binary bits into a hexdecimal digit (1-9, binary bits into a hexdecimal digit (1-9, A,B,C,D,E,F)A,B,C,D,E,F)

In a hexdecimal number, each place In a hexdecimal number, each place value is 16 times greater than the value is 16 times greater than the place to its right.place to its right.

Binary NumeralsBinary Numerals

0110110101101101– Bits are numbered from the right Bits are numbered from the right

bb7 7 bb66bb55bb44bb33bb22bb11bb00

– Subscripts represent the place valueSubscripts represent the place value bbi i has place value 2has place value 2ii

– Convert to decimalConvert to decimal bb77 * 2 * 277+b+b66*2*26 6 + b+ b55*2*25 5 +b+b44*2*24 4 +b+b33*2*23 3

+b+b22*2*22 2 +b+b11*2*21 1 + b+ b00*2*200

Data RepresentationData Representation

101000 = 1 * 2 = 1 * 222 + 0 * 2 + 0 * 211 + + 00 1100 = 1 * 2 = 1 * 211 + + 00

11

Data RepresentationData Representation

Binary to Decimal Binary to Decimal

10011 10011 = 1 * 2 = 1 * 244 + 0 * 2 + 0 * 233 + 0 * 2 + 0 * 222 + 1* 2 + 1* 211 + 1 * 2+ 1 * 200

Data RepresentationData Representation

Binary to Decimal Binary to Decimal

10011 10011 = 1 * 2 = 1 * 244 + 0 * 2 + 0 * 233 + 0 * 2 + 0 * 222 + 1* 2 + 1* 211 + 1 * + 1 * 2200

= 16 + 0 + 0 + 2 + 1 = 16 + 0 + 0 + 2 + 1 = 19 = 19

ExcerciseExcercise

1011b = ?d1011b = ?d

Addition Addition

1000 + 1 =?1000 + 1 =? 0011 + 0010 =0011 + 0010 =

4 bits and Hex 4 bits and Hex

– 0000 ;00000 ;0

– 0001 ;10001 ;1

– 0010 ;20010 ;2

– 0011 ;30011 ;3

– 0100 ;40100 ;4

– 0101 ;50101 ;5

– 0110 ;60110 ;6

– 0111 ;70111 ;7

– 1000 ;81000 ;8

– 1001 ;91001 ;9

– 1010 ;10 (Ah)1010 ;10 (Ah)

– 1011 ;11 (Bh)1011 ;11 (Bh)

– 1100 ;12 (Ch)1100 ;12 (Ch)

– 1101 ;13 (Dh)1101 ;13 (Dh)

– 1110 ;14 (Eh)1110 ;14 (Eh)

– 1111 ;15 (Fh)1111 ;15 (Fh)

Converting Binary to Converting Binary to DecimalDecimal

Another method: repeatedly multiply Another method: repeatedly multiply by 2 and add next bitby 2 and add next bit

e.g. 110101e.g. 110101

0 x 2 = 0 + 1 = 10 x 2 = 0 + 1 = 1

1 x 2 = 2 + 1 = 31 x 2 = 2 + 1 = 3

3 x 2 = 6 + 0 = 63 x 2 = 6 + 0 = 6

6 x 2 = 12 + 1 = 136 x 2 = 12 + 1 = 13

13 x 2 = 26 + 0 = 2613 x 2 = 26 + 0 = 26

26 x 2 = 52 + 1 = 5326 x 2 = 52 + 1 = 53

Converting Decimal to Converting Decimal to BinaryBinary

Repeatedly divide by 2, recording Repeatedly divide by 2, recording remainders in reverse orderremainders in reverse order

e.g. 53 / 2 = 26 R 1e.g. 53 / 2 = 26 R 1

26 / 2 = 13 R 026 / 2 = 13 R 0

13 / 2 = 6 R 113 / 2 = 6 R 1

6 / 2 = 3 R 06 / 2 = 3 R 0

3 / 2 = 1 R 13 / 2 = 1 R 1

1 / 2 = 0 R 11 / 2 = 0 R 1

giving 110101giving 110101

Data RepresentationData Representation

use a fixed number of digits.use a fixed number of digits.

But how many bits do we need?But how many bits do we need?

1 binary digit 1 binary digit 0 or 1 0 or 1 2 possible chars 2 possible chars

2 binary digits 2 binary digits 00, 01, 10, 11 00, 01, 10, 11 4 chars 4 chars

3 binary digits 3 binary digits 000, 001, 010, 011, 100, 000, 001, 010, 011, 100, 101, 110, 111 101, 110, 111 8 chars 8 chars

Data RepresentationData Representation

Solution: use a fixed number of digits.Solution: use a fixed number of digits.

But how many bits do we need?But how many bits do we need?

1 binary digit 1 binary digit 0 or 1 0 or 1 2 possible chars 2 possible chars

2 binary digits 2 binary digits 00, 01, 10, 11 00, 01, 10, 11 4 chars 4 chars

3 binary digits 3 binary digits 000, 001, 010, 011, 100, 101, 110, 111 000, 001, 010, 011, 100, 101, 110, 111 8 chars 8 chars

Notice a pattern? 1Notice a pattern? 12, 22, 24, 34, 38, …8, …the total number of character that can be represented the total number of character that can be represented

by n bits isby n bits is

22nn

Number of bitsNumber of bits

How many states can be How many states can be represented with 1 bits, 2 bits, 3 represented with 1 bits, 2 bits, 3 bits, 8 bits ….bits, 8 bits ….

To represent N states, how many To represent N states, how many bits are needed.bits are needed.

Data RepresentationData Representation

But how many bits are needed to store But how many bits are needed to store n n symbols?symbols?

Or, how many bits are needed to represent n Or, how many bits are needed to represent n numbers?numbers?

loglog22nn

Character Character RepresentationRepresentation 1 byte = 8 bits = 1 character?1 byte = 8 bits = 1 character? 256 possible codes with 8 bits256 possible codes with 8 bits Assign a character to each codeAssign a character to each code Common assignmentCommon assignment

– ASCII - American Standard Code for ASCII - American Standard Code for Information Interchange – defines Information Interchange – defines first 128first 128

ASCII CodeASCII CodeCode ValueCode Value LetterLetter

00 Null characterNull character

1 - 311 - 31 Special Control CharactersSpecial Control Characters

1010 \n = New line\n = New line

3232SpaceSpace

33-47, 58-64, 91-9633-47, 58-64, 91-96 PunctuationPunctuation

48 - 5748 - 57 0 - 90 - 9

65 - 9065 - 90 A - ZA - Z

97 - 122 97 - 122 a - za - z

Interesting ASCII Interesting ASCII Choice?Choice? Digits 0 through 9 seem strange?Digits 0 through 9 seem strange?

DigitDigit DecDec HexHex

00 48 48 30 30 1 1 49 49 31 31

… … …… … …

99 57 57 39 39

Data RepresentationData Representation AAmerican merican SStandard tandard CCode for ode for IInformation nformation IInterchange nterchange

(ASCII ) defines 256 symbols that can be stored in a (ASCII ) defines 256 symbols that can be stored in a byte. Each symbol corresponds to a number frombyte. Each symbol corresponds to a number from0 -- 2550 -- 255

SymbolSymbol DecimalDecimal BinaryBinary

@@ 6464 0100000001000000

AA 6565 0100000101000001

BB 6666 0100001001000010

CC 6767 0100001101000011

DD 6868 0100010001000100

EE 6969 0100010101000101

FF 7070 0100011001000110

GG 7171 0100011101000111

HH 7272 0100100001001000

UnicodeUnicode

International language coding International language coding standardstandard

Superset of ASCIISuperset of ASCII Various codes defined to use Various codes defined to use

upper 128 bits for symbols and upper 128 bits for symbols and other languagesother languages

Memory SizesMemory Sizes

Byte = 8 bitsByte = 8 bits Kilobyte (K) = 2Kilobyte (K) = 21010 = 1,024 bytes = 1,024 bytes Megabyte (Mb) = 2Megabyte (Mb) = 22020 = 1,048,576 = 1,048,576

bytesbytes Gigabyte (Gb) = 2Gigabyte (Gb) = 23030 = =

1,073,741,824 bytes1,073,741,824 bytes

16-bit Memory Word16-bit Memory Word

To store number 6, use To store number 6, use 00000000000001100000000000000110

Value 0 is 0000000000000000Value 0 is 0000000000000000

Largest value is Largest value is 1111111111111111 = 65,535 = 21111111111111111 = 65,535 = 21616 −− 1 1

32-bit word gives largest value > 4 billion32-bit word gives largest value > 4 billion