coe 205
DESCRIPTION
COE 205. Lectures 2 & 3: Computer Organization. Memory. Storage Device Stores Programs and Data coded in binary format. Technically “similar” to a two-dimensional array of “switches” A “switch” called a bit (abbr. for bi nary dig it ) n Address lines means 2 n words of m bits each. - PowerPoint PPT PresentationTRANSCRIPT
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
1
COE 205
Lectures 2 & 3:
Computer Organization
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
2
Memory• Storage Device• Stores Programs and
Data coded in binary format.
• Technically “similar” to a two-dimensional array of “switches”
• A “switch” called a bit (abbr. for binary digit)
• n Address lines means 2n words of m bits each
0
1
m
n
2n
Data
Address
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
3
Memory• 2 Operations:
– Read: Copy Data stored in word of Address (on Address lines) to Data Bus
– Write: Store Data on Data Bus into word of Address (on Address lines)
m
n
ReadWrite
Addr
Data
Memory
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
4
Concept of Address• It is an index in the memory
• It represents a “geographic” location of a word in the memory
• Number of Address lines and Word size determine Memory Capacity (Size)
• Most of the time:– Memory size = 2n words = 2n * m bits
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
5
Random Access• Access to Memory locations is equal delay.• Means access to any word which address
picked “randomly” will take the SAME amount of access time.
• Think about it as structurally different than a tape structure.
• In a tape: unequal access time to information stored in different locations (beginning of tape, middle or end of tape)
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
6
RAM• RAM: Random Access Memory• Although the name is about the way memory is
accessed. Historically, volatile memory has been called RAM.
• Volatile (do not retain information on power off)• Used mainly as Central Memory for CPUs• Two types of RAM
– Static: Continuous Retention of Information– Dynamic (DRAM): needs refresh cycle to maintain
information
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
7
ROM• Non Volatile• Used to store data (programs) that do not
change often (fixed)• Many types
– Mask ROM: Values set at fabrication stage. Values cannot be changed
– Fuse PROM: Values set at burning phase. Values cannot be changed
– EPROM: Can be erased (UV)– EEPROM: Electrically erased– Flash EEPROM: Easily reprogrammable.– New: NVRAM (Non Volatile RAM): Fast access time.
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
8
Disk Drives• Hard Drive: suite of
magnetic disks. Mechanically read and write data by moving a set of magnetic head over the disks
• CD-ROM, DVD-ROM: Suite of optical disks read by measuring the time of laser reflexion between “1” and “0”
“1” “0”
N S
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
9
Program Execution• A Program is a suite of
instructions
• Program Execution is Sequential
• Program is stored in Memory
• Program is executed by CPU
Instruction 1
Instruction 2
Instruction 3
Instruction n
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
10
CPU
• Executes Programs Stored in Memory
• Executes Instructions ONE by ONE
• Only “knows” instructions: Instruction Set
• DO NOT know any notion of Program as a single entity.
• Everything is a suite of instructions
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
11
CPU Structure (1)Is Mainly a Data Processing Unit Controlledby a Control Unit.• Data Processing Unit: Datapath
– Registers (Scratch pad working space or temporary data storage)
– ALU: Arithmetic and Logic Unit– Internal Buses
• Control Unit: Generates Commands to “drive” Datapath operations
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
12
CPU Structure (2)
Control Unit
Data Path is Similar to a Pipe Structure where valves are controlled by the Control Unit
Dat
apat
h ALU
Reg
iste
r
Reg
iste
r
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
13
Master Clock• Instructions Executed step by step• Need a “Rhythm” Generator to move forward in the
steps:
TimeClock Cycle
Every CPU needs a Clock to control the transition from one execution step to the next
Clock Frequency = 1/Clock Cycle Period : MHz
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
14
Instruction Set• Instruction Set is the Catalog of the CPU• Defines what are ALL the possible
operations that the CPU can execute• Only Instructions are recognized by CPU.• CPU does NOT “understand” High Level
Language (text).• CPU understands instructions coded in
numbers called machine code.
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
15
Instruction parameters• Each Instruction specifies an action or a suite of
actions:– Action(s) “identifier” or Operation Code or Opcode– Action arguments or operands– Methods specifying how to access the operands,
called addressing modes
Instruction specified as:<Opcode> <Operand 1, addr_mode1> <Operand 2, addr_mode2> ….
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
16
Addressing Modes• Direct
• Indirect
• Indexed
• Immediate
• Register
• Inherent
• Combination of the above (some)
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
17
Number of Operands• Many types of Instruction Sets
• Instruction Set with One Operand: Implicit Register Called Accumulator. Everything goes to and from the accumulator:
• Instruction Set with Two Operands: Many registers can be used as accumulators
• Instruction Set with Three Operands: Mainly Register Based.
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
18
Instruction Format• Specifies the map of the instruction at the code machine
level.• Formatted scheme for the instruction word(s)• Considers a word (or multiple words) in memory as a
single instruction composed of different contiguous bit-fields containing the opcode and the different operands and their addressing modes
• Many formats can co-exist in the same instruction set• Opcode value determines remaining format
Opcode Reg Immediate
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
19
CPU Execution• Executes Instruction by Instruction• Instructions stored in Memory• Capable of doing a certain number of operations
(Defined by Instruction Set)
• Get Instruction from Memory• Recognize What instruction it is• Activates the associated set of commands (step-by-step)
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
20
Fetch – Decode - Execute
Fetch
Decode
Execute
CpuMemory
Address of next Instruction
Instruction
Read Command
Opcode Reg Immediate
InstructionDecoder
Fetch
Decode
Execute
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
21
Address of Programs• Where the Address of next instruction is Stored ?
Need for an Instruction PointerCalled: “Program Counter”
PC
• Critical Component of CPU• Conveniently useful for changing program
sequence (Branch instructions)
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
22
Instruction Register• Where is the current instruction going to be stored during
its execution ?Need for a RegisterCalled: “Instruction Register”
• Critical Component of CPU• Internal Register. Cannot be used
(accessed) by instructions• Holds the current instruction until its
execution is completed• Tightly Coupled to the decoding
portion of the control unit• Connected to the datapath (to transfer
operand fields)
Opcode Op1 Op2
Instruction Decoder
Data Bus
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
23
Program in Memory• Binary code (machine code).
B8
00
05
MOV AX,5
03
C3ADD AX,BX
EB
E7JMP Next
Memory (8-bit)
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
24
High Level Languages• Machine independent. • Cannot be run directly on the target machine• Need to be translated to machine language • Compiler: program that translates a HLL program to a machine
language program of a specific platform • The Machine language program produced by the compiler is the
executable program.• Translating HLL programs to machine language programs is not a
one-to-one mapping– A HLL statement translated to one or more machine language
instructions– Usually, machine language programs produced by compilers are not
efficient• Deals with Data types (integer, real, complex, user-defined) vs.
machine language: no data types only binary words.
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
25
Assembly Language• Text version of machine language• Human friendly representation of machine
language• Based on mnemonics (easy to memorize
abbreviations of actions) instead of dealing with opcode numbers.
• Complicated format simplified with some conventions
• Text file translated into machine code by the Assembler
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
26
Assembler• Program that assemble the
programs written in assembly language into machine language
• Because there is a ONE to ONE mapping between instructions written in assembly language and machine language instructions, the process is called: assembly rather than translation.
• Disassembly (reverse process) is also easy because of the ONE to ONE relation between the assembly language instructions and the machine language instructions
MOV DX, 1
MOV AX, BX
MOV AX, CX
MOV AX, DX
ADD AX, 1
ADD AX, 2
ADD AX, BX
ADD AX, CX
ADD AX, i
SUB AX, 1
SUB AX, BX
ADD AX, 1234h
BA 0001
8B C3
8B C1
8B C2
83 C0 01
83 C0 02
03 C3
03 C1
03 06 0000
83 E8 01
2B C3
05 1234
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
27
Linker
• Program used to link together separately assembled/compiled programs into a single executable code
• Allows the programmers to develop different parts of a large program separately, test them separately and ‘freeze’ them for future use.
• Allows the programmer to develop store portions of programs that have been intensively tested and used into a “program library” for anyone to re-use them.
• Produces modular programs and greatly enables the management of large programming projects
COE 205COE 205
King Fahd University of Petroleum and MineralsKing Fahd University of Petroleum and Minerals
Computer Engineering Department
Computer Engineering Department
College of ComputerScience And Engineering
College of ComputerScience And Engineering
Lectures 2 & 3 – Computer Organization
28
Debugger/Monitor
These are tools that allow the assembly programmers to:• Display and alter the contents of memory and registers
while running their code, • Perform disassembly of their machine code (show the
assembly language equivalent),• Permit them to run their programs, stop (or halt) them,
run them step-by-step or insert break points.– Break points: Positions in the program that if are encountered
during run time, the program will be halted so the programmer can examine the memory and registers contents and determine what went wrong.