Professional Documents
Culture Documents
CH 3
CH 3
Programming in Hardware
Sequence of
Arithmetic
Data Results
and Logic
Functions
Program/Software:
A sequence of codes or instructions
2. Function of Control Unit
• For each operation a unique code is
provided
e.g. ADD, MOVE
• A hardware segment accepts the code and
issues the control signals
Instruction Instruction Control
Codes Interpreter Signals
1010…0110
3.2 Computer Function
• Basic function of a computer is execution of a
program
• A program is a sequence of instructions
Execution of instructions
Fetch: processor reads instruction from memory
one at a time.
Execution: processor interprets instruction and
perform operation
1. Basic Instruction cycle
4bits 12bits
Opcodes:
Instruction Opcode Address
0001 = Load AC from Memory
1bit 15bits 0010 = Store AC to Memory
Operand S Magnitude 0101 = Add to AC from Memory
Example of Program Execution
2/3
Memory CPU Registers Memory CPU Registers
300 1 9 4 0 3 0 1 PC 300 1 9 4 0 3 0 12 PC
301 5 9 4 1 0003 AC 301 5 9 4 1 00 00 00 53 AC
302 2 9 4 1 IR 302 2 9 4 1 5941 IR
4bits 12bits
Opcodes:
Instruction Opcode Address
0001 = Load AC from Memory
1bit 15bits 0010 = Store AC to Memory
Operand S Magnitude 0101 = Add to AC from Memory
Example of Program Execution
3/3
Memory CPU Registers Memory CPU Registers
300 1 9 4 0 3 0 2 PC 300 1 9 4 0 3 0 32 PC
301 5 9 4 1 0005 AC 301 5 9 4 1 0 0 0 5 AC
302 2 9 4 1 IR 302 2 9 4 1 2941 IR
4bits 12bits
Opcodes:
Instruction Opcode Address
0001 = Load AC from Memory
1bit 15bits 0010 = Store AC to Memory
Operand S Magnitude 0101 = Add to AC from Memory
2. Instruction Cycle State Diagram
Instruction Operand
fetch Operand
fetch Store
Multiple Multiple
Operands Results
① ④
I/O Command
WRITE OP
② ⑤
WRITE END
WRITE
Program Flow of Control With interrupts
User Program I/O Program
① ④
WRITE
Short I/O wait
OP
OP
① ④
⑤
③
END
resume
Interrupt Cycle -Operations
-- Added to instruction cycle --
• Processor checks for interrupt request
o Indicated by an interrupt signal
• If no interrupt, fetch next instruction
• If interrupt pending:
o Suspend execution of current
o Save context
o Set PC to start address of interrupt handler routine
o Process interrupt
o Restore context and continue interrupted program
Instruction Cycle (with Interrupts) - State
Diagram
Instruction Operand
fetch Operand
fetch Store
Multiple Multiple
Operands Results
No
Instruction Complete Return for String
Interrupt
Fetch Next Instruction or Vector Data
Multiple Interrupts
• Disable interrupts
• Processor will ignore further interrupts whilst
processing one interrupt
• Interrupts remain pending and are checked after
first interrupt has been processed
• Interrupts handled in sequence as they occur
• Define priorities
• Low priority interrupts can be interrupted by
higher priority interrupts
• When higher priority interrupt has been processed,
processor returns to previous interrupt
Multiple Interrupts – Sequential
User Program Interrupt Handler X
Interrupt Handler Y
Multiple Interrupts – Nested
Interrupt Handler Y
3.3 Interconnection Structures
• All the units must be connected
• Different types of connection for different
types of units
o Memory
o Input/Output
o CPU
Interconnection Structures:
The collection of paths connecting the
various modules
1. Memory Connection
Data Bus
• Data lines of a bus
• Carries data
o Remember that there is no difference between “data” and
“instruction” at this level
• Bits be transferred at a time
• Width is a key determinant of performance
o 8, 16, 32, 64 bit
Address bus
Control lines
Data lines
Address lines
Operation of the Bus
Local I/O
Main
controller
Memory
System Bus
Expansion Bus
5. Elements of Bus Design
• Bus Type
• Method of Arbitration
• Timing
• Bus Width
Bus Types
• Dedicated
Separate data & address lines
• Multiplexed
o Shared lines
o Address valid or data valid control line
o Advantage - fewer lines
o Disadvantages
More complex control
Ultimate performance
Bus Arbitration
Master device
Slave device
Centralised Arbitration