Unit-3 Basic Computer Organization and Design
Unit-3 Basic Computer Organization and Design
By,
Er. Nabaraj Bahadur Negi
1
Contents
• Every different processor type has its own design (different registers, buses,
microoperations, machine instructions, etc.)
• It contains
• Many registers
• Multiple arithmetic units, for both integer and floating point calculations
• This is similar to what real processors were like ~25 years ago
• M. Morris Mano introduces a simple processor model he calls the Basic
Computer
4
The basic computer
5
Instructions
• The computer reads each instruction from memory, the CPU reads the next
instruction from memory and places it in in ( Instruction Register (IR)) a
control register.
• The control then interprets the binary code of the instruction and proceeds to
execute it by issuing a sequence of microoperations.
6
Instruction Format
• In the Basic Computer, since the memory contains 4096 (= 212) words, we needs
12 bit to specify which memory address this instruction will use
• In the Basic Computer, bit 15 of the instruction specifies the addressing mode
(0: direct addressing, 1: indirect addressing) 7
• Since the memory words, and hence the instructions, are 16 bits long, It
consists of a 3-bit operation code, a 12-bit address, and an indirect address
mode bit designated by I. the mode bit is 0 for a direct and 1 for an indirect
address.
8
Stored Program Organization
• The simplest way to organize a computer is to have one processor register
and instruction code format with two parts.
• The first part specifies the operation to be performed and the second
specifies and address.
• 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.
• Figure below depicts this type of organization. Instructions are stored in one
section of memory and a data in another.
• For a memory unit with 4096 words we need 12 bits to specify an address
since 212 = 4096.
9
• If we store each instruction code in one
16-bit memory word, we have available
four bits for the operation code
(abbreviated as opcode) to specify one
out of 16 possible operation 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 and 16 bit operand
from the data portion of memory. It then Figure : Stored program organization.
executes the operation specified by the
operation code.
10
• Computer that have a single processor register usually assign to it the name
accumulator and label it AC. The operation is performed with the memory
operand and the content ofAC.
• If an operation in an instruction code does not need and operand from
memory, the rest of the bits in the instruction can be used for other purposes.
• For example, operations such as clear AC, complement AC, and increment
AC operate on data stored in the AC register.
11
Addressing Modes
• The address fieldof an Direct addressing Indirect addressing
either
300 1350
• Direct address: the
457 Operand
address in memory of
1350 Operand
12
• A direct address instruction is shown in figure : b It is placed in address 22
in memory. The I bit is 0, so the instruction is recognized as a direct
address instruction. The opcode specifies an ADD instruction, and the
address part is the binary equivalent of 457. The control finds the operand
in memory at address 457 and adds it to the content ofAC.
• The instruction in address 35 shown in figure : c has a mode bit I = 1.
Therefore, it is recognized as an indirect address instruction. The address
part is the binary equivalent of 300. The control goes to address 300 to
find the address instruction needs two references to memory to fetch and
operand. The address of the operand in this case is 1350. The operand
found in address 1350 is then added to the content ofAC.
• Effective Address(EA) is the location where operand is present , or as the
target address for a branch-type instruction
13
Basic Computer Registers and Memory
• Computer instructions are normally stored in consecutive memory locations
and are executed sequentially one at a time.
• The control reads an instruction from a specific address in memory and
executes it. It then continues by reading the next instruction in sequence and
executes it, and so on. This type of instruction sequencing needs a counter to
calculate the address of the next instruction after execution of the current
instruction is completed.
• The computer needs processor registers for manipulating data and a register
for holding a memory address.
• The memory unit has a capacity of 4096 words and each word contains 16
bits. Twelve bits of an instruction word are needed to specify the address of
an operand.
14
• A processor has many registers to hold instructions, addresses, data,etc
• The data register (DR) holds the operand read from memory. The accumulator
• The instruction read from memory is placed in the instruction register (IR). The
temporary register (TR) is used for holding temporary data during the
processing
• The processor has a register, the Program Counter (PC) that holds the memory
address of the next instruction to be read from memory after the current
instruction is executed. Since, the memory in the Basic Computer only has
15
• In a direct or indirect addressing, the processor needs to keep track of what
locations in memory it is addressing: The Address Register (AR) is used for
this
• The Input Register (INPR) holds an 8 bit character gotten from an input
device
16
Register Number
17
11 0
PC
Memory
11 0 4096 x 16
AR
15 0
IR
CPU
15 0 15 0
TR DR
7 0 7 0 15 0
OUTR INPR AC
18
Common Bus System
• The basic computer has eight registers, a memory unit, and a control unit.
Paths must be provided to transfer information from one register to another
and between memory and register.
• The outputs of seven registers and memory are connected to the common
bus.
• Three control lines, S2, S1, and S0 control which register the bus selects as its
input.
• For example, the number along the output of DR is 3. The 16-bit outputs
of DR are placed on the bus lines when S2S1S0 = 011 since this is the binary
value of decimal 3. 19
20
S2
S1 Bus
S0
Memory unit 7
4096 x 16
Address
Write Read
AR 1
LD INR CLR
PC 2
LD INR CLR
DR 3
LD INR CLR
E
ALU AC 4
LD INR CLR
INPR
IR 5
LD
TR 6
LD INR CLR
OUTR
Clock
LD
16-bit common bus
LOAD A AC = M[A]
ADD B AC = AC + M[B]
STORE T M[T] = AC
LOAD C AC = M[C]
ADD D AC = AC + M[D]
MUL T AC = AC * M[T]
STORE X M[X] = AC
22
Basic Computer Instructions
• The basic computer has three instruction code formats. Each format has 16
bits. The operation code (opcode) part of the instruction contains three bits
and the meaning of the remaining 13 bits depends on the operation code
encountered.
• A memory-reference instruction uses 12 bits to specify and address and one
bit to specify the addressing mode I. I is equal to 0 for direct address and
to 1 for indirect address.
• The register reference instructions are recognized by the operation code
111 with a 0 in the leftmost bit (bit 15) of the instruction.
• A register-reference instruction specifies an operation on or a test of the AC
register. An operand from memory is not needed; therefore, the other 12
bits are used to specify the operation or test to be executed.
23
• Similarly, an input output instruction does not need a reference to memory and
is recognized by the operation code 111 with a 1 in the leftmost bit of the
instruction. The remaining 12 bits are used to specify the type of input-output
operation or test performed.
I Opcode Address
15 12 11 0
0 1 1 1 Register operation
15 12 11 0
1 1 1 1
I/O operation
27
r: SC 0 Clear SC
CLA rB11: AC 0 Clear AC
CLE rB10: E0 Clear E
CMA rB9: AC AC’ Complement AC
CME rB8: E E’ Complement E
CIR rB7: AC shr AC, AC(15) E, E AC(0) Circulate right
CIL rB6: AC shl AC, AC(0) E, E AC(15) Circulate left
INC rB5: AC AC + 1 Increment AC
SPA rB4: if (AC(15) = 0) then (PC PC+1) Skip if positive
SNA rB3: if (AC(15) = 1) then (PC PC+1) Skip if negative
SZA rB2: if (AC = 0) then (PC PC+1) Skip if A C zero
SZE rB1: if (E = 0) then (PC PC+1) Skip if E zero
HLT rB0: S 0 (S is a start-stop flip-flop) Halt computer
• The effective address of the instruction is in the address register AR and was
placed there during timing signal T2 when I = 0, or during timing signal T3
when I=1.
• The symbolic description of each instruction is specified in the table in
terms of register transfer notation. The actual execution of the instruction in
the bus system will require a sequence of microoperations.
29
Symbol Operation Symbolic Description
Decoder
AND D0 AC AC M[AR]
ADD D1 AC AC + M[AR], E Cout
LDA D2 AC M[AR]
STA D3 M[AR] AC
BUN D4 PC AR
BSA D5 M[AR] PC, PC AR + 1
ISZ D6 M[AR] M[AR] + 1, if M[AR] + 1 = 0 then PC PC+1
AND to AC
• This is an instruction that performs the AND logic operation on pairs of bits in AC
and the memory word specified by the effective address. The result of the
operation is transferred to AC . The microoperations that execute this instruction
are:
AR = 135 135 21
136 Subroutine PC = 136 Subroutine
34
Memory-reference instruction
D 4T4 D 5T 4 D 6T 4
PC AR M[AR] PC DR M[AR]
SC 0 AR AR + 1
D 5T5 D 6T5
PC AR DR DR + 1
SC 0
D 6T6
M[AR] DR
If (DR = 0)
then (PC PC + 1)
SC 0
• Input-output instructions have an operation code 1111 and are recognized by the
control when D7 = 1 and I = 1.The remaining bits of the instruction specify the
particular operation.
• The control functions and microoperations for the input-output instructions are
listed in Table. D7 I T3 = p (common to all input-output instructions)
IR(i) = Bi [bit in IR (6-ll) that specifies the instruction]
p: SC 0 Clear SC
INP pB11: AC(0-7) INPR, FGI 0 Input char. to AC
OUT pB10: OUTR AC(0-7), FGO 0 Output char. from AC
SKI pB9: if(FGI = 1) then (PC PC + 1) Skip on input flag
SKO pB8: if(FGO = 1) then (PC PC + 1) Skip on output flag
ION pB7: IEN 1 Interrupt enable on
IOF pB6: IEN 0 Interrupt enable off 57
Instruction set completeness
• A computer should have a set of instructions so that the user can construct
machine language programs to evaluate any function that is known to be
computable.
• The set of instructions are said to be complete if the computer includes a
sufficient number of instructions in each of the following categories:
• Functional Instructions
• Transfer Instructions
• Data transfers between the main memory and the processor registers
27
• Examples: loading the AC(LDA), storing the accumulator (STA)
• Control Instructions
• The branch instructions BUN, BSA, and ISZ, together with the four
skip instructions, provide capabilities for program control and
checking of status conditions.
• Input/Output Instructions
• The timing for all registers in the basic computer is controlled by a master
clock generator.
• The clock pulses are applied to all flip-flops and registers in the system,
including the flip-flops and registers in the control unit.
• The clock pulses do not change the state of a register unless the register is
enabled by a control signal.
• The control signals are generated in the control unit and provide control
inputs for the multiplexers in the common bus, control inputs in processor
registers, and microoperations for the accumulator.
• Control Unit: Control unit (CU) of a processor translates from machine
instructions to the control signals for the microoperations that implement
them.
• Control units are implemented in one of two ways: hardwired control and
microprogrammed control.
Hardwired control:
• The control logic is implemented with gates, flip-flops, decoders, and
other digital circuits.
• It has the advantage that it can be optimized to produce a fast mode of
operation.
• Requires changes in the wiring among the various components if the
design has to be modified or changed, i.e. modification very difficult.
• Adding new feature is difficult.
• Expensive ,high error and used in RISC processor.
29
Microprogrammed control:
30
Instruction register (IR)
15 14 13 12 11 - 0 Other inputs
3x8
decoder
7 6 5 4 3 2 10
D0
I Combinational
D7 Control Control
logic signals
T15
T0
15 14 . . . . 2 1 0
4 x 16
decoder
43
Timing Signals
• Most of the time the counter is incremented to provide the sequence of timing
signals out of the 4 x 16 decoder. Once in awhile, the counter is cleared to 0,
causing the next active timing signal to be T0.
• Example, consider the case where SC is incremented to provide timing
signals T0, T1, T2, T3, and T4 in sequence. At time T4 SC is cleared to 0 if
decoder output D3 is active. This is expressed symbolically by the statement
D3T4: SC 0
44
T0 T1 T2 T3 T4 T0
C lo c k
T0
T1
T2
T3
T4
D3
C LR
SC
45
Figure: Functioning of Microprogrammed Control Unit
46
• The inputs (IR, ALU flags, clock) and outputs (control signals). The
control unit functions as follows:
• To execute an instruction, the sequencing logic unit issues a READ
command to the control memory.
• The word whose address is specified in the control address register is
read into the control buffer register.
• The content of the control buffer register generates control signals
and next-address information for the sequencing logic unit.
• The sequencing logic unit loads a new address into the control
address register based on the next-address information from the
control buffer register and the ALU flags.
47
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.
3. Read the effective address from memory if the instruction has an indirect address
• 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.
37
Note: Every different processor has its own (different) instruction cycle
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,T1,T2, and so on.
• The microoperations for the fetch and decode phases can be specified by
the following register transfer statements.
T0: AR←PC
T1: IR←M[AR],PC←PC +1
T2: D0, ….D7←decode IR (12-14) ,AR←IR (0-11) ,I←IR(15)
49
• Since only AR is connected to the address inputs of memory, it is necessary
to transfer the address from PC to AR during the clock transition associated
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.
50
T1
S2
T0 S1 Bus
S0
Memory
7
unit
Address
Read
AR 1
LD
PC 2
INR
IR 5
LD
Clock
Common bus
T0
AR PC
T1
IR M[AR], PC PC + 1
T2
Decode Opcode in IR(12-14),
AR IR(0-11), I IR(15)
(Register or I/O) = 1
= 0 (Memory-reference)
D7
T3 T3 T3 T3
Execute Execute AR M[AR] Nothing
input-output register-reference
instruction instruction
SC 0 SC 0 Execute T4
memory-reference
instruction
SC 0
D7 I’T3: Nothing
D7 I’T3: Execute a register-reference instruction
D7 I T3 : Execute an input-output instruction
54
Input-Output and Interrupt
• Instructions and data stored in memory must come from some input device.
Computational results must be transmitted to the user through some output
device. Commercial computers include many types of input and output
devices.
Input-Output Configuration
• The terminal sends and receives serial information. Each quantity of
information has eight bits of an alphanumeric code.
• The two registers communicate with a communication interface serially
and with the AC in parallel.
• The serial information from the keyboard is shifted into the input register
INPR . The serial information for the printer is stored in the output register
OUTR. 53
Input-output Serial Computer
Receiver
Printer FGO
interface
OUTR
AC
Transmitter
Keyboard
interface INPR
FGI
56
• INPR Input register - 8 bits, OUTR Output register - 8 bits, FGI Input flag - 1 bit,
FGO Output flag - 1 bit, IENInterrupt enable - 1 bit
• Initially, the input flag FGI is cleared to 0. When a key is struck in the keyboard,
an 8-bit alphanumeric code is shifted into INPR and the input flag FGI is set to 1.
As long as the flag is set, the information in INPR cannot be changed by striking
another key. 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 striking another key.
• The output register OUTR works similarly but the direction of information flow is
reversed. 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 device accepts the coded information, prints the
corresponding character, and when the operation is completed, it sets FGO to 1.
57
Program controlled data transfer
FGI=0 FGO=1
Start Input Start Output
FGI 0
AC Data
yes
FGI=0 yes
FGO=0
no
no
AC INPR
OUTR AC
FGO 0
yes
More
Character
yes More
no Character
END no
END
58
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 transfer.
• Consider a computer that can transfer information at a maximum rate of 10
characters per second. This is equivalent to one character every 100,000µs.
Two instructions are executed when the computer checks the flag bit and
decides not to transfer the information. This means that at the maximum rate,
the computer will check the flag 50000 times between each transfer. The
computer is wasting time while checking the flag instead of doing some other
useful processing task.
• The interrupt enable flip-flop IEN can be set and cleared with two instructions.
When IEN is cleared to 0 the flags cannot interrupt the computer.
59
• When IEN is set to 1 the computer can be interrupted. These two
instructions provide the programmer with the capability of making a
decision as to whether or not to use the interrupt facility.
60
Interrupt Cycle
=0
Execute IEN
instructions
=1 Branch to location 1
PC 1
=1
FGI
=0
IEN 0
=1
FGO R 0
=0
R 1
RT0: AR 0, TR PC
RT2: PC PC + 1, IEN 0, R 0, SC 0
63
Complete Computer Description
64
Flowchart Start
SC 0, IEN 0, R 0
66
Register-Reference
D7IT3= r (Common to all register-reference instr)
IR(i) = Bi (i = 0,1,2, ..., 11)
r: SC 0
CLA rB11: AC 0
CLE rB10: E 0
CMA rB9: AC ACE
CME rB8: E
CIR rB7: AC shr AC, AC(15) E, E AC(0)
CIL rB6: AC shl AC, AC(0) E, E AC(15)
INC rB5: AC AC + 1
SPA rB4: If(AC(15) =0) then (PC PC + 1)
SNA rB3: If(AC(15) =1) then (PC PC + 1)
SZA rB2: If(AC = 0) then (PC PC + 1)
SZE rB1: If(E=0) then (PC PC + 1)
HLT rB0: S0
67
Control Logic Gates
Inputs:
• Address Register; AR, Scan all of the register transfer statements that change
the content of AR:
R’T0: AR PC LD(AR)
R’T2: AR IR(0-11) LD(AR)
D’7IT3: AR M[AR] LD(AR)
RT0: AR 0 CLR(AR)
D5T4: AR AR + 1 INR(AR)
69
• where LD(AR) is the load input of AR, CLR(AR) is the clear input of AR, and
INR(AR) is the increment input of AR . The control gate logic associated with
AR is shown in Figure.
• In a similar fashion we can derive the control gates for the other registers as well
as the logic needed to control the read and write inputs of memory. The read
operation is recognized from the symbol <-M[AR].
Read = R’T1 + D´7IT3 + (D0 + D1 + 02 + D6)T4
12 12
From bus AR To bus
D'7
I
LD Clock
T3
T2 INR
CLR
R
T0
D
T4
B6
K
R
T2
16
Adder and
16 16 16
logic AC
From DR
circuit
To bus
8
From INPR
Control
gates
74
D0T5: AC AC DR AND with DR
D1T5: AC AC + DR Add with DR
D2T5: AC DR Transfer from DR
rB11 : AC 0 Clear
rB5 : AC AC + 1 Increment
75
Control of AC register
• Gate structures for controlling the LD, INR, and CLR of AC show in below:
D2 DR
T5
p INPR
B11
r COM
B9
SHR
B7
SHL
B6
INC
B5
CLR
B11
Figure : Gate structure for controlling the LD, INR, and CLR ofAC. 75
Adder and Logic circuit
DR(i)
AC(i)
AND
C LD
i ADD
I
FA i J Q
AC(i)
DR
C
i+1
K
INPR
From
INPR
bit(i)
COM
SHR
AC(i+1)
SHL
AC(i-1)