IT18302 - Computer Organization and Architecture Lecture Notes Unit 1-Basic Computer Organization and Design
IT18302 - Computer Organization and Architecture Lecture Notes Unit 1-Basic Computer Organization and Design
Lecture Notes
Instruction Codes
The Internal organization of a digital system is defined by the sequence of microoperations it performs on data
stored in its registers. The user of a computer can control the process by means of a program
A program is a set of instructions that specify the operations, operands, and the processing sequence.
A computer instruction is a binary code that specifies a sequence of micro-operations for the computer. Each
computer has its unique instruction set.
Instruction codes and data are stored in memory. The computer reads each instruction from memory and places it
in a control register. The control unit interprets the binary code of the instruction and proceeds to execute it by
issuing a sequence of micro-operations.
An Instruction code is a group of bits that instructs the computer to perform a specific operation (sequence of
microoperations). It is divided into parts (basic part is the operation part).
The operation code of an instruction is a group of bits that defines certain operations such as add, subtract, shift,
and complement. The number of bits required for the operation code depends on the total number of operations
available in the computer. 2n (or little less) distinct operations n bit operation code
An operation must be performed on some data stored in processor registers or in memory. An instruction code
must therefore specify not only the operation, but also the location of the operands (in registers or in the
memory), and where the result will be stored (registers/memory). Memory words can be specified in
instruction codes by their address.
Processor registers can be specified by assigning to the instruction another binary code of k bits that specifies
one of 2k registers.
Each computer has its own particular instruction code format. Instruction code formats are conceived by
computer designers who specify the architecture of the computer.
1
IT18302-Computer Organization and Architecture-Lecture Notes
Indirect Address
There are three Addressing Modes used for address portion of the instruction code:
Immediate: the operand is given in the address portion (constant)
Direct: the address points to the operand stored in the memory
Indirect: the address points to the pointer (another address) stored in the memory that references the
operand in memory
One bit of the instruction code can be used to distinguish between direct & indirect addresses
• Effective address: the address of the operand in a computation-type instruction or the target address in a branch-
type instruction
• The pointer can be placed in a processor register instead of memory as done in commercial computers
Computer Registers
Computer instructions are normally stored in consecutive memory locations and executed sequentially one at a
time. The control reads an instruction from a specific address in memory and executes it, and so on. This type of
sequencing needs a counter to calculate the address of the next instruction after execution of the current instruction is
completed. It is also necessary to provide a register in the control unit for storing the instruction code after it is read
from memory. The computer needs processor registers for manipulating data and a register for holding a memory
address.
2
IT18302-Computer Organization and Architecture-Lecture Notes
3
IT18302-Computer Organization and Architecture-Lecture Notes
Computer Instructions
Hex Code
Symbol I=0 I=1 Description
AND 0xxx 8xxx AND memory word to AC
ADD 1xxx 9xxx Add memory word to AC
LDA 2xxx Axxx Load AC from memory
STA 3xxx Bxxx Store content of AC into memory
BUN 4xxx Cxxx Branch unconditionally
BSA 5xxx Dxxx Branch and save return address
ISZ 6xxx Exxx Increment and skip if zero
CLA 7800 Clear AC
CLE 7400 Clear E
CMA 7200 Complement AC
CME 7100 Complement E
CIR 7080 Circulate right AC and E
CIL 7040 Circulate left AC and E
INC 7020 Increment AC
4
IT18302-Computer Organization and Architecture-Lecture Notes
5
IT18302-Computer Organization and Architecture-Lecture Notes
T0
T1
T2
T3
T4
D3
CLR
SC
A memory read or writes cycle will be initiated with the rising edge of a timing signal. Assume that: memory cycle
time < clock cycle time! So, a memory read or write cycle initiated by a timing signal will be completed by the time
the next clock goes through its positive edge. The clock transition will then be used to load the memory word into a
register. The memory cycle time is usually longer than the processor clock cycle wait cycles
• T0: AR←PC
– Transfers the content of PC into AR if timing signal T0 is active
– T0 is active during an entire clock cycle interval
– During this time, the content of PC is placed onto the bus (with S2S1S0=010) and the LD (load) input of
AR is enabled
– The actual transfer does not occur until the end of the clock cycle when the clock goes through a positive
transition
– This same positive clock transition increments the sequence counter SC from 0000 to 0001
– The next clock cycle has T1 active and T0 inactive
Instruction Cycle
A program is a sequence of instructions stored in memory. The program is executed in the computer by going through
a cycle for each instruction (in most cases).
Each instruction in turn is subdivided into a sequence of sub-cycles or phases
Instruction Cycle Phases:
1- Fetch an instruction from memory
2- Decode the instruction
3- Read the effective address from memory if the instruction has an indirect address
4- Execute the instruction
This cycle repeats 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
– T0: AR←PC (this is essential!!)
The address of the instruction is moved to AR.
– T1: IR←M[AR], PC←PC+1
The instruction is fetched from the memory to IR , and the PC is incremented.
– T2: D0,…, D7←Decode IR(12-14), AR←IR(0-11), I←IR(15)
6
IT18302-Computer Organization and Architecture-Lecture Notes
D'7IT3: AR M[AR]
D'7I'T3:Nothing
D7I'T3: Execute a register-reference instr.
D7IT3: Execute an input-output instr.
7
IT18302-Computer Organization and Architecture-Lecture Notes
8
IT18302-Computer Organization and Architecture-Lecture Notes
9
IT18302-Computer Organization and Architecture-Lecture Notes
.
• INPR and OUTR communicate with a communication interface serially and with the AC in parallel. They hold an
8-bit alphanumeric information.
• I/O devices are slower than a computer system we need to synchronize the timing rate difference between the
input/output device and the computer.
• FGI: 1-bit input flag (Flip-Flop) aimed to control the input operation.FGI is set to 1 when a new information is
available in the input device and is cleared to 0 when the information is accepted by the computer
• FGO: 1-bit output flag used as a control flip-flop to control the output operation. If FGO is set to 1, then this
means that the computer can send out the information from AC. If it is 0, then the output device is busy and the
computer has to wait!
The process of input information transfer:
• Initially, FGI is cleared to 0
• An 8-bit alphanumeric code is shifted into INPR (Keyboard key strike) and the input flag FGI is set to 1
• As long as the flag is set, the information in INPR cannot be changed by another data entry
• The computer checks the flag bit; if it is 1, the information from INPR is transferred in parallel into AC
and FGI is cleared to 0
• Once the flag is cleared, new information can be shifted into INPR by the input device (striking another
key)
The process of outputting information:
• Initially, the output flag FGO is set to 1
• The computer checks the flag bit; if it is 1, the information from AC is transferred in parallel to OUTR
and FGO is cleared to 0
• The output accepts the coded information (prints the corresponding character)
• When the operation is completed, the output device sets FGO back to 1
• The computer does not load a new data information into OUTR when FGO is 0 because this condition
indicates that the output device is busy to receive another information at the moment!!
Needed for:
Transferring information to and from AC register
Checking the flag bits
Controlling the interrupt facility
The control unit recognize it when D7=1 and I = 1. The remaining bits of the instruction specify the particular
operation. Executed with the clock transition associated with timing signal T3
Input-Output instructions are summarized as
D7IT3 = p
IR(i) = Bi, i = 6, …, 11
10
IT18302-Computer Organization and Architecture-Lecture Notes
Program Interrupt
The process of communication just described is referred to as Programmed Control Transfer
The computer keeps checking the flag bit, and when it finds it set, it initiates an information transform (this is
sometimes called Polling). This type of transfer is in-efficient due to the difference of information flow rate
between the computer and the I/O device
The computer is wasting time while checking the flag instead of doing some other useful processing task.
An alternative to the programmed controlled procedure is to let the external device inform the computer when
it is ready for the transfer. This type of transfer uses the interrupt facility. While the computer is running a
program, it does not check the flags. Instead:
o When a flag is set, the computer is immediately interrupted from proceeding with the current program
o The computer stops what it is doing to take care of the input or output transfer
o Then, it returns to the current program to continue what it was doing before the interrupt
The interrupt facility can be enabled or disabled via a flip-flop called IEN. The interrupt enable flip-flop IEN
can be set and cleared with two instructions (IOF, ION):
o IOF: IEN 0 (the computer cannot be interrupted)
o ION: IEN 1 (the computer can be interrupted)
Another flip-flop (called the interrupt flip-flop R) is used in the computer’s interrupt facility to decide when to
go through the interrupt cycle. So, the computer is either in an Instruction Cycle or in an Interrupt Cycle.
The interrupt cycle is a hardware implementation of a branch and save return address operation (BSA). The
return address available in PC is stored in a specific location where it can be found later when the program
returns to the instruction at which it was interrupted. This location may be a processor register, a memory
stack, or a specific memory location
For our computer, we choose the memory location at address 0 as a place for storing the return address.
Control then inserts address 1 into PC:
o this means that the first instruction of the interrupt service routine should be stored in memory at
address 1,
o or, the programmer must store a branch instruction that sends the control to an interrupt service
routine!!
• IEN, R 0: no more interruptions can occur until the interrupt request from the flag has been serviced.The
service routine must end with an instruction that re-enables the interrupt (IEN 1) and an instruction to return to
11
IT18302-Computer Organization and Architecture-Lecture Notes
the instruction at which the interrupt occurred. The instruction that returns the control to the original program is
"indirect BUN 0" .
• Example: the computer is interrupted during execution of the instruction at address 255
The fetch and decode phases of the instruction cycle must be : (Replace T0, T1, T2 R'T0, R'T1, R'T2 (fetch and
decode phases occur at the instruction cycle when R = 0)
• Interrupt Cycle:
– RT0: AR 0, TR PC
– RT1: M[AR] TR, PC 0
– RT2: PC PC + 1, IEN 0, R 0, SC 0
• Register transfers for the Interrupt Cycle
12
IT18302-Computer Organization and Architecture-Lecture Notes
13
IT18302-Computer Organization and Architecture-Lecture Notes
14
IT18302-Computer Organization and Architecture-Lecture Notes
– To control the Read input of the memory we scan the table again to get these:
• D0T4: DR M[AR]
• D1T4: DR M[AR]
• D2T4: DR M[AR]
• D6T4: DR M[AR]
• D7′IT3: AR M[AR]
• R′T1: IR M[AR]
Read = R′T1 + D7′IT3 + (D0 + D1 + D2 + D6 )T4
J K Q(t+1)
0 0 Q(t)
0 1 0
1 0 1
1 1 Q’(t)
15
IT18302-Computer Organization and Architecture-Lecture Notes
• Control of Common bus is accomplished by placing an encoder at the inputs of the bus selection logic and
implementing the logic for each encoder input
x1 x2 x3 x4 x5 x6 x7 S2 S1 S0 selected register
0 0 0 0 0 0 0 0 0 0 none
1 0 0 0 0 0 0 0 0 1 AR
0 1 0 0 0 0 0 0 1 0 PC
0 0 1 0 0 0 0 0 1 1 DR
0 0 0 1 0 0 0 1 0 0 AC
0 0 0 0 1 0 0 1 0 1 IR
0 0 0 0 0 1 0 1 1 0 TR
0 0 0 0 0 0 1 1 1 1 Memory
• For x7:
– X7 = R′T1 + D7′IT3 + (D0 + D1 + D2 + D6 )T4 where it is also applied to the read input
16
IT18302-Computer Organization and Architecture-Lecture Notes
17