Digital Computers and Information n Digital computers n

  • Slides: 23
Download presentation
Digital Computers and Information n Digital computers n Number representations n Arithmetic operations n

Digital Computers and Information n Digital computers n Number representations n Arithmetic operations n Alphanumeric codes Read MK 3 -26

What’s in a Computer? Graphics Card monitor keyboard microprocessor FPU MMU CPU Internal Cache

What’s in a Computer? Graphics Card monitor keyboard microprocessor FPU MMU CPU Internal Cache Microprocessor • Central Processing Unit • Floating Point Unit • Memory Mgmt. Unit • Internal Cache Memory 1. 2 - Jon Turner - 12/26/2021 Network Interface Disk Controller Peripheral Bus Interface External Cache Main Memory • stores running programs and associated data • typically 64 -512 Mbytes • Dynamic RAM

What’s in a Computer? Graphics Card monitor keyboard microprocessor FPU MMU CPU Internal Cache

What’s in a Computer? Graphics Card monitor keyboard microprocessor FPU MMU CPU Internal Cache External Cache • small, fast memory • stores recently used data 1. 3 - Jon Turner - 12/26/2021 Network Interface Disk Controller Peripheral Bus Interface External Cache Memory Bus Control movement of data between memory and I/O devices Main Memory

What’s in a Computer? Transfer data between Peripheral Bus Graphics Card monitor keyboard Convert

What’s in a Computer? Transfer data between Peripheral Bus Graphics Card monitor keyboard Convert text & graphics to video 1. 4 - Jon Turner - 12/26/2021 microprocessor FPU MMU CPU Internal cache Network Interface Peripheral Bus Interface External Cache external network & memory Disk Controller Read/write data on proper physical location on disk Main Memory

What’s in a Chip? Intel 80286 Microprocessor (www. micro. magnet. fsu. edu/chipshots) NEC/MIPS R

What’s in a Chip? Intel 80286 Microprocessor (www. micro. magnet. fsu. edu/chipshots) NEC/MIPS R 4400 Microprocessor (www. micro. magnet. fsu. edu/chipshots) n Photomicrographs made using colored filters. 1. 5 - Jon Turner - 12/26/2021

Basic Processor & Memory Processor PC 10 Instruction Decoder n Memory ACC Memory 50

Basic Processor & Memory Processor PC 10 Instruction Decoder n Memory ACC Memory 50 Arithmetic & Logic Unit stores programs and data. Address read/write Address Decode Data » organized as set of numbered storage slots » each storage slot (memory word) can hold a number » processor can read from or write to any word n Fetch & execute cycle 0 1 2 3. . . ffff » read word whose address is in Program Counter (PC) and increment PC » interpret stored value as instruction (decoding) » perform instruction using Accumulator (ACC) and Arithmetic & Logic Unit (ALU) 1. 6 - Jon Turner - 12/26/2021 11 21 -3 65 56

Instruction Set 0000 halt - halt execution 0001 negate - ACC : = -ACC

Instruction Set 0000 halt - halt execution 0001 negate - ACC : = -ACC 1 xxx immediate load – if sign bit of xxx is 0 then ACC : = 0 xxx else ACC : = fxxx 2 xxx direct load - ACC : = M[0 xxx] 3 xxx indirect load - ACC : = M[M[0 xxx]] 4 xxx direct store - M[0 xxx] : = ACC 5 xxx indirect store – M[M[0 xxx]] : = ACC 6 xxx branch - PC : = 0 xxx 7 xxx branch if zero - if ACC = 0 then PC : = 0 xxx 8 xxx branch if positive - if ACC > 0 then PC : = 0 xxx 9 xxx branch if negative - if ACC < 0 then PC : = 0 xxx add - ACC : = ACC + M[0 xxx] 1. 7 - Jon Turner - 12/26/2021

Simple Program n Add the values in locations 20 -2 f and write sum

Simple Program n Add the values in locations 20 -2 f and write sum in 10. Address Instruction Comment 0000 (start)1000 (ACC : = 0000) initialize sum 0001 4010 (M[0010] : = ACC) 0002 1020 (ACC : = 0020) initialize pointer 0003 4011 (M[0011] : = ACC) 0004 (loop) 1030 (ACC : = 0030) if pointer = 030, quit 0005 0001 (ACC : = -ACC) 0006 a 011 (ACC : =ACC+M[0011]) 0007 700 f (if 0 goto 000 f) 0008 3011 (M[M[0011]] : = ACC) sum = sum + *pointer 0009 a 010 (ACC : =ACC+M[0010]) 000 a 4010 (M[0010] : = ACC) 000 b 1001 (ACC : = 0001) pointer = pointer + 1 000 c a 011 (ACC : =ACC+M[0011]) 000 d 4011 (M[011] : = ACC) 000 e 6004 (goto 0004) goto loop 000 f (end) 0000 (halt) halt 0010 Store sum here 0011 Pointer to next value 1. 8 - Jon Turner - 12/26/2021

Representing Information in Computers n Electronic computers represent information as voltage levels. n To

Representing Information in Computers n Electronic computers represent information as voltage levels. n To make the computer hardware simple and reliable, computers represent information in binary form. » example: voltages greater than 3 V are interpreted as representing one value (called “ 1”), voltages less than 2 V are interpreted as representing another value (called “ 0”). n In principle, could use more voltage levels. » example: 0 to. 75 V represents “ 0”, 1 to 1. 75 V represents “ 1”, 2 to 2. 75 V represents “ 2”, and so forth. n In practice, this is rarely done. » requires more complex circuits » circuits are more susceptible to noise, hence less reliable 1. 9 - Jon Turner - 12/26/2021

Noise in Computer Systems n Computers, like all electronic systems, are affected by noise.

Noise in Computer Systems n Computers, like all electronic systems, are affected by noise. » noise has various sources (nearby signal changes, thermal vibrations of molecules in semiconductor materials, . . . ) » in computers, noise can cause binary signals to be misinterpreted n The noise margin is the amount of noise that a system can tolerate and still correctly identify a logic high or low. 5 v High 4 v High 3 v Undefined 2 v Undefined 1 v Low noise margin 3 V 1. 10 - Jon Turner - 12/26/2021 Low 0 v noise margin 1 V

Number Representation n Standard decimal number representation 243. 83 = 2´ 102 + 4´

Number Representation n Standard decimal number representation 243. 83 = 2´ 102 + 4´ 101 + 3´ 100 + 8´ 10 -1 + 3´ 10 -2 n Generalization to base r An. . . A 1 A 0. A-1. . . A-m =An´rn +. . . + A 1´r 1 +A 0´r 0 + A-1´r-1 +. . . + A-m´r-m n Binary number representation 110. 01 = 1´ 22 + 1´ 21 + 0´ 20 + 0´ 2 -1 + 1´ 2 -2 n Converting binary numbers to decimal (easy). write binary expansion, replace powers of 2 with decimal values, and add up the values 110. 01 = 1´ 22 + 1´ 21 + 0´ 20 + 0´ 2 -1 + 1´ 2 -2 = 4 + 2 + 1/4 = 6. 25 Note: it helps to know your powers of 2 (hint) 1. 11 - Jon Turner - 12/26/2021

Decimal-Binary Conversion n Repeated division by 2 625/2 = 312/2 = 156/2 = 78

Decimal-Binary Conversion n Repeated division by 2 625/2 = 312/2 = 156/2 = 78 78/2 = 39 39/2 = 19 19/2 = 9 9/2 = 4 4/2 = 2 2/2 = 1 1/2 = 0 with remainder of 1 with remainder of 0 with remainder of 1 with remainder of 0 with remainder of 1 least significant bit So, (625)10 = (10 0111 0001)2 n Works similarly for other number bases. 1. 12 - Jon Turner - 12/26/2021

Octal and Hexadecimal n Octal (base 8) and hexadecimal (base 16) provide more convenient

Octal and Hexadecimal n Octal (base 8) and hexadecimal (base 16) provide more convenient way for people to write binary numbers. » 110101100010 = 110 101 100 010 = (6542)8 1101 0110 0010 = (d 62)16 octal conversion 000 = 0 001 = 1 010 = 2 011 = 3 100 = 4 101 = 5 110 = 6 111 = 7 1. 13 - Jon Turner - 12/26/2021 hexadecimal conversion 0000 = 0 1000 = 8 0001 = 1 1001 = 9 0010 = 2 1010 = a 0011 = 3 1011 = b 0100 = 4 1100 = 12 = c 0101 = 5 1101 = 13 = d 0110 = 6 1110 = 14 = e 0111 = 7 1111 = 15 = f

Finite Data Representations n Computer hardware is generally designed to operate on words with

Finite Data Representations n Computer hardware is generally designed to operate on words with a fixed number of bits (e. g. 16 bits). n Places a limit on the number of discrete values that can be stored in a single word (e. g. 216). n If we use words to represent positive integers then with n bits, we can represent integers 0 up to 2 n-1 n Larger integers can be represented by multiple words. » computer hardware operates on single words » software must combine results from single word operations to produce desired result n Or, use floating point representation for large (and small) values; typically supported by computer hardware. 1. 14 - Jon Turner - 12/26/2021

How Computers Add n Binary long addition similar to decimal long addition. carry augend

How Computers Add n Binary long addition similar to decimal long addition. carry augend addend sum decimal 1100 2565 6754 9319 binary 111100 10110 11011 110001 n Binary addition algorithm - add an-1. . . a 0 to bn-1. . . b 0 and put result in sn. . . s 0 c 0=0 // ci are carry bits for i = 0 to n-1 if one or three of ai, bi or ci are = 1 then si = 1 else si = 0 if at least two of ai, bi or ci are = 1, then ci+1 = 1 else ci+1 = 0 sn = c n 1. 15 - Jon Turner - 12/26/2021

Modular and Signed Arithmetic n Computers 15 0 1 2 14 11 0 0

Modular and Signed Arithmetic n Computers 15 0 1 2 14 11 0 0 3 13 4 0100 12 50 11 1 10 6 10 9 8 7 10 10 01 10 1 0011+0110 =1001 110 1 11 -7 -8 7 10 01 10 -1 0 1 11 0 0 3 4 0100 50 101 6 2 10 01 1 011 1000 10 -2 -3 1100 -4 -5 1 1 -6 10 000 00 1 10 1111+0011=0010 n Associating 1. 16 - Jon Turner - 12/26/2021 0000 00 1 10 10 111 certain bit patterns with negative values yields signed arithmetic. n Negate a given value by flipping all bits and adding 1. n Must pay attention to overflow. 11 10 01 1 011 1000 » to add A+B, start at position for A and then count clockwise B positions » modular arithmetic is just like “clock arithmetic” 1111+0011=0010 1 111 use modular arithmetic in which values wrap around circularly.

Representing Text Computers use numbers to represent alphabetic characters, numerals and punctuation. n Most

Representing Text Computers use numbers to represent alphabetic characters, numerals and punctuation. n Most common encoding is ASCII (American Standard Code for Communication Interchange) n » characters represented by 7 bit values » numerals start at (30)16 » upper case letters start at (41)16 » lower case letters start at (61)16 » see Table 1 -4 in Mano for details n Unicode uses 16 bits per character, allowing it to represent far more distinct characters. 1. 17 - Jon Turner - 12/26/2021

Convert Numeric String to Internal Value n ASCII character codes for decimal integer stored

Convert Numeric String to Internal Value n ASCII character codes for decimal integer stored in locations 20 -24 with M. S. D. at location 20. Write internal value in location 1 f. Address Instruction Comment 0000 (start)1000 (ACC : = 0000) result = 0 0001 401 f (M[001 f] : = ACC) 0002 1020 (ACC : = 0020) pointer = 020 0003 401 d (M[001 d] : = ACC) 0004 (loop)1025 (ACC : = 0025) if pointer = 025, quit 0005 0001 (ACC : = -ACC) 0006 a 01 d (ACC : = ACC + M[001 d]) 0007 7015 (if 0 goto 0015) 0008 100 a (ACC : = 000 a) result = 10 * result 0009 b 01 f (ACC : = ACC*M[001 f]) New multiply inst. 000 a 401 f (M[001 f] : = ACC) 1. 18 - Jon Turner - 12/26/2021

Convert Numeric String (continued) Address 000 b 000 c 000 d 000 e 000

Convert Numeric String (continued) Address 000 b 000 c 000 d 000 e 000 f 0010 0011 0012 0013 0014 0015 (end). . 001 d 001 e 001 f 0020 Instruction Comment 1 fd 0 (ACC : = -30) result = result 401 e (M[001 e] : = ACC) + (*pointer-‘ 0’) 301 d (ACC : = M[M[001 d]]) a 01 e (ACC += ACC+M[001 e]) a 01 f (ACC += ACC+M[001 f]) 401 f (M[001 f] : = ACC) 1001 (ACC : = 0001) pointer = pointer + 1 a 01 d (ACC : = ACC+M[001 d]) 401 d (M[001 d] : = ACC) 6004 (goto 0004) goto loop 0000 (halt) halt 1. 19 - Jon Turner - 12/26/2021 Pointer to next char Temporary value Store result here ASCII digits

Convert Internal Value to Numeric String n Write ASCII character codes for value in

Convert Internal Value to Numeric String n Write ASCII character codes for value in location 1 f into words 20. . 24 with L. S. D. in word 20. loop pointer = 20 if pointer = 25 then quit *pointer = (value modulo 10) + ‘ 0’ value = value / 10 pointer = pointer + 1 goto loop n Exercise: write corresponding machine program; assume two new instructions cxxx dxxx 1. 20 - Jon Turner - 12/26/2021 divide value in accumulator by value in location xxx and leave quotient in accumulator divide by value in xxx & put remainder in ACC

Another Look at Basic Computer Address Bus PC IREG Controller n Program IAR ACC

Another Look at Basic Computer Address Bus PC IREG Controller n Program IAR ACC Data Bus ALU read/write 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000 a Counter (PC) stores address of next. . . instruction. ffff n Instruction Register & Decoder (IREG) stores Memory current instruction. n Indirect Address Register (IAR) stores indirect addresses. n Accumulator (ACC) stores arithmetic operands and results. n Arithmetic & Logic Unit (ALU) implements arithmetic functions. n Controller coordinates actions of other components. n Data & Address Buses carry data between components. 1. 21 - Jon Turner - 12/26/2021

Execution of a Computer Program reset (initialization) monitored signals 1. 22 - Jon Turner

Execution of a Computer Program reset (initialization) monitored signals 1. 22 - Jon Turner - 12/26/2021 program counter, instruction register, accumulator, . . . system clock waveforms & buses time axis

Execution of a Computer Program reset period fetch first instruction 1. 23 - Jon

Execution of a Computer Program reset period fetch first instruction 1. 23 - Jon Turner - 12/26/2021 execute first instruction mload fetch second instruction execute second instruction – dload