Unit 2 Complete Notes
Unit 2 Complete Notes
• Computer Instructions
• Instruction Cycle
15 0
4095
INSTRUCTIONS
• Program
– A sequence of (machine) instructions
• (Machine) Instruction or microinstruction:
– a sequence of micro-operation that tell the computer to perform a
specific operation is called microinstruction.
• The instructions of a program, along with any needed data
are stored in memory
• The CPU reads the next instruction from memory
• It is placed in an Instruction Register (IR)
• Control circuitry in control unit then translates the
instruction into the sequence of micro operations
necessary to implement it
Instruction Format
15 14 12 11 0
I Opcode Address
Addressing
mode
ADDRESSING MODES
• The address field of an instruction can represent either
– Direct address: the address in memory of the data to use (the address of the
operand), or
– Indirect address: the address in memory of the address in memory of the data to
use
A direct address instruction is shown in Figure 2.1 Direct addressing Indirect addressing
– It is placed in address 22 in memory.
– if (MSB) I bit is 0, a direct address instruction. 22 0 ADD 457 35 1 ADD 300
– The opcode specifies an ADD instruction, and
the address part is the binary equivalent of 457.
– The control finds the operand in memory 300 1350
at address 457 and adds it to the content of AC.
457 Operand
An indirect address instruction is shown in Figure 2.2
– if (MSB) I bit is 1, an indirect address instruction. 1350 Operand
– It is placed in address 35 in memory
– The address part is the binary equivalent of 300.
– The control goes to address 300 to
find the address of the operand.
– The address of the operand in this
case is 1350.
+ +
– The operand found in address 1350
is then added to the content of AC. AC AC
COMPUTER ORGANIZATIONS
Generally CPU organization are of three types on the
basis of number of address fields:
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
List of Registers
DR 16 Data Register Holds memory operand
AR 12 Address Register Holds address for memory
AC 16 Accumulator Processor register
IR 16 Instruction Register Holds instruction code
PC 12 Program Counter Holds address of instruction
TR 16 Temporary Register Holds temporary data
INPR 8 Input Register Holds input character
OUTR 8 Output Register Holds output character
Computer Organization Computer Architectures Lab
Basic Computer Organization & Design 16 Instruction codes
computer REGISTERS
• It is 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.
• 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 AR is a 12 bit register in the Basic Computer
• When an operand is found, using either direct or indirect
addressing, it is placed in the Data Register (DR). The
processor then uses this value as data for its operation
• The Basic Computer has a single general purpose register –
the Accumulator (AC)
Computer REGISTERS
• 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 memory address register (AR) has 12 bits.
• The program counter (PC) also has 12 bits and it holds the
address of the next instruction to be read from memory after the
current instruction is executed.
• Instruction words are read and executed in sequence unless a
branch instruction is encountered.
• Two registers are used for input and output:
The input register (INPR) receives an 8-bit character from an
input device.
The output register (OUTR) holds an 8-bit character for an output
device.
• Instruction Types
Functional Instructions
- Arithmetic, logic, and shift instructions
- ADD, CMA, INC, CIR, CIL, AND, CLA (other than ADD/AND?)
Transfer Instructions
- Data transfers between the main memory
and the processor registers
- LDA, STA
Control Instructions
- Program sequencing and control
- BUN, BSA, ISZ
Input/Output Instructions
- Input and output
- INP, OUT
CONTROL UNIT
3x8
decoder
7 6543 210
D0
I Combinational
D7 Control Control
logic signals
T15
T0
15 14 . . . . 2 1 0
4 x 16
decoder
TIMING SIGNALS
- Generated by 4-bit sequence counter and 416 decoder
- The SC can be incremented or cleared.
T0
T1
T2
T3
T4
D3
CLR
SC
INSTRUCTION CYCLE
T0
AR PC
T1
IR M[AR], PC PC + 1
T2
Decode Opcode in IR(12-14), During time T3, control unit determines the
AR IR(0-11), I IR(15) type of instruction that was just read from
memory as shown in flowchart.
(Register or I/O) = 1 = 0 (Memory-reference) =>opcode ≠ 111
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
D'7IT3: AR M[AR]
D'7I'T3: Nothing
D7I'T3: Execute a register-reference instr.
D7IT3: Execute an input-output instr.
Computer Organization Computer Architectures Lab
Basic Computer Organization & Design 30 Instruction Cycle
AR = 135 135 21
136 Subroutine PC = 136 Subroutine
BSA:
D5T4: M[AR] PC, AR AR + 1
D5T5: PC AR, SC 0
D0 T 4 D1 T 4 D2 T 4 D 3T 4
DR M[AR] DR M[AR] DR M[AR] M[AR] AC
SC 0
D0 T 5 D1 T 5 D2 T 5
AC AC DR AC AC + DR AC DR
SC 0 E Cout SC 0
SC 0
D4 T 4 D5 T 4 D6 T 4
PC AR M[AR] PC DR M[AR]
SC 0 AR AR + 1
D5 T 5 D6 T 5
PC AR DR DR + 1
SC 0
D6 T 6
M[AR] DR
If (DR = 0)
then (PC PC + 1)
SC 0
INPUT-OUTPUT CONFIGURATION
A Terminal with a keyboard and a Printer
• Input-Output Configuration
Input-output Serial Computer
terminal communication registers and
interface
flip-flops
Receiver
Printer interface OUTR FGO
AC
Transmitter
Keyboard interface INPR FGI
INPR Input register - 8 bits
OUTR Output register - 8 bits Serial Communications Path
FGI Input flag - 1 bit Parallel Communications Path
FGO Output flag - 1 bit
IEN Interrupt enable - 1 bit
INPUT-OUTPUT INSTRUCTIONS
CPU Side: input-output instructions are needed for transmitting information to/from AC.
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
- The I/O interface, instead of the CPU, monitors the I/O device.
- When the interface founds that the I/O device is ready for data transfer,
it generates an interrupt request to the CPU
Execute =0
IEN
instructions
=1 Branch to location 1
PC 1
=1
FGI
=0
=1 IEN 0
FGO R0
=0
R1
=0(Instruction =1 (interrupt
R
Cycle) Cycle)
R’T0 RT0
AR PC AR 0, TR PC
R’T1 RT1
IR M[AR], PC PC + 1 M[AR] TR, PC 0
R’T2 RT2
AR IR(0~11), I IR(15) PC PC + 1, IEN 0
D0...D7 Decode IR(12 ~ 14) R 0, SC 0
Register-Reference
D7IT3 = r (Common to all register-reference instr)
IR(i) = Bi (i = 0,1,2, ..., 11)
r: SC 0
CLA AC 0
rB11:
CLE E0
CMA rB10:
AC AC
CME rB9: E E
CIR rB8: AC shr AC, AC(15) E, E AC(0)
CIL rB7: AC shl AC, AC(0) E, E AC(15)
INC rB6: AC AC + 1
SPA rB5: If(AC(15) =0) then (PC PC + 1)
SNA rB4: If(AC(15) =1) then (PC PC + 1)
SZA If(AC = 0) then (PC PC + 1)
SZE rB3:
If(E=0) then (PC PC + 1)
HLT rB2: S0
rB1:
Input-Output rB0: (Common to all input-output instructions)
(i = 6,7,8,9,10,11)
D7IT3 = p SC 0
INP IR(i) = Bi AC(0-7) INPR, FGI 0
OUT p: OUTR AC(0-7), FGO 0
SKI pB11: If(FGI=1) then (PC PC + 1)
SKO If(FGO=1) then (PC PC + 1)
ION pB10:
IEN 1
IOF pB9: IEN 0
pB8:
pB7:
pB6:
Computer Organization Computer Architectures Lab
Basic Computer Organization & Design 44
Computer
Computer Organization
System Ar Chap. 7 Microprogrammed Control Computer
Dept. ofArchitectures
Info. Of Comput Lab
Basic Computer Organization & Design 45
User Program
Machine Instruction
Microprogram
Microinstruction
Microoperation
Computer
Computer Organization
System Ar Chap. 7 Microprogrammed Control Computer
Dept. ofArchitectures
Info. Of Comput Lab
Basic Computer Organization & Design 46
Computer
Computer Organization
System Ar Chap. 7 Microprogrammed Control Computer
Dept. ofArchitectures
Info. Of Comput Lab
Basic Computer Organization & Design 47
Computer
Computer Organization
System Ar Chap. 7 Microprogrammed Control Computer
Dept. ofArchitectures
Info. Of Comput Lab
Basic Computer Organization & Design 48
Address Sequencing
2. Address Sequencing
Address Sequencing = Sequencer : Next Address Generator Selection of
address for control memory
Routine Subroutine : program used by other ROUTINES
Microinstruction are stored in control memory in groups With each group
specify a routine.
each computer instruction has it’s own micro program routine in
control memory to generate microinstructions to execute an instruction.
Mapping : mapping of Instruction Code into Address in control
memorywhere routine is located is called mapping process
Process of Address Sequencing :
1) Incrementing of the control address register
2) Unconditional branch or conditional branch, depending on status bit
conditions
3) Mapping process ( mapping of instruction code to microinstruction
address)
4) A facility for subroutine call and return
Computer
Computer Organization
System Ar Chap. 7 Microprogrammed Control Computer
Dept. ofArchitectures
Info. Of Comput Lab
Basic Computer Organization & Design 49 Sequencing
MICROPROGRAM SEQUENCER(SELECTION OF ADDRESS FROM CONTROL MEMORY)
Instruction code
Mapping
logic
Subroutine
register
Control address register (SBR)
(CAR)
Incrementer
select a status
bit
Microoperations
Branch address
Conditional Branching
Status Bits
» Control the conditional branch decisions generated in the Branch Log
ic
» TestLogic
Branch the specified condition and Branch to the indicated address if the
condition is met ; otherwise, the control address register is just
incremented.
Opcode
Mapping of Instruction :
Computer Instructio 1 0 1 1 Address
n
Mapping bits 0 x xxx 00
Microinstruction Addres 0 1 0 1 1 0 0
s
4 bit Opcode = specify up to 16 distinct instruction
Mapping Process : Converts the 4-bit Opcode to a 7-bit control memory address
» 1) Place a “0” in the most significant bit of the address
» 2) Transfer 4-bit Operation code bits
» 3) Clear the two least significant bits of the CAR (Microinstruction )
Mapping Function : Implemented by Mapping ROM or PLD
Computer
Control
Computer Organization
Memory
System Ar Size : 128 words
Chap. 7(= 27)
Microprogrammed Control Computer
Dept. ofArchitectures
Info. Of Comput Lab
Basic Computer Organization & Design 51
Subroutine
Subroutines are programs that are used by other routines
» Subroutine can be called from any point within the main body
of the microprogram
Microinstructions can be saved by subroutines that use
common section of microcode
Memory Reference ,Operands Effective Address Subroutine
must have a provision for
» storing the return address during a subroutine call
Computer
Computer Organization
System Ar Chap. 7 Microprogrammed Control Computer
Dept. ofArchitectures
Info. Of Comput Lab
Basic Computer Organization & Design 52
Instruction Format
Instruction Format :
» I : 1 bit for indirect addressing
Microinstruction Format
:
Computer
Computer Organization
System Ar Chap. 7 Microprogrammed Control Computer
Dept. ofArchitectures
Info. Of Comput Lab
Basic Computer Organization & Design 53
Microinstruction format
Computer
Computer Organization
System Ar Chap. 7 Microprogrammed Control Computer
Dept. ofArchitectures
Info. Of Comput Lab
Basic Computer Organization & Design 54 Microprogram
F3 Microoperation Symbol
000 None NOP
001 AC AC DR XOR
010 AC AC’ COM
011 AC shl AC SHL
100 AC shr AC SHR
101 PC PC + 1 INCPC
110 PC AR ARTPC
111 Reserved
BR Symbol Function
00 JMP CAR AD if condition = 1
CAR CAR + 1 if condition = 0
01 CALL CAR AD, SBR CAR + 1 if condition = 1
CAR CAR + 1 if condition = 0
10 RET CAR SBR (Return from subroutine)
11 MAP CAR(2-5) DR(11-14), CAR(0,1,6) 0
Micro-instruction Types
vertical micro-programming
Each micro- instruction specifies single (or
few) micro- operations to be performed
horizontal micro-programming
Each micro- instruction specifies many
different micro- operations to be
performed in parallel
56
Computer
Computer Organization
System Ar Chap. 7 Microprogrammed Control Computer Architectures
Dept. of Info. Of Compute Lab
Basic Computer Organization & Design 57
Horizontal & vertical microprogramming
Horizontal Micro-
Vertical Micro-programming programming
QUESTION
Computer
Computer SystemOrganization
Architecture CChhaapp.. 77 MiMiccrroopprrComputer Architectures
ooggrraammmmeedd te Lab
Basic Computer Organization & Design 60
Computer
Computer Organization
System Ar Chap. 7 Microprogrammed Control Computer
Dept. ofArchitectures
Info. Of Comput Lab
Basic Computer Organization & Design 61
Computer
Computer Organization
System Ar Chap. 7 Microprogrammed Control Computer
Dept. ofArchitectures
Info. Of Comput Lab