CPU1
CPU1
• Introduction
• Stack Organization
• Instruction Formats
• Addressing Modes
• Program Control
Introduction
Execution(Processing) Components
Arithmetic Logic Unit(ALU)
Arithmetic calculations, Logical computations, Shifts/Rotates
Transfer Components
Bus
Control Components
Control Unit
CPU – Designer Point of View –
the computer instruction set provides the specifications Register
File ALU
for the design of the CPU
User – Programmer – Point of View
- aware of the register set, the memory structure, the
type of data supported by the instructions, and the
function that each instruction performs
- 1) Instruction Formats Control Unit
- 2) Addressing Modes
- 3) Register Sets
GENERAL REGISTER ORGANIZATION
• Register
– Memory locations are needed for storing pointers, counters, return
address, temporary results, and partial products during multiplication
– Memory access is the most time-consuming operation in a computer
– More convenient and efficient way is to store intermediate values in
processor registers
• When a large number of registers are included in the CPU, it is
most efficient to connect them through a common bus system.
• The registers communicate with each other not only for direct
data transfers, but also while performing various
microoperations.
• A common unit that can perform all the arithmetic, logic, and
shift microoperations in the processor.
GENERAL REGISTER ORGANIZATION
Input
Clock
R1
R2
R3
R4
R5
R6
R7
Load
}
(7 lines)
SELA { MUX MUX SELB
3x8
A bus B bus
decoder
SELD
OPR ALU
Output
GENERAL REGISTER ORGANIZATION
• Bus organization for 7 CPU registers
–2 MUX : select one of 7 register or external data
input by SELA and SELB
–BUS A and BUS B : form the inputs to a
common ALU
–ALU : OPR determine the arithmetic or logic
microoperation
» The result of the microoperation is available for external
data output and also goes into the inputs of all the
registers
–3 X 8 Decoder : select the register (by SELD)
that receives the information from ALU
GENERAL REGISTER ORGANIZATION
• Example operation
– R1 R2 + R3
• Binary selector input :
– 1) MUX A selector (SELA) : to place the content of R2 into BUS A
– 2) MUX B selector (SELB) : to place the content of R3 into BUS B
– 3) ALU operation selector (OPR) : to provide the arithmetic addition R2 + R3
– 4) Decoder selector (SELD) : to transfer the content of the output bus into R1
The four control selection variables are generated in the control unit
and must be available at the beginning of a clock cycle.
The data from the two source registers propagate through the gates in
the multiplexers and the ALU, to the output bus, and into the inputs of
the destination register, all during the clock cycle interval.
When the next dock transition occurs, the binary information from the
output bus is transferred into R 1.
Control
Stack pointer 4
SP C 3
B 2
A 1 Push, Pop operations
0
DR /* Initially, SP = 0, EMPTY = 1, FULL = 0 */
PUSH POP
SP ← SP + 1 DR ← M[SP]
M[SP] ← DR SP ← SP - 1
If (SP = 0) then (FULL ← 1) If (SP = 0) then (EMPTY ← 1)
EMPTY ← 0 FULL ← 0
MEMORY STACK ORGANIZATION
1000
Memory with Program, Data, PC
Program
(instructions)
and Stack Segments
Data
AR (operands)
SP 3000
stack
3997
3998
3999
4000
4001
- A portion of memory is used as a stack with a DR
processor register as a stack pointer
- PUSH: SP ← SP - 1
M[SP] ← DR
- POP: DR ← M[SP]
SP ← SP + 1
- Most computers do not provide hardware to check stack overflow (full stack) or underflow
(empty stack)
Stack Organization
(3 * 4) + (5 * 6) ⇒ 34*56*+
6
4 5 5 30
3 3 12 12 12 12 42
3 4 * 5 6 * +
Problems
• A bus-organized CPU has 16 registers with 32 bits in each, an ALU, and a destination
decoder.
– a. How many multiplexers are there in the A bus, and what is the size of each multiplexer?
– b. How many selection inputs are needed for MUX A and MUX B?
– c. How many inputs and outputs are there in the decoder?
– d. How many inputs and outputs are there in the ALU for data, including input and output
carries?
– e. Formulate a control word for the system assuming that the ALU has 35 operations
• Solution
– (a) 32 multiplexers, each of size 16 × 1.
(b) 4 inputs each, to select one of 16 registers.
(c) 4-to-16 – line decoder
(d) 32 + 32 + 1 = 65 data input lines
32 + 1 = 33 data output lines.
(e)
• Specify the control word that must be applied to the processor of to implement the
following microoperations.
– R1 R2 + R3
– R4 R4’
– R5 R5 -1
– R6 SHL R1
– R7 INPUT
Determine the microoperations that will be executed in the processor when the following
14-bit control words are applied.
a. 00101001100101 b. 00000000000000
c. 01001001001100 d. 00000100000010
e. 11110001110000
Convert the following numerical arithmetic expression into reverse Polish
notation and show the stack operations for evaluating the numerical result.
(3 + 4)[10(2 + 6) + 8]