Lecture # 1
Lecture # 1
Lecture # 1
F = 2 *109 F = 3 *109
Multiplication 400
Division 450
Load/Store 150
O for positive& 1 for negative. [( UnSigned Number ->( 00001111) -> (15)
O for positive& 1 for negative. [( UnSigned Number ->( 10001111) ->
(128+0+0+0+8+4+2+1 = 143)
In unsigned numbers Magnitude will be based of 8 bits out of total 8 bits and highest
value could be 28 = 256-1 because most significant value will be used for magnitude
instead of sign.
2 x 20 bit instructions
Keeping all other parameters constant if we double the frequency of our system, the execution time
of a processor will be half.
00000001 = 20 = 1
00000011 = 21 + 20 = 3
11111111 = 27 +26 +25 +24 +23+22 +21 + 20 = 128+64+32+16+8+4+2+1 =255 (28-1 = 256-1 = 255)
I have two options available, a system with 4 GHz single core and a system with 2 GHz dual core.
Consider the execution of a program which results in the execution of 2 million instructions
on a 400-MHz processor. The program consists of four major types of instructions. The
instruction mix and the CPI for each instruction type are given below based on the result of a
program trace experiment:
Calculate its CPI, Total time required for the execution of below given program and its MIPS
rate?
T = Ic * CPI * Timeperiod = 2000000 * 2.24 * 0.0025 *10-6 => 11200 *10-6 => 0.0112 sec
MIPS Rate ( Millions of Instruction per second) = 400 * 106 / 2.24 * 106 => 400/2.24 => 178.57
MIPS Rate = Ic / T * 106 => Ic / Ic * CPI * t * 106 => 1/CPI * t * 106 => f / CPI *106
Magnetic
Optical
Electrical
a. Registers
b. Cache
c. RAM
i. Static & its types
ii. Dynamic & Its types
d. ROM and its Types
e. USB
f. SSD ( Solid State Drive )
Magnetic
1) Floppy Drive/Disk
2) Magnetic Disk (SATA / with different RPMS)
3) Magnetic Tape
Optical
1) CD
2) DVD
3) Rewriteable CD / DVD
4) Blu-Ray Disk
Discuss memory hierarchy with reasoning & you guys are supposed to discuss the following concepts
regarding each memory type:
Mapping functions:
Direct Mapping Fully Associative Mapping
0
000 1
0
001 1
0
010 1
0
011 1
0
100 1
0
101 1
0
110 1
0
111 1
00
00 01
10
11
00
01 01
10
11
00
10 01
10
11
00
11 01
10
11
000
0 001
010
011
100
101
110
111
000
1 001
010
011
100
101
110
111
Direct Mapping
Ram Blocks:
Line Table: => Line Number = Block number of RAM % Total number of lines in Cache
Cache: RAM
0 0, 8, 16, 24
1 1, 9, 17, 25
2 2, 10, 18, 26
3 3, 11, 19, 27
4 4, 12, 20, 28
5 5, 13, 21, 29
6 6, 14, 22, 30
7 7, 15, 23, 31
Set Associative:
Set Table:
Cache: RAM
Questions: 1
Consider we have RAM of 2048 words and Cache consists of 256 Words. Calculate
Tag bits and Line Table when Line Size/block size in cache is 16 Words. Word size is 4 bytes
and Memory is Word addressable. When direct mapping function is implemented.
RAM Cache
Address Length = Number of bits required to address certain memory is called address length.
A.L => 2A.L = 2048 => 211 = 2048 A.L => 2A.L = 256 => 28 = 256
Direct Mapping:
Number of Blocks of RAM allocated in a Single Line/Block of Cache = Total No of Blocks in RAM/
Total number of lines in cache
Number of Blocks of RAM allocation in a Single Line/Block of Cache = 128/16 = 8 Blocks in single line
Line Table:
Tag Bits: => A.L = XXXXXXXXXXX s-r bitsr bitsW bits Tag bits = S-r = 7-4 = 3 bits
1-> 11001110000 - Cache MIss 11001110001 - Cache Hit 11001111111 - Cache Hit
Fully Associative:
Tag Bits: => In fully associative there will be no line table because we can place any block of RAM
in any LINE/Block of cache. So “S” bits will be saved as Tag bits.
Set Associative:
1-Way set Associative = set Size is equal to 1 Lines of Cache Direct Mapping
16-Way set Associative = set Size is equal to 16 Lines of Cache Fully Associative Mapping
Draw set table and calculate Tag bits when set size is equal to 4 lines. ( 4 Way set Associative)
Total number of sets = Total number of lines or blocks in cache / Set size
Set Table will give you the allocation of each line in a specific set.
Number of Blocks allocated in a single set = Total Blocks in RAM / Total sets in Cache -> 128/4 = 32
Set Table:
0: 0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92,96,100,104,108,112,116,120,124
1: 1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81,85,89,93,97,101,105,109,113,117,121,125
2: 2,6,*******************************************************************************126
3: 3,7,11,15**************************************************************************127
Tag Bits: => A.L = XXXXXXXXXXX s-d bits d bits W bits Tag bits = S-d = 7-2 = 5 bits
01
10
11001 1100111 (Block Number = 103)
Questions: 2
Consider we have RAM of 2048 words and Cache consists of 256 Words. Calculate
Tag bits and Line Table when Line Size in cache is 16 Words. Word size is 4 bytes and
Memory is Word addressable. When direct mapping function is implemented.
RAM Cache
Address Length = Number of bits required to address certain memory is called address length.
A.L => 2A.L = 2048 => 211 = 2048 A.L => 2A.L = 256 => 28 = 256
Direct Mapping:
Number of Blocks of RAM allocation in a Single Line/Block of Cache = Total No of Blocks in RAM/
Total number of lines in cache
Number of Blocks of RAM allocation in a Single Line/Block of Cache = 128/16 = 8 Blocks in single line
Line Table:
Question: 3
RAM has the address length of 14 bits and Cache consists of 1024 Words. Calculate
Tag bits and Line Table when Line Size in cache is 32 Words. Word size is 4 bytes and
Memory is Word addressable.
I. When direct Mapping function is implemented.
II. When Fully Associative Mapping function is implemented.
III. When 4-way set associative mapping function is implemented.
RAM Cache
A.L = 14 bits A.L => 2A.L = 1024 Words
Memory Size = 214 = 16384 Words A.L = 10 bits
A.L = XXXXXXXXXXXXXX A.L = XXXXXXXXXX
Block Size = 32 Words Block/Line Size = 32 Words
Number of Blocks = 16384 / 32 Number of lines = 1024/32
Number of Blocks = 512 Blocks Number of lines = 32
Lines/Blocks
2W = 32W = 5 bits 2W = 32W = 5 bits
2S= 512 S = 9 bits 2r= 32 r = 5 bits
Direct Mappning:
Blocks allocated in a Single line = Total num of blocks in RAM / Total number of blocks in cache
. . . . . . . . …………
. . . . . . . . …………
. . . . . . . . …………
. . . . . . . . …………
Tag bits are used to differentiate among the blocks which are nominated in a same line of cache.
S=9 W=5
S-r = 4 r = 5 W=5
Question: 4
RAM has the address length of 4096 Words and Cache consists of 512 Words.
Calculate Tag bits and Line Table when Line Size in cache is 32 Words. Word size is 4 bytes
and Memory is Word addressable.
RAM Cache
A.L = 12 bits A.L => 2A.L = 512 Words
Memory Size = 212 = 4096 Words A.L = 9 bits
A.L = XXXXXXXXXXXX A.L = XXXXXXXXX
Block Size = 32 Words Block/Line Size = 32 Words
Number of Blocks = 4096 / 32 Number of lines = 512/32
Number of Blocks = 128 Blocks Number of lines = 16
Lines/Blocks
2W = 32W = 5 bits 2W = 32W = 5 bits
2S= 128 S = 7 bits 2r= 32 r = 4 bits
Direct Mappning:
Blocks allocated in a Single line = Total num of blocks in RAM / Total number of blocks in cache
Tag bits are used to differentiate among the blocks which are nominated in a same line of cache.
S=7 W=5
S-r= 3r = 4W=5
General Discussion:
100011000000 – Miss
100011000001 – Hit
100011001100 – Hit
000011000000 – Miss
000011001111 - Hit
100011000000 – Miss
d = 2 bits
S=7 W=5
XXXXXXXXXXXX In 4-way set associative Mapping S-d bits will be used as tag bits
S-d=5 d=2W=5
Set Table:
S
e
t
N
o
0 0 4 8 1 1 2 2 2 3 3 4 4 4 5 5 6 6 6 7 7 8 8 8 9 9 1 1 1 1 1 1 1
2 6 0 4 8 2 6 0 4 8 2 6 0 4 8 2 6 0 4 8 2 6 0 0 0 1 1 2 2
0 4 8 2 6 0 4
1 1 5 1
2
5
2 2 6 1
2
6
3 3 7 1
2
7
Hit & Miss Rate when 4-Way Set Associative Mapping is implemented:
General Discussion:
001110100001 - Miss
Question No: 5
Calculate the hit ratio and miss ratio for the following 20 requests of Block Numbers.
Update the Tag bits and requested block in respective lines when your system has 128
Blocks and 16 Lines in Total. Use (i) direct mapping (ii) Fully Associative (iii) 4-way
Set associative (iv) 2-way set associative mythology for Placement and FIFO for
replacement.
Requested Blocks: 0, 8, 12, 0, 9, 45, 84, 24, 127, 9, 15, 114, 12, 125, 84, 127, 9, 8, 45,
12
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Solution:
a) Direct Mapping
Requested Blocks: 0, 8, 12, 0, 9, 45, 84, 24, 127, 9, 15, 114, 12, 125, 84, 127, 9, 8, 45, 12
Addressing Mode:
Calculate the total addressable memory when an instruction field of an instruction is 11 bits long.
a)
2048 (Will store next reference only) + 256*2048 = 526336 Locations/bytes
Total memory in bytes when memory is one byte organized & single referenced.
2048 locations for 1st reference & 256*2048 = 524288 bytes for operand storage.
2048 + 65536*2048 = 134219776 Locations * 2 = bytes Total memory in bytes when memory is
two byte organized & single referenced.
a) (2048 + 256*2048 + 2048 * 256 * 256) = Total memory in bytes when memory is one byte
organized & Double referenced.
b) (2048 + 65536*2048 + 2048 * 65536 * 65536)*2 = Total memory in bytes when memory is two
byte organized & Double referenced.
1. Draw & Calculate the size of the memory for 1st reference, 2nd reference and operands if
address the address length is 8 bits long and affective address will be obtained in 2nd
reference. Assume that memory is two bytes organized. Do calculate the total size of the
memory in bytes as well.
(10)
1 st
Reference will be utilized in 256 Locations only but each memory location contain 2
bytes (16 bits ) because the memory is two by organized.
In 2nd reference (256 *65536) Locations will be accessed in which affective address will
be obtained.
In 3rd access the oprand will be accessed and the total memory locations will be
(256*65536*65536) Locations (Operands Memory )
Total memory in bytes when memory is two byte organized & Double referenced.