Upload
erin-wood
View
239
Download
3
Tags:
Embed Size (px)
Citation preview
Computer Computer Architecture And Architecture And
OrganizationOrganizationUNIT-II
Structured OrganizationStructured Organization
Structured OrganizationStructured Organization It is a way of structuring computers as a series of abstractions, It is a way of structuring computers as a series of abstractions,
each abstraction building on the one below it.each abstraction building on the one below it. Let’s call L0 the machine language of a computer machine Let’s call L0 the machine language of a computer machine
which we refer at as M0which we refer at as M0
The actual computer M0, which executes Programs written in L0Level 0
• Defining another language L1 which is more convenient for people to use and L1 cannot be executed on the actual computer M0 (as M0 only understands L0)
•Though we can transform a L1 program in L0 so that it can be executed on M0
•There two ways for transforming a L1 programs into L0 programs
Translation vs InterpretationTranslation vs Interpretation
Translation: Translation: the original L1 program is translated the original L1 program is translated in an equivalent L0 one, then executed on M0in an equivalent L0 one, then executed on M0
L1 program
translator
L0 program
The actual computer M0, which executes Programs written in L0Level 0
Interpretation: Interpretation: to write a program (interpreter) in to write a program (interpreter) in L0 (hence running on M0) which takes L1 L0 (hence running on M0) which takes L1 programs as input and for each instruction in L1 programs as input and for each instruction in L1 executes the equivalent sequence of L0 instructionexecutes the equivalent sequence of L0 instruction
Translation vs InterpretationTranslation vs Interpretation
L1 program
interpreterLevel 0
Translation and interpretation are similar: they are Translation and interpretation are similar: they are both way to carry out L1 programs through a machine both way to carry out L1 programs through a machine which understand L0 language only. They are also which understand L0 language only. They are also different: different: In translation the entire L1 program is first In translation the entire L1 program is first
translated, then its thrown away and the resulting translated, then its thrown away and the resulting L0 program is executed (hence the translated L0 program is executed (hence the translated program controls the computer)program controls the computer)
With Interpretation the interpreter is in control of With Interpretation the interpreter is in control of the computer all the time. Each single instruction of the computer all the time. Each single instruction of L1 is considered and executed immediately Rather L1 is considered and executed immediately Rather than thinking in terms of translation/interpretation than thinking in terms of translation/interpretation we can think in terms of virtual machines.we can think in terms of virtual machines.
Translation vs InterpretationTranslation vs Interpretation
We can imagine a number of levels each one with its own We can imagine a number of levels each one with its own language language LnLn and virtual machine and virtual machine Mn Mn
A user of level A user of level nn has only to know language has only to know language LnLn and can and can forget about all below layers: to his eyes the computer is the forget about all below layers: to his eyes the computer is the virtual machine virtual machine MnMn
Through interpratation/translation the final result is that a Through interpratation/translation the final result is that a program written in Ln will be executed on M0 (the actual program written in Ln will be executed on M0 (the actual computer)computer)
It involves:-It involves:- CPUCPU CacheCache Main MemoryMain Memory Secondary MemorySecondary Memory I/O UnitsI/O Units
Structured OrganizationStructured Organization
Structured Organization- Structured Organization- CPUCPU
Data Bus
memory input/ outputcontrol
unit
arithmetic-logic unit
Central ProcessingUnit (CPU)
registers
program counter PC
instruction register IR
computation register R
condition flags: GT, EQ, LT
registers are like the cells ofmemory, but are much fasterand used for special purposes.For now, let’s focus on the computation register and the condition flags.
ALU and the data-path• the internal part of the CPU is also called data-path• it consists of registers and the ALU•The ALU performs simple arithmetical/logic operations (ADD, AND,OR) •It takes its operands from the registers and store the result back in them•The process of reading operand and storing result back is called data-path cycle•The faster the data-path cycle is the faster the computer runs
A B
ALU
A+B
A
B
A+B
input register
registers
output register
CPU-Instruction Execution CPU-Instruction Execution StepsSteps
CPU executes each instruction in the following steps:- CPU executes each instruction in the following steps:- (FETCH-DECODE-EXECUTE)(FETCH-DECODE-EXECUTE)
1)1) Fetch next instruction from memory into Fetch next instruction from memory into instruction register.instruction register.
2)2) Change program counter to point to next Change program counter to point to next instruction.instruction.
3)3) Determine the type of instruction just fetched.Determine the type of instruction just fetched.4)4) If instruction uses a word in memory, determine If instruction uses a word in memory, determine
where Fetch word, if needed, into CPU registerwhere Fetch word, if needed, into CPU register5)5) Execute the instruction.Execute the instruction.6)6) Go to step 1 to begin executing following Go to step 1 to begin executing following
instruction.instruction.
Example of Example of fetch-fetch-executeexecute cycle cycle
the memory cells actually contain binary numbers ... more on this later
instruction pointer PC
instruction register IR
computation register R
condition flags
Arithmetic-Logic Unit
Control Unit
CPUMemory
10 Load X11 Add Y12 Store Z13 Jump Nxt14 Subtract X15 Clear X
...........
20 7 21 4 22 0 23 0
instructions
data
Data Bus
addresscontents
(X)(Y)(Z)
(CN1)
(Nxt)
instruction pointer PC
instruction register IR
computation register R
condition flags
Arithmetic-Logic Unit
Control Unit
CPUMemory
10 Load X11 Add Y12 Store Z13 Jump Nxt14 Subtract X15 Clear X
...........
20 7 21 4 22 0 23 0
instructions
data
Data Bus
addresscontents
(X)(Y)(Z)
(CN1)
(Nxt)
step 0: to execute the program, initialize PC to 10
step 1: fetch instruction & increment PC
10
Load X
11
instruction pointer PC
instruction register IR
computation register R
condition flags
Arithmetic-Logic Unit
Control Unit
CPUMemory
10 Load X11 Add Y12 Store Z13 Jump Nxt14 Subtract X15 Clear X
...........
20 7 21 4 22 0 23 0
instructions
data
Data Bus
addresscontents
(X)(Y)(Z)
(CN1)
(Nxt)Load X
11
Step 2: (Decode and) Execute
7
Step 3: Go To Step 1
instruction pointer PC
instruction register IR
computation register R
condition flags
Arithmetic-Logic Unit
Control Unit
CPUMemory
10 Load X11 Add Y12 Store Z13 Jump Nxt14 Subtract X15 Clear X
...........
20 7 21 4 22 0 23 0
instructions
data
Data Bus
addresscontents
(X)(Y)(Z)
(CN1)
(Nxt)
step 1: fetch instruction & increment PC
11
Add Y
12
Step 2: (Decode and) Execute
instruction pointer PC
instruction register IR
computation register R
condition flags
Arithmetic-Logic Unit
Control Unit
CPUMemory
10 Load X11 Add Y12 Store Z13 Jump Nxt14 Subtract X15 Clear X
...........
20 7 21 4 22 0 23 0
instructions
data
Data Bus
addresscontents
(X)(Y)(Z)
(CN1)
(Nxt)Add Y
12
7
Step 3: Go To Step 1
11
and so on, and so on ...
The Storage HierarchyThe Storage Hierarchy
registers cache Main memorySecondary storage (disk)
floppy
Zip disk
Tape
fastersmallercostlierless flexible
slowerbigger
cheapermore flexible
Cache MemoryCache Memory Cache is a small, fast memory which holds Cache is a small, fast memory which holds
copies of recently accessed instruction and datacopies of recently accessed instruction and data Key to the performance of modern Key to the performance of modern
MicroprocessorsMicroprocessors There could be up to two levels of cache, the There could be up to two levels of cache, the
picture to the right is Intel Pentium M, the picture to the right is Intel Pentium M, the large block to the left showing 2 MB of L2 large block to the left showing 2 MB of L2 cachecache
Taking advantage of the Principle of Locality, Taking advantage of the Principle of Locality, cache loads itself with contents of data which cache loads itself with contents of data which was recently accessedwas recently accessed
But this only addresses temporal locality!But this only addresses temporal locality! Therefore to take advantage of spatial locality Therefore to take advantage of spatial locality
as well, cache subsystems are designed to read as well, cache subsystems are designed to read anywhere between 16-128 bytes of data at a anywhere between 16-128 bytes of data at a time.time.
Cache MemoryCache Memory Cache is simply defined as a temporary Cache is simply defined as a temporary
storage area for data which is frequently storage area for data which is frequently accessedaccessed
A A cache hit cache hit occurs when the CPU is occurs when the CPU is looking for data which is already looking for data which is already contained within the cachecontained within the cache
A A cache miss cache miss is the alternate scenario, is the alternate scenario, when a when a cache line cache line needs to be read from needs to be read from main memorymain memory
The percentages of accesses which result The percentages of accesses which result in cache hits are known as the cache in cache hits are known as the cache hit hit rate rate or or hit ratio hit ratio of the cacheof the cache
If the cache is full, it needs to If the cache is full, it needs to evict evict a a cache line before it can bring in a new cache line before it can bring in a new cache line. This is done through a cache line. This is done through a heuristic process and is known as the heuristic process and is known as the cache cache replacement policyreplacement policy
Cache OrganizationCache Organization Cache is organized not in bytes, but as Cache is organized not in bytes, but as
blocks of cache lines, with each line blocks of cache lines, with each line containing some number of bytes (16-64) containing some number of bytes (16-64)
Unlike normal memory, cache lines do Unlike normal memory, cache lines do not have fixed addresses, which enables not have fixed addresses, which enables the cache system to populate each cache the cache system to populate each cache line with a unique (non-contiguous) line with a unique (non-contiguous) addressaddress
There are three methods for filling a There are three methods for filling a cache linecache line
Fully Associative – The most flexibleFully Associative – The most flexible Direct Mapped – The most basicDirect Mapped – The most basic Set Associative – A combination of the twoSet Associative – A combination of the two
Main MemoryMain Memory Stores Instructions and DataStores Instructions and Data
Stored ProgramStored Program Random Access Memory (RAM)Random Access Memory (RAM)
Fetch (not destructive)Fetch (not destructive) Store (destructive)Store (destructive)
Read-Only Memory (ROM)Read-Only Memory (ROM) Fetch OnlyFetch Only
Dynamic RAMDynamic RAM Store binary information in the form of electric charges Store binary information in the form of electric charges
that are applied to capacitors.that are applied to capacitors. Pros:Pros: Simple constructionSimple construction Small memory cell (per bit)Small memory cell (per bit) Less expensiveLess expensive Cons:Cons: Charges leak, need refreshing even when poweredCharges leak, need refreshing even when powered Need refresh circuitsNeed refresh circuits SlowerSlower Main memoryMain memory
Static RAMStatic RAM
Consists of internal flip flops that store Consists of internal flip flops that store binary information.binary information.
Pros:Pros: No charges to leakNo charges to leak No refreshing needed when poweredNo refreshing needed when powered Does not need refresh circuitsDoes not need refresh circuits FasterFaster Cons:Cons: More complex constructionMore complex construction Larger per bitLarger per bit More expensiveMore expensive CacheCache
SRAM v DRAMSRAM v DRAM Both volatileBoth volatile Power needed to preserve dataPower needed to preserve data Dynamic cellDynamic cell Simpler to build, smallerSimpler to build, smaller More denseMore dense Less expensiveLess expensive Needs refreshNeeds refresh Larger memory unitsLarger memory units StaticStatic FasterFaster CacheCache
Secondary memorySecondary memory Secondary memory (or secondary Secondary memory (or secondary
storage) is the slowest and cheapest storage) is the slowest and cheapest form of memory. It cannot be processed form of memory. It cannot be processed directly by the CPU. It must first be directly by the CPU. It must first be copied into primary storage (also known copied into primary storage (also known as RAM ). as RAM ).
Secondary memory devices include Secondary memory devices include magnetic disks like hard drives and magnetic disks like hard drives and floppy disks ; optical disks such as CDs floppy disks ; optical disks such as CDs and CDROMs ; and magnetic tapes , and CDROMs ; and magnetic tapes , which were the first forms of secondary which were the first forms of secondary memorymemory..
I/O: Input and OutputI/O: Input and Output There is both a human-machine There is both a human-machine
interface and a machine-machine interface and a machine-machine interface to I/O.interface to I/O. Examples of the human-machine interface Examples of the human-machine interface
include a keyboard, screen or printer.include a keyboard, screen or printer. Examples of the machine-machine interface Examples of the machine-machine interface
include things like mass storage and include things like mass storage and secondary storage devices.secondary storage devices.