CO Unit 5
CO Unit 5
CPU Organization
1.Introduction
1. Register set
2.Control unit (CU)
3. Arithmetic and logic unit(ALU)
Register set stores intermediate values used during the execution of the program.
ALU executes the microperations. CU generates the control signal related to
micro operation. CU controls the transfer of information among the registers
and selects which operation to be performed by ALU.
The design of CPU involves choosing hardware for implementing the machine
instructions. Assembly language Programmer must be aware of the register set,
memory structure, the type of data supported by the instructions, and the
function that each instruction performs.
The above diagram consists of 7 registers which are connected to 2 multiplexers (MUX)
to form Bus A and Bus B. The select lines (SELA and SELB ) are used to select the
registers to input data to ALU through Bus A and Bus B.
The ALU performs arithmetic and logical microoperations and generates output. One
copy of the output is stored in the register .
The combined value of SELA( 3bits), SELB( 3bits), SELD( 3bits), OPR (5 bits) (i.e,
3+3+3+5= 14 bits ) is called control word.SELA and SELB selects input registers,
SELD selects the output register.
The following statements demonstrate the sequence of steps that are used to perform
microoperation.
For Example to perform the operation R1 ¬ R2 + R3 , the sequence of steps will be
1MUX A selector (SELA): Here BUS A ¬R2
●
2MUX B selector (SELB): Here BUS B ¬R3
3ALU operation selector (OPR): Here 00010 is fed through OPR to perform addition
by ALU.
4 Decoder destination selector (SELD): Selects the register that must store the output.
This is decided by the SELD input given to 3x8 decoder .Here Output generated after
the execution of micro operation is loaded into R1 .
A memory unit that stores control word is known as control memory. By reading
consecutive control words, we can generate desired sequence of micro operations. This
type of generating control words is known as Micro programmed control.
Q)Explain about stack organization ? (or) What is stack and how stacks are organized
in system architecture.
Ans:
Stack: set of memory location in which data values are accessed using Last In First
Out Technique (LIFO) is called Stack. Stacks are
1.Very useful feature for nested subroutines, nested interrupt services.
2.Also efficient for arithmetic expression evaluation
3.Stack Pointer (SP) register holds the address of memory location containing top most
data item.
4.Only PUSH and POP operations are applicable
register stack.
A. Conclusion
Here DR is a data register used to store the data popped from top of stack. DR register
also holds the data to be pushed onto the stack.
Stack Pointer (SP) register holds the address of memory location containing top most
data item.
FULL and EMPTY are one bit registers or Flags. FULL is set to 1 when the stack is
full and EMPTY is set to 1 when the stack is empty. The first item stored in the stack
is at address 1. The last item is stored at address 0. If SP reaches 0, the stack is full, so
FULL is set to 1
In 64-word stack, the SP contains 6 bits because 2 = 64 .The first item stored in the
6
stack is at address 1. The last item is stored at address 0. When SP=63 and SP← �� +
1 , the result is 0 as 111111+1=1000000 in binary. But SP =0 as SP can hold 6 least
significant bits(LSB). Also when SP=0 and �� ← �� − 1 then 000000-1=111111
therefore, SP=63.
A portion of main memory is used as stack and processor register as SP. Below figure
shows portion of main memory divided into 3 segments -program, data and stack
segments. The initial value of SP is 4001 and the stack grows with decreasing
addresses.
Thus the first item stored in the stack
is at address 4000, the second item is
stored at address 3999, and the last
address that can be used for the
stack is 3000.
Most computers do not provide hardware to check stack overflow (full stack) or
underflow (empty stack). Limit checking must be done in software using 2 processor
registers. One register to hold upper limit (i.e, 3000 in this case) and another to hold
lower limit.
Stack Organization is good for evaluating arithmetic expressions. Common
arithmetic expressions are written in infix notation.
Multiplication and division are performed before addition and subtraction. The
following diagram represents evaluation of arithmetic expression using stack.
The above expression is evaluated from left to right. The operands are pushed onto the
stack and the arithmetic operations are performed on the top 2 elements of the stack,
the result is again pushed back onto stack.
Ans: Consider the expression (A + B) * [C * (D + E) + F]
we must first perform the arithmetic inside the parentheses (A + B) and (D + E).
So, AB+DE+
Next we must calculate the expression inside the square brackets.
The multiplication of C * (D + E) must be done prior to the addition of F since
multiplication has precedence over addition. So, AB+DE+C*F+
The last operation is the multiplication of the two terms between the parentheses
and brackets
The converted expression is A B + D E + C * F + *
The expression can be converted to reverse Polish notation, without the use of
parentheses, by taking into consideration the operation hierarchy.
Q)What are the common fields found in an instruction?
Ans: The bits of the instruction are divided into groups called fields. The most common
fields found in instruction formats are:
1.operation code field (op-code field) that specifies the operation to be performed.
2.An address field that has a memory address or a processor register depending on
mode field.
3.A addressing mode field that specifies determines how the address field is to be
interpreted (to get effective address or the operand)
Q)Explain about the most common processor organizations. (or) What are 1-address ,
2- address, 3- address and zero-address instructions. (or) Explain about various types of
instruction formats.
Ans:
Most common fields in instruction are op-code field, address field and addressing
mode field. The number of address fields in the instruction format depends on the
internal organization of CPU. Most computers fall into one of the 3 types of CPU
organizations. They are
1.Single register (Accumulator) organization
2.General register organization
3.Stack organization
1.Single register (Accumulator) organization: Accumulator is the only general purpose
register.
Example : ADD X /* AC <-- AC + M[X] */ One address instruction
here AC is the accumulator and M[X] is the memory word located at address X.
Since the instruction has one address field, ADD X is a one –address instruction
2. General register organization employs two or three address fields in their instruction
format. Each address field may specify a processor register or a memory word. Any of
the registers can be used as the source or destination for computer operations.
ADD R1, R2, R3 /* R1 ← R2 + R3 */
ADD R1, R2, R3 is three address instructions as it has 3 register address fields R1,R2
and R3. First address field R1 is the destination and remaining address fields(R2 and
R3) are sources.
Q) Convert the expression from infix to postfix or reverse polish notation
depends on the internal organization of the CPU. Most computers fall into one of
the 3 types of CPU organizations. They are
1. Single register (Accumulator) organization
2. General register organization
3. Stack organization
ADD R1, R2 /* R1 R1 + R2 */
MOV R1, R2 /* R1 R2 */
MO R1, A R1 ← M[A]
V
ADD R1, B R1 ← R1+M[B]
MUL R1, R2 R1 ← R1 * R2
MO X, R1 M[X]<-- R1
V
The first symbol listed in an instruction is assumed to be both a source and the
destination where the result of the operation is transferred
·One- Address Instructions
LOAD A AC ← M[A]
STORE T M[T] ← AC
ADD D AC ← AC + M[D]
STORE X M[X] ← AC
PUSH A TOS ← A
PUSH B TOS← B
ADD TOS ← (A + B)
PUSH C TOS ← C
PUSH D TOS← D
ADD TOS ← (C + D)
MUL TOS ← (C + D) * (A + B)