COA_Unit-2
COA_Unit-2
(3140707)
Unit-2
Basic Computer Organization and Design
Vrunda Joshi
Assistant Professor
IT Department
V.V.P. Engineering College, Rajkot
Outline
● Instruction codes
● Computer registers
● Computer instructions
● Timing and Control
● Instruction cycle
● Register-Reference Instructions
● Memory-Reference Instructions
● Input-output and interrupt
● Interrupt Cycle
● Design of Basic computer
● Design of Accumulator Unit.
Instruction codes
Instruction codes
● Program:
➢ A program is a set of instructions that specify the operations, operands and the
sequence by which instructions are to be executed.
● Computer Instruction:
➢ A computer instruction is a binary code that specifies a sequence of micro-operations
for the computer.
● Instruction Code:
➢ An instruction code is a group of bits that instruct the computer to perform a specific
operation.
➢ Example: ADD B
Instruction codes
● Operation Code (Opcode):
➢ The operation code of an instruction is a group of bits that define such operations as
add, subtract, multiply, shift, and complement.
➢ The number of bits required for the operation code of an instruction depends on
the total number of operations available in the computer.
➢ The operation code must consist of at least n bits for a given 2n (or less) distinct
operations.
● Example: consider a computer with 64 distinct operations, one of them being ADD
operation. The operation code consists of six bits, with a bit configaration 110010
assigned to ADD operation.
➢ When this operation code is decoded in the control unit, the computer issues control
signals to read an operand from memory and add the operand to a register.
Stored Program Organization
● The simplest way to organize a
computer is to have one processor
register and an instruction code
format with two parts.
● The first part specifies the operation
(opcode) to be performed and the
second specifies an address (operand).
● The memory address tells the control
where to find an operand in memory.
● This operand is read from memory and
used as the data to be operated on
together with the data stored in the
processor register.
● Instructions are stored in one section of memory and
data in another.
● For a memory unit with 4096 words, we need 12 bits
to specify an address since 212 = 4096.
● If we store each instruction code in one 16-bit memory
word, we have available four bits(24 = 16) for
operation code (opcode) to specify one out of 16
possible operations, and 12 bits to specify the address
of an operand.
● The control reads a 16-bit instruction from the
program portion of memory.
● It uses the 12-bit address part of the instruction to read Example(Opcode):
● The last three waveforms shows how SC is cleared when D3T4= 1. Output D3 from the
operation decoder becomes active at the end of timing signal T2. When timing signal T4
becomes active, the output of the AND gate that implements the control function D3T4
becomes active.
● This signal is applied to the CLR input of SC. On the next positive clock transition the
counter is cleared to 0. This causes the timing signal T0 to become active instead of T5
that would have been active if SC were incremented instead of cleared.
Instruction cycle
Instruction Cycle
● A program residing in the memory unit of the computer consists of a sequence of
instructions.
● The program is executed in the computer by going through a cycle for each instruction.
● Each instruction cycle consists of the following phases:
1. Fetch an instruction from memory.
2. Decode the instruction(Determing which operation is to be executed).
3. Read the effective address from memory if the instruction has an indirect address.
4. Execute the instruction.
● Upon the completion of step 4, the control goes back to step 1 to fetch, decode, and
execute the next instruction.
● This process continues indefinitely unless a HALT instruction is encountered.
Fetch and Decode
● Initially, the program counter PC is loaded with the address of the first instruction in the
program.
● The sequence counter SC is cleared to 0, providing a decoded timing signal T0.
● After each clock pulse, SC is incremented by one, so that the timing signals go through a
sequence T0, T1, T2, and so on.
● Microoperations for the fetch and decode phases:
Fetching T0 : AR<-PC
Fetching T1 : IR<-M[AR], PC<-PC + 1
Decoding T2 : AR <-IR(0-11), D0,........,D7<-Decode IR(12-14), I<-IR(15)
● Since only AR is connected to the address inputs of memory with timing signal T0.
● The instruction read from memory is then placed in the instruction register IR with the
clock transition associated with timing signal T1. At the same time, PC is incremented by
one to prepare it for the address of the next instruction in the program.
● At time T2, the operation code in IR is decoded, the indirect bit is transferred to flip-flop I,
and the address part of the instruction is transferred to AR. Note that SC is incremented
after each clock pulse to produce the sequence T0, T1 and T2 .
Register transfer for Fetch
phase
● Figure shows how first two register transfer
statements(T0 and T1) are implemented in
bus system.
● In order to implement the following
statement T0 : AR<-PC.
● It is necessary to use timing signal T0 to
provide the following connections in the bus
system.
1. Place the content of PC onto the bus by
making the bus selection inputs S2S1S0 equal
to 010.
2. Transfer the content of the bus to AR by
enabling the LD input of AR.
● The next clock transition initiates the transfer
from PC to AR since T0=1.
Register transfer for Fetch
phase
● In order to implement the second statement
T1 : IR<-M[AR], PC<-PC + 1.
● It is necessary to use timing signal T1 to
provide the following connections in the bus
system.
1. Enable the read input of memory.
2. Place the content of memory onto the bus by
making S2S1S0 =111.
3. Transfer the content of the bus to IR by
enabling the LD input of IR
4. Increment PC by enabling the INR input of
PC.
● The next clock transition initiates the read
and increment operations since T1= 1.
Register transfer for Fetch
phase
• The control function for this instruction uses the operation decoder D0 since this output of
the decoder is active when the instruction has an AND operation whose binary code value
is 000.
• Two timing signals are needed to execute the instruction.
• The clock transition associated with timing signal T4 transfers the operand from memory
into DR .
• The clock transition associated with the next timing signal T5 transfers to AC the result of
the AND logic operation between the contents of DR and AC.
• The same clock transition clears SC to 0, transferring control to timing signal T0 to start a
new instruction cycle.
2. ADD: ADD to AC
• This instruction adds the content of the memory word specified by the effective address to
the value of AC. The sum is transferred into AC and the output carry Cout is transferred to
the E (extended accumulator) flip-flop.
• The control function for this instruction uses the operation decoder D1 since this output of
the decoder is active when the instruction has an ADD operation whose binary code value
is 001.
• Two timing signals are needed to execute the instruction.
• The clock transition associated with timing signal T4 transfers the operand from memory
into DR .
• The clock transition associated with the next timing signal T5 transfers to AC the result of
the ADD operation between the contents of DR and AC.
• The same clock transition clears SC to 0, transferring control to timing signal T0 to start a
new instruction cycle.
3. LDA: Load to AC
• This instruction transfers the memory word specified by the effective address to AC.
• The effective address from AR is transferred through the common bus to PC. Resetting
SC to 0 transfers control to T0.
• The next instruction is then fetched and executed from the memory address given by the
new value in PC.
6. BSA: Branch and Save Return Address
• This instruction is useful for branching to a portion of the program called a subroutine or
procedure.
• When executed, the BSA instruction stores the address of the next instruction in
sequence (which is available in PC) into a memory location specified by the effective
address.
• The effective address plus one is then transferred to PC to serve as the address of the first
instruction in the subroutine.
• The BSA instruction performs the function usually referred to as a aubroutine call.
• The indirect BUN instruction at the end of the subroutine performs the function referred
to as a subroutine return.
BSA-Example
OR