Professional Documents
Culture Documents
Architectures
Source:
Null and Lobur. The Essentials of Computer Organization and
Architecture. Chapter 5
Operations
Types of operations
Which operations are allowed to access memory
Design decisions
Instruction set must match the architecture
Factors
Amount of space a program requires
Complexity of the instruction set
Amount of decoding necessary
Complexity of the tasks performed by the instruction
Trade-offs
Short vs. long instructions
Short:
less space and fetched quickly
Limits the number of instructions as well as the size and number of operands
Fixed length but expandable when it comes to the number of operands (expanding
opcode)
Number of addressing modes
Big-endian or little-endian?
How many registers?
How should they be organized?
How should operands be stored in the CPU?
Accumulator architecture
One operand is implicitly in the accumulator
Reduces complexity
Memory traffic is high
Variable length
More complex to decode
Saves storage space
Opcode
Opcode
Opcode
Opcode
only
+ 1 address
+ 2 addresses
+ 3 addresses
Comparison of architectures
treatment of opcodes
Stack architecture
Expanding opcodes
Number of operands is dependent on the instruction length.
Not all instructions have the same number of operands.
Expanding opcodes: compromise solution between rich set of
opcodes (opcodes which contain a complex set of instructions) and
having short opcodes
Short opcode: many operands
Rich set: all the bits can be used for unique instructions
15
14
31
16
instructions
instructions
instructions
instructions
with
with
with
with
three addresses
two addresses
1 address
0 addresses
An implementation of the
specifications
15 3-address codes
0000 R1 R2 R3 (where each Rn is 4 bits) 1110 R1 R2 R3
14 2-address codes
1111 0000 R1 R2 --- 1111 1101 R1 R2
31 1-address codes
1111 1110 0000 R1 --- 1111 1111 1110 R1
16 0-address codes
1111 1111 1111 0000 ---- 1111 1111 1111 1111
Instruction Types
Data Movement
Arithmetic Operations
Boolean Logic Instructions
Bit Manipulation Instructions
Input/Output Instructions
Instructions for Transfer of Control
Special Purpose Instructions
Orthogonality
No redundancy in instructions
Instruction set must be consistent
Addressing modes of operands must be independent from the operands
Consequences:
Facilitates language compiler construction
Long instruction words
Longer programs
More memory use
Address Modes
Immediate addressing: value follows the opcode
Direct addressing: value obtained by the specified memory
address in the instruction
Register addressing: register is used to specify the operand
Pipelining
Fetch-decode-execute: normally each clock pulse controls a step
What if the steps are broken down into smaller steps, and some steps
can be performed in parallel?
Ministeps:
1.
2.
3.
4.
5.
6.
Fetch instruction
Decode opcode
Calculate effective address of operands
Fetch operands
Execute instruction
Store result
Cycle 2
Cycle 3
Cycle 4
Cycle 5
Cycle 6
Cycle 7
Cycle 8
S1
S2
S3
S4
S5
S6
S1
S2
S3
S4
S5
S6
S1
S2
S3
S4
S5
S6
S1
S2
S3
S4
S5
Cycle 9
Instruction 1
Instruction 2
Instruction 3
Instruction 4
S6
Speedup computation
Speedup is affected by the number of stages.
For a k-stage pipeline
Assume a clock cycle time of tp, i.e. it takes tp time per stage.
Assume n instructions (tasks) to process.
Thus, it takes Task 1 k x tp time to complete
The remaining n 1 tasks emerge from the pipeline one per cycle,
thus the total time for these tasks of (n 1)tp.
Thus, to complete n tasks using a k-stage pipeline requires
(k x tp) + (n 1) tp = (k + n 1) tp
or
k + (n 1) clock cycles
Speedup computation
Without
a pipeline, for n instructions require ntn cycles,
where tn = k x tp
To compute speedup, we divide the time required if there is
no pipeline by the time required if there is a pipeline:
Thus as , we see that approaches n, which results in a
theoretical speedup of
where k is the number of stages in the pipeline.
Constraints of pipelining
Resource conflicts (structural hazards)
Data dependencies
Conditional branch statements
Proposed solutions
Branch prediction
Delayed branch (compiler resolution through a rearrangement of the
machine code)
IP addresses