The document discusses the central processing unit (CPU) and its major components: the control unit, arithmetic logic unit (ALU), and register set. It also covers general register organization and bus connections, as well as stack organization using a stack pointer and the push and pop operations. Finally, it describes reverse polish notation and how stacks can be used to evaluate arithmetic expressions in this notation.
1. 12/14/2014
1
Computer Organization
Instructors :
Dr. Abdul Raouf Khan
Mr.Marwan El-Haj
Central Processing Unit
The Central Processing Unit is made of three
major parts, as shown below.
Control
Arithmetic
Logic Unit
(ALU)
Register Set
2. 12/14/2014
2
Central Processing Unit
The register set stores intermediate data
used during the execution of the instructions.
ALU performs the required microoperation
for executing the instruction.
The control unit supervises the transfer of
information among the registers and instructs
the ALU as to which instruction to perform
Central Processing Unit
Computer architecture is sometimes defined
as the computer structure and behavior as
seen by programmer that uses machine
language instructions. This include the
instruction formats, addressing modes, the
instruction set, and the general organization
of the CPU registers.
3. 12/14/2014
3
General Register Organization
Referring Memory repeatedly is time consuming
Intermediate values can be stored in registers
large number of registers are included in CPU,
connected through bus
Registers can communicate with each other
A bus organization for seven registers is shown
next
4. 12/14/2014
4
General Register Organization
The control Unit directs the operations e.g.
To perform R1 R2+R3
1. MUX A selector (SELA): to place the contents of R2
into bus A
2. MUX B selector (SELB): to place the contents of R3
into bus B
3. ALU operation selector (OPR): to provide arithmetic
addition A+B
4. Decoder destination selector (SELD): to transfer the
content of the output bus into R1.
Stack Organization
Stack is a storage device (memory) that
stores information in such a manner that the
items stored last is retrieved first. Also known
as LIFO (Last-In-First-Out)
The register that holds the address of the top
of the stack is called Stack Pointer (SP).
The two operations of stack are insertion and
deletion of items known as PUSH & POP.
5. 12/14/2014
5
Push operation
1. If (Full=0)Then ‘Check Stack Not Full
1. Begin
2. SP SP + 1 ‘Increment stack pointer
3. M[SP] DR ‘write on top of stack
4. If (SP=0) then FULL 1 ‘Check if stack is full
5. EMPTY 0 ‘Mark the stack not empty
6. End
6. 12/14/2014
6
POP Operation
1. If (Empty=0)Then ‘Check if Stack not Empty
1. Begin
2. DR M[SP] ‘Read from top of stack
3. SP SP-1 ‘Decrement stack pointer
4. If (SP=0) then EMPTY 1 ‘Check if stack is empty
5. FULL 0 ‘Mark the stack not Full
6. End
Memory Stack
A stack can exist as a stand-alone unit as
shown above or can be implemented in a
random access memory attached to CPU.
The implementation of a stack in the CPU is
done by assigning a portion of memory to
stack operation and using a processor
register as stack pointer.
See figure next
7. 12/14/2014
7
Reverse Polish Notation
A stack operation is very effective in
evaluating arithmetic expressions.
Infix Notation A + B
Prefix or polish Notation + AB
Postfix or reverse polish notation AB+
Reverse polish notation is in a form suitable
for stack manipulation
8. 12/14/2014
8
Examples
Infix (A * B) + (C * D)
Postfix AB * CD * +
Infix (A+B) * [C * (D + E) + F]
Postfix AB + DE + C * F + *
Evaluation of arithmetic expression
First Arithmetic expression is converted to
reverse polish notation
Operands are pushed into the stack in the
order of appearance
Two topmost operands in the stack are used
for operation
The stack is popped & the result of the
operation replaces the lower operand
The expression is evaluated in this order &
final result remains in the top of stack