Comp Arch Chapter 2
Comp Arch Chapter 2
In this chapter:
Structure and Function
Basic Computer Components and
Function
Instruction Cycle & Interrupts
Computer Structure and Function 3
The computer
Contd… 6
Another alternative:
General purpose configuration of components (ALU)
System accepts data and control signals and produce
results
New set of control signals instead of rewiring hardware
how control signals are supplied:
o The entire program is sequence of steps
o For each step, new set of control signals is needed
o Provide a unique code for each possible set of
control signals
o The sequence of codes/instructions is called
software.
12
Computer components
Fetch Cycle
Program Counter (PC) holds address of next instruction
to fetch
Processor fetches instruction from memory location
pointed to by PC
Increment PC
o Unless told otherwise
Instruction loaded into Instruction Register (IR)
Processor interprets instruction
Instructions contain bits that specify action the
processor is to take
These actions fall into 4 categories: Processor-memory,
processor I/O, Data processing, Control
Instruction cycle 17
Execute cycle:
Processor-memory
o Data transfer between CPU and main memory
Processor I/O
o Data transfer between CPU and I/O module
Data processing
o Some arithmetic or logical operation on data
Control
o Alteration of sequence of operations
o e.g. jump
Instruction execution may involve combination of the
above
18
Example of ProgramExecution
Example – consider the following machine:
Example of ProgramExecution 19
Program:
AC ← M(940)
AC ← AC +
M(941)
M(941) ← AC
Instruction Cycle State Diagram 20
Interrupts 21
Interrupt
Mechanism by which various events (e.g. I/O) may
interrupt normal sequence of processing
Classes of interrupts:
o Program
• Overflow, division by zero, etc.
o Timer
• Generated by internal processor timer
• Used in pre-emptive multi-tasking
o I/O
• From I/O controller
o Hardware failure
• Memory parity error, etc.
Interrupts 22
Interrupt Cycle
Added to instruction cycle
Processor checks for interrupt
Indicated by an interrupt signal
If no interrupt, fetch next instruction
If interrupt pending:
Suspend execution of current program
Save context
Set PC to starting address of interrupt handler
routine
Process interrupt
Restore context and continue interrupted
program
Interrupts 23
Instruction cycle with interrupt 24
State diagram with interrupt 25
26
Reading Assignment
Multiple Interrupts