Unit - I Syllabus: Basic Structure of Computers
Unit - I Syllabus: Basic Structure of Computers
Types of Computers :
1. Personal Computer
2. Desktop Computer
3. Notebook
4. Workstations
5. Enterprise Systems (Mainframe) and Servers
6. Super computers
Processor
Hard Disk
Hard Disk
Functional Units
Main Memory
Registers
CU BUS
ALU
I/p 1 I/p 2 S.M o/p 1 o/p n
Connection between Processor & Memory
Main Memory
R0
PC
R1
ALU Processor
:
:
IR
Rn-1
Fetch
Next
Determine successor instruction; can
Instruction generally be combined w/ Decode
Execution Cycle Contd..
Bus / Interface
Bus Structure
• For a computer to achieve its operation, the functional units
need to communicate with each other.
•I n order to communicate, they need to be connected.
Bus
CPU time is the time taken by CPU to execute the program. It has
two components:
User CPU time is the time to execute the instructions of the program.
System CPU time is the time used by the operating system to run the
program.
Elapsed time (wall clock time) is the time between the start and
end of the program.
Processor Clock
Clock cycle
Period of the hardware clock
Example: one clock cycle means 1 nanosecond for a 1GHz clock
frequency (or clock rate)
– CPU time = (CPU clock cycles)/(clock rate)
T = NXS
R
T - Performance parameter of an application program
N - No.of machine language instructions required to
complete execution of a program,
S - Avg No.of basic steps required to execute one machine
instruction.
R - Clock rate of the processor in cycles per second.
Amdahl’s Law
Old time
Speedup = ------------
New time
1
= ---------------------
1 – fenh + fenh/n
Bytes
Number of Binary Digits (bits) Common Name
1 Bit
4 Nibble
8 Byte
16 Half Word
32 Word
64 Double Word
128 Quad Word
Number of Bytes Common Name
1,024 (210) kilobyte (kb)
1,048,576 (220) Megabyte (Mb)
1,073,741,824 (230) Gigabyte (Gb)
1,099,511,627,776 bytes (240) Terabyte (Tb)
1,125,899,906,842,624 bytes (250) Petbytes (P)
260 , 270 , 280 Exabytes, Zettabytes, Yottabytes
Number Systems
• Decimal number system
• Binary number system
• Octal number system
• Hexadecimal number system
• Converting
• Negative numbers
• Character representation
Decimal Octal Hex Binary
0 0 0 0000
1 1 1 0001
2 2 2 0010
3 3 3 0011
4 4 4 0100
5 5 5 0101
6 6 6 0110
7 7 7 0111
8 10 8 1000
9 11 9 1001
10 12 A 1010
11 13 B 1011
12 14 C 1100
13 15 D 1101
14 16 E 1110
15 17 F 1111
16 10 (1 + 0) 0001 0000
Unsigned Integers
• Represents positive integers only
• Example: ASCII character codes
• Not necessary to indicate a sign, so all 8 or
16 bits can be used for the magnitude:
– 1 byte = 8 bits = 28 = 256 (0 to 255)
– 2 bytes = 16 bits = 216 = 65,536 (0 to 65,535)
– 4 bytes = 32 bits = 232
= 4,294,967,296 (0 to 4,294,967,295)
Signed Integers
• Represents positive and negative integers
• MSB (Most Significant Bit – leftmost bit) used to
indicate sign
– 0 = positive, 1 = negative
• One less bit is used for the magnitude, with one
extra negative value
– 1 byte = 8-1 bits = 27 (-128 to +127)
– 2 bytes = 16-1 bits = 215 (-32,768 to +32,767)
– 4 bytes = 32-1 bits = 231 (-2,147,483,648 to
+2,147,483,647 )
1’s & 2’s Complement
• 1’s complement form
– Formed by reversing (complementing) each bit
• 2’s complement form
– Formed by adding 1 to 1's complement
– Negative numbers are stored this way
– Additive inverse of a number
– Computer never has to subtract
• A – B = A + (-B)
Decimal Conversion
• Unsigned Integers
– Convert binary directly to decimal form
• Signed Integers
– If MSB = 0, convert directly to decimal
– If MSB = 1, convert to 2's complement form
(reverse the bits & add 1), then to decimal
form
Signed Integers (8-bit)
• Example: -9
– 0000 1001b
– 1111 0110b
– +1b
– 1111 0111b
• Example: -32
– 0010 0000b
– 1101 1111b
– +1b
– 1110 0000b
Converting Rules
= ( 1100.1101 )2
Decimal – Hexadecimal conversion
Integer or Fixed Point: 4181
eg : 4181910 16 9 10 3 5 11
16 2613 - 11
i.e
Ans = (A35B)16 16 163 - 5
10 - 3 A 3 5 B
Floating Point :
eg : 23.812510
0.8125 x 16 = 13.0000 = D
16 23
1 - 7
Ans = (17.D)16
Decimal - Octal Conversion
Integer or Fixed Point: Floating Point :
eg : 625310 eg : 117.98210
8 117
8 6253 8 14 - 5
8 781 - 5 1 - 6 = 165
8 97 - 5
0.982 x 8 = 7.586 = 7
8 12 - 1
0.856 x 8 = 6.848 = 6
1 - 4
0.848 x 8 = 6.784 = 6
0.784 x 8 = 6.272 = 6
= 7666213
0.272 x 8 = 2.176 = 2
= ( 14155 )8 0.176 x 8 = 1.408 = 1
0.408 x 8 = 3.264 = 3
= ( 65.7666213)8
Binary - Hexadecimal Conversion
Integer or Fixed Point:
eg : 11111001101111000112
0111 1100 1101 1110 0011
7 C D E 3
Ans = ( 7CDE3 )16
Floating Point:
eg : 10110001.1002
Floating Point:
eg : 1101011110.11000112
1 1 0 1 0 1
1 x 20 = 1
0 x 21 = 0
1 x 22 = 4
0 x 23 = 0
1 x 24 = 16
1 x 25 = 32
(53)10
Binary - Decimal Conversion
• Floating Point eg : (11001.10101)2
1 1 0 0 1 . 1 0 1 0 1
1 x 2-5 = 0.03125
0 x 2-4 = 0.0
1 x 2-3 = 0.125
1 x 2-2 = 0.0
1 x 2-1 = 0.5
0.65625
1 x 20 = 1
1 x 21 = 0
1 x 22 = 0
1 x 23 = 8
1 x 24 = 16
Ans = (25.65625 )16 25
Octal – Decimal conversion
• Integer eg : ( 741 )8
7 4 1
1 x 80 = 1
4 x 81 = 32
7 x 82 = 448
481
6 2 3 . 4 0 1
1 x 8-3 = 0.001953
0 x 8- 2 = 0
4 x 8-1 = 0.5
0.501953
3 x 80 =
3
2 x 81 =
16
6 x 82 =
384
403
Ans = ( 403.5019 )10
Hexadecimal – Decimal Conversion
Integer eg: ( D6C1 )16
D 6 C 1
1 x 160 = 1
1 x 161 = 192
1 x 162 = 1536
1 x 163 = 53248
54977
F 9 A . B C 3
3 x 16-3 = 0.0007
C x 16-2 = 0.0039
B x 16-1 = 0.6875
0.6921
A x 160 = 10
9 x 161 = 144
F x 162 = 3840
3994
Integer eg : ( 436 )8
4 3 6
100 011 110
Ans = ( 100011110 )2
Floating Point eg : ( 765.421 )8
7 6 5 . 4 2 1
111 110 101 . 100 010 001
Ans = ( 111110101100010001 )2
Octal – Hexdecimal Conversion
Integer eg : ( BC35 )8
B C 3 5
1011 1100 0011 0101
Ans = ( 1011110000110101 )2
Floating Point eg : ( F9A . BC3 )8
F 9 A . B C 3
1111 1001 1010 1011 1100 0011
Ans = ( 111110011010101111001111 )2
Binary Arithmetic
• Binary Arithmetic
– Addition
111011 Carries
101011 Augend
+ 11001 Addend
1000100
– Subtraction
0 1 10 0 10 Borrows
1 0 0 1 0 1 Minuend
- 1 1 0 1 1 Subtrahend
1 0 1 0
Binary Arithmetic contd
– Multiplication Division
110 Quotient
1 1 0 1 0 Multiplicand Divider 1001 111101 Dividend
1001
x 1 0 1 0 Multiplier 1100
00000 1001
111 Remainder
11010
00000
11010
1 0 0 0 0 0 1 0 0 Product
Hexadecimal Arithmetic
– Addition
1 0 1 1 Carries
5 B A 9 Augend
+ D 0 5 8 Addend
1 2 C 0 1 Sum
– Subtraction
9 10 A 10 Borrows
A 5 B 9 Minuend
+ 5 8 0 D Subtrahend
4 D A C Difference
Hexadecimal Arithmetic contd
Multiplication Division
79B Quotient
B9A5 Multiplicand Divider B9 57F6D Dividend
50F
x D50 Multiplier 706
3A0390 Partial products 681
96D61 85D
7F3
9A76490 Product 6A Remainder
Octal Arithmetic
– Addition
1 1 1 Carries
5 4 7 1 Augend
+ 3 7 5 4 Addend
11445 Sum
– Subtraction
6 10 4 10 Borrows
7 4 5 1 Minuend
- 5 6 4 3 Subtrahend
1 6 0 6 Difference
Octal Arithmetic contd
– Multiplication Division
114 Quotient
326 Multiplicand Divider 63 7514 Dividend
x 67 Multiplier 63
114
2732 Partial products 63
364
2404 314
50 Remainder
26772 Product
Big-Endian and Little-Endian Formats
• In a byte-addressable machine, the smallest datum that can be
referenced in memory is the byte. Multi-byte words are stored as a
sequence of bytes, in which the address of the multi-byte word is the
same as the byte of the word that has the lowest address.
• When multi-byte words are used, two choices for the order in which the
bytes are stored in memory are: most significant byte at lowest
address, referred to as big-endian, or least significant byte stored at
lowest address, referred to as little-endian.
One, Two, Three-Address Machines
• Consider how the C expression A = B*C + D might be
evaluated by each of the one, two, and three-address
instruction types.
• Assumptions: Addresses and data words are two bytes in size.
Opcodes are 1 byte in size. Operands are moved to and from
memory one word (two bytes) at a time.
• Three-Address Instructions: In a three-address instruction,
the expression A = B*C + D might be coded as:
mult B, C, A
add D, A, A
which means multiply B by C and store the result at A. (The
mult and add operations are generic; they are not ARC
instructions.) Then, add D to A and store the result at address
One, Two, Three-Address
Machines
• Two Address Instructions: In a two-address
instruction, one of the operands is overwritten by
the result. Here, the code for the expression A = B*C
+ D is:
load B, A
mult C, A
add D, A
The program size is now 3´(1+2´2) or 15 bytes.
Memory traffic is 15 + 2´2 + 2´2´3 or 31 bytes.
One, Two, Three-Address Machines
• One Address (Accumulator) Instructions: A one-address
instruction employs a single arithmetic register in the CPU,
known as the accumulator. The code for the expression A = B*C +
D is now:
load B
mult C
add D
store A
The load instruction loads B into the accumulator, mult multiplies
C by the accumulator and stores the result in the accumulator,
and add does the corresponding addition. The store instruction
stores the accumulator in A. The program size is now 3´4 or 12
bytes, and memory traffic is 12 + 4´2 or 20 bytes.
CISC vs RISC
CISC processors RISC processors
1 Complex Instruction Set Computer 1.Reduced Instruction Set Computers
(CISC) processors has a bigger (RISC) processors has a smaller
instruction set with many addressing instruction set with few addressing
modes. modes
10. Code Expansion is not a problem in 10. Code expansion can be a problem
CISC processors. in some cases in RISC processors.
Emerging Technologies
DRAM Interleaving
Bus protocols
Coherence,
Memory L2 Cache Bandwidth,
Hierarchy Latency
L1 Cache Addressing,
VLSI Protection,
Instruction Set Architecture Exception Handling
swap:
muli $2, $5, 4
add $2, $4, $2 Assembly language
lw $15, 0($2) program (for MIPS)
lw $18, 4($2)
sw $18, 0($2)
sw $15, 4($2)
jr $31
0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 00 00 00 00 1 1 0 0 0
0 00 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 1
1 00 0 1 1 0 0 0 1 1 0 0 0 1 0 0 0 0 00 0 0 0 0 00 0 0 0 0 0 Binary machine language
1 00 0 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0 00 0 0 0 0 00 0 0 1 0 0 program (for MIPS)
1 0 1 0 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0 00 0 0 0 0 00 0 0 0 0 0
1 0 1 0 1 1 0 0 0 1 1 0 0 0 1 0 0 0 0 00 0 0 0 0 00 00 1 0 0
0 00 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 1 0 0 0
HW - SW Components
• Hardware
– Memory components • Software
• Registers – Data
• Register file • Simple
• memory – Characters
• Disks – Integers
– Functional components – Floating-point
• Adder, multiplier, – Pointers
dividers, . . . • Structured
• Comparators – Arrays
• Control signals – Structures
( records)
– Instructions
• Data transfer
• Arithmetic
• Shift
• Control flow
• Comparison
• ...
Levels of Abstraction
A p p lic a tio n s
O p e r a tin g S y s te m
C o m p ile r F ir m w a r e
In s tr u c tio n S e t A r c h ite c tu r e
In s tr u c tio n S e t P r o c e s s o r I/O S y s te m
D a ta p a th & C o n tro l
D ig ita l D e s ig n
C ir c u it D e s ig n
Layout