Digital Computers and Information n Digital computers n Number representations n Arithmetic...
-
Upload
dominick-singleton -
Category
Documents
-
view
218 -
download
0
Transcript of Digital Computers and Information n Digital computers n Number representations n Arithmetic...
Digital Computers and Information
Digital computersNumber representationsArithmetic operationsAlphanumeric codes
Read MK 3-26
1.2 - Jon Turner - 04/18/23
What’s in a Computer?
microprocessor
monitor
keyboard
FPU
CPU
MMU
InternalCache
ExternalCache
MainMemory
PeripheralBus Interface
GraphicsCard
DiskController
NetworkInterface
Microprocessor•Central Processing Unit•Floating Point Unit•Memory Mgmt. Unit•Internal Cache Memory
Main Memory•stores running programs and associated data
•typically 64-512 Mbytes
•Dynamic RAM
1.3 - Jon Turner - 04/18/23
What’s in a Computer?
microprocessor
monitor
keyboard
FPU
CPU
MMU
InternalCache
ExternalCache
MainMemory
PeripheralBus Interface
GraphicsCard
DiskController
NetworkInterface
Memory BusExternal Cache•small, fast memory
•stores recently used data
Control movement of data between memory and I/O devices
1.4 - Jon Turner - 04/18/23
What’s in a Computer?
microprocessor
monitor
keyboard
FPU
CPU
MMU
Internalcache
ExternalCache
MainMemory
PeripheralBus Interface
GraphicsCard
DiskController
NetworkInterface
Convert text & graphics to video
Peripheral Bus
Read/write data on proper physical location on disk
Transfer data between external network & memory
1.5 - Jon Turner - 04/18/23
What’s in a Chip?Intel 80286 Microprocessor
(www.micro.magnet.fsu.edu/chipshots)NEC/MIPS R4400 Microprocessor(www.micro.magnet.fsu.edu/chipshots)
Photomicrographs made using colored filters.
1.6 - Jon Turner - 04/18/23
Basic Processor & Memory
Memory stores programs and 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
Fetch & execute cycle»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)
10 50PC ACC
InstructionDecoder
Arithmetic& Logic Unit
AddressDecode
110123...
ffff
21-365
56
Processor MemoryAddress
Data
read/write
1.7 - Jon Turner - 04/18/23
Instruction Set0000 halt - halt execution0001 negate - ACC := ACC1xxx immediate load – if sign bit of xxx is 0 then
ACC := 0xxx else ACC := fxxx2xxx direct load - ACC := M[0xxx]3xxx indirect load - ACC := M[M[0xxx]]4xxx direct store - M[0xxx] := ACC5xxx indirect store – M[M[0xxx]] := ACC6xxx branch - PC := 0xxx7xxx branch if zero - if ACC = 0 then PC := 0xxx8xxx branch if positive - if ACC > 0 then PC :=
0xxx9xxx branch if negative - if ACC < 0 then PC :=
0xxxaxxx add - ACC := ACC + M[0xxx]
1.8 - Jon Turner - 04/18/23
Simple Program Add the values in locations 20-2f and write sum in 10.Address Instruction Comment0000 (start)1000 (ACC := 0000) initialize sum0001 4010 (M[0010] := ACC)0002 1020 (ACC := 0020) initialize pointer0003 4011 (M[0011] := ACC)0004 (loop) 1030 (ACC := 0030) if pointer = 030, quit
0005 0001 (ACC := -ACC)0006 a011 (ACC :=ACC+M[0011])0007 700f (if 0 goto 000f)0008 3011 (M[M[0011]] := ACC) sum = sum + *pointer0009 a010 (ACC :=ACC+M[0010])000a 4010 (M[0010] := ACC)000b 1001 (ACC := 0001) pointer = pointer + 1000c a011 (ACC :=ACC+M[0011])000d 4011 (M[011] := ACC)000e 6004 (goto 0004) goto loop000f (end) 0000 (halt) halt0010 Store sum here0011 Pointer to next value
1.9 - Jon Turner - 04/18/23
Representing Information in Computers
Electronic computers represent information as voltage levels.
To make the computer hardware simple and reliable, computers represent information in binary form.»example: voltages greater than 3V are interpreted as
representing one value (called “1”), voltages less than 2V are interpreted as representing another value (called “0”).
In principle, could use more voltage levels.»example: 0 to .75V represents “0”, 1 to 1.75V represents
“1”, 2 to 2.75V represents “2”, and so forth. In practice, this is rarely done.
»requires more complex circuits»circuits are more susceptible to noise, hence less reliable
1.10 - Jon Turner - 04/18/23
Noise in Computer Systems 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
The noise margin is the amountof noise that a system cantolerate and still correctlyidentify a logic high or low.
Undefined
High
Low
Undefined
High
Low
5v
4v
3v
2v
1v
0v
noise margin1 V
noise margin3 V
1.11 - Jon Turner - 04/18/23
Number Representation Standard decimal number representation
243.83 = 2102 + 4101 + 3100 + 8101 + 3102
Generalization to base rAn. . .A1A0.A1 . . .Am
=Anrn + . . . + A1r1 +A0r0 + A1r1 + . . . + Amrm
Binary number representation110.01 = 122 + 121 + 020 + 021 + 122
Converting binary numbers to decimal (easy).write binary expansion, replace powers of 2 with decimal values, and add up the values110.01 = 122 + 121 + 020 + 021 + 122 = 4 + 2 + 14 = 6.25Note: it helps to know your powers of 2 (hint)
1.12 - Jon Turner - 04/18/23
Decimal-Binary Conversion Repeated division by 2
625/2 = 312 with remainder of 1 least significant bit312/2 = 156 with remainder of 0156/2 = 78 with remainder of 0 78/2 = 39 with remainder of 0 39/2 = 19 with remainder of 1 19/2 = 9 with remainder of 1 9/2 = 4 with remainder of 1 4/2 = 2 with remainder of 0 2/2 = 1 with remainder of 0 1/2 = 0 with remainder of 1
So, (625)10 = (10 0111 0001)2
Works similarly for other number bases.
1.13 - Jon Turner - 04/18/23
Octal and Hexadecimal 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 = (d62)16
octal conversion hexadecimal conversion000 = 0 0000 = 0 1000 = 8001 = 1 0001 = 1 1001 = 9010 = 2 0010 = 2 1010 = 10 = a011 = 3 0011 = 3 1011 = 11 = b100 = 4 0100 = 4 1100 = 12 = c
101 = 5 0101 = 5 1101 = 13 = d110 = 6 0110 = 6 1110 = 14 = e
111 = 7 0111 = 7 1111 = 15 = f
1.14 - Jon Turner - 04/18/23
Finite Data Representations Computer hardware is generally designed to operate
on words with a fixed number of bits (e.g. 16 bits). Places a limit on the number of discrete values that
can be stored in a single word (e.g. 216). If we use words to represent positive integers then
with n bits, we can represent integers 0 up to 2n1 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 Or, use floating point representation for large (and
small) values; typically supported by computer hardware.
1.15 - Jon Turner - 04/18/23
How Computers Add Binary long addition similar to decimal long addition.
decimal binarycarry 1100 111100augend 2565 10110addend 6754 11011sum 9319 110001
Binary addition algorithm - add an1...a0 to bn1...b0 and put result in sn...s0
c0=0 // ci are carry bitsfor i = 0 to n1
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
= 0sn = cn
1.16 - Jon Turner - 04/18/23
Modular and Signed Arithmetic
Computers use modular arithmetic in which values wrap around circularly.»to add A+B, start at position
for A and then count clockwise B positions
»modular arithmetic is just like “clock arithmetic”
0011+0110 =1001
1111+0011=0010
000
000
01
1100
0010
0011
1011
0100
1010
0101
1101
0110
0111
1111
100
0
1110
1001
0 12
345
14
109 7
6
15
131211
8
1111+0011=0010
000
000
01
1100
0010
0011
1011
0100
1010
0101
1101
0110
0111
1111
100
0
1110
1001
0 12
345
-2
-6-7 7
6
-1
-3-4-5
-8
Associating certain bit patterns with negative values yields signed arithmetic.
Negate a given value by flipping all bits and adding 1.
Must pay attention to overflow.
1.17 - Jon Turner - 04/18/23
Representing Text Computers use numbers to represent
alphabetic characters, numerals and punctuation.
Most common encoding is ASCII (American Standard Code for Communication Interchange)»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
Unicode uses 16 bits per character, allowing it to represent far more distinct characters.
1.18 - Jon Turner - 04/18/23
Convert Numeric String to Internal Value ASCII character codes for decimal integer stored
in locations 20-24 with M.S.D. at location 20. Write internal value in location 1f.
Address Instruction Comment0000 (start)1000 (ACC := 0000) result = 00001 401f (M[001f] := ACC)0002 1020 (ACC := 0020) pointer = 0200003 401d (M[001d] := ACC)0004 (loop)1025 (ACC := 0025) if pointer = 025, quit
0005 0001 (ACC := -ACC)0006 a01d (ACC := ACC + M[001d])0007 7015 (if 0 goto 0015)0008 100a (ACC := 000a) result = 10 * result0009 b01f (ACC := ACC*M[001f]) New multiply inst.000a 401f (M[001f] := ACC)
1.19 - Jon Turner - 04/18/23
Convert Numeric String (continued)Address Instruction Comment 000b 1fd0 (ACC := -30) result = result 000c 401e (M[001e] := ACC) + (*pointer-‘0’)
000d 301d (ACC := M[M[001d]]) 000e a01e (ACC += ACC+M[001e]) 000f a01f (ACC += ACC+M[001f]) 0010 401f (M[001f] := ACC) 0011 1001 (ACC := 0001) pointer = pointer + 1
0012 a01d (ACC := ACC+M[001d]) 0013 401d (M[001d] := ACC) 0014 6004 (goto 0004) goto loop 0015 (end) 0000 (halt) halt .... 001d Pointer to next char 001e Temporary value 001f Store result here 0020 ASCII digits
1.20 - Jon Turner - 04/18/23
Convert Internal Value to Numeric String
Write ASCII character codes for value in location 1f into words 20..24 with L.S.D. in word 20.
pointer = 20loop if pointer = 25 then quit
*pointer = (value modulo 10) + ‘0’value = value / 10pointer = pointer + 1goto loop
Exercise: write corresponding machine program; assume two new instructionscxxx divide value in accumulator by value in
location xxxand leave quotient in accumulator
dxxx divide by value in xxx & put remainder in ACC
1.21 - Jon Turner - 04/18/23
Another Look at Basic Computer
Program Counter (PC) stores address of next instruction.
Instruction Register & Decoder (IREG) stores current instruction.
Indirect Address Register (IAR) stores indirect addresses. Accumulator (ACC) stores arithmetic operands and results. Arithmetic & Logic Unit (ALU) implements arithmetic
functions. Controller coordinates actions of other components. Data & Address Buses carry data between components.
Controller
PC Data Bus
Address Bus
Memory
0000000100020003000400050006000700080009000a
ffff
. . .
IREG IAR ACC
read/writeALU
1.22 - Jon Turner - 04/18/23
Execution of a Computer Program
monitoredsignals
waveforms
& buses
timeaxis
system
clock
reset(initialization
)
program counter,instruction register, accumulator, . . .