Professional Documents
Culture Documents
Memory, I/O
devices
CPU Data bus Data bus
MAR PC SP
MDR
Internal bus Data bus
Rn
GPR’s
R1
R0
IR
Control bus
ALU Flags CU
Processor, CPU
SPRs of a CPU
• MAR: holds the address of memory (or I/O device) that is currently
being accessed by the processor
• MDR: holds the data that is currently being read or written by the
processor
• IR: holds that machine code of the instruction that is currently being
executed
• PC: holds the address of the next instruction to be fetched (or
executed). Its value is calculated and updated after every instruction
fetch.
• SP: Stack pointer
SPRs of a CPU
• Flags: indicate the arithmetic status of the last result of the processor
• Carry flag; C = 1, if result of the addition (or subtraction) generated a carry (or
borrow)
C = 0, V = 1, S = 1, Z = 0 C = 0, V = 1, S = 0, Z = 0
MAR PC SP
MDR
Internal bus Data bus
Rn
GPR’s
R1
R0
IR
Control bus
ALU Flags CU
Processor, CPU
Accumulator based CPU
latch Accumulator
latch
Stack based CPU
latch latch
latch latch
stack
stack
ALU Memory
ALU Memory
latch stack pt
latch stack pt
Which architecture is better?
• We have three choices:
1. A stack architecture
2. An accumulator architecture
3. A general purpose register architecture.
• In choosing one over the other, the tradeoffs are simplicity (and cost)
of hardware design with execution speed and ease of use.
• Accumulator architecture is also called as ‘Load-store architecture’
Memory-Memory: Pros and Cons
• Pros
• Requires fewer instructions (especially if 3 operands)
• Easy to write compilers for (especially if 3 operands)
• Cons
• Very high memory traffic (especially if 3 operands)
• With two memory operands, more data movements are required
• Variable number of clocks per instruction
Memory-Register: Pros and Cons
• Pros
• Some data can be accessed without loading
• Instruction format is easy to encode
• Good code density
• Cons
• Operands are not equivalent (poor orthogonality)
• Variable number of clocks per instruction
• May limit number of registers
Accumulators: Pros and Cons
• Pros
• Very low hardware requirements
• Easy to design and understand
• Simple instruction encoding
• Instructions take similar number of cycles
• Cons
• Higher instruction count
• Accumulator becomes the bottleneck
• High memory traffic
• Little ability for parallelism or pipelining
• Dependent on good compiler
Stacks: Pros and Cons
• Pros
• Good code density (implicit operand addressing top of stack)
• Low hardware requirements
• Easy to write a simple compiler for stack architectures
• Cons
• Stack becomes the bottleneck
• Data is not always at the top of stack when need, so additional instructions
like TOP and SWAP are needed
• Little ability for parallelism or pipelining
• Difficult to write an optimizing compiler for stack architectures
Registers: Advantages and Disadvantages
• Advantages
• Faster than cache (no addressing mode or tags)
• Reduce memory traffic
• Short identifier (typically 3 to 8 bits)
• Deterministic (no misses)
• Can replicate (multiple read ports)
• Disadvantages
• Need to save and restore on procedure calls and context switch
• Fixed size (can’t store strings or structures efficiently)
• Compiler must manage
• Can’t take the address of a register (for pointers)
Summarizing
• In stack architecture, instructions and operands are implicitly taken from
the stack.
• A stack cannot be accessed randomly.
• In accumulator architecture, one operand of a binary operation is
implicitly specified in the accumulator.
• One operand usually is in memory, creates lot of bus traffic.
• In general purpose register (GPR) architecture, registers can be used
instead of memory.
• Faster than accumulator architecture.
• Efficient implementation for compilers.
• Results in longer instructions.
Classifying ISAs