Unit 3
Unit 3
AND ARCHITECTURE
09/08/2024 2
• No. of bits required by an opcode depends on the total no. of operations available
in a computer.
• Rule of thumb; An opcode must have atleast n no. of bits for a given 2n operations
• Memory locations are specified by their address while processor registers may
be specified by a k bit binary number for 2k registers
09/08/2024 3
Instruction code
• A computer instruction is basically a binary code that specifies a sequence of
micro-operations to be performed by computer
• The computer then reads each instruction from memory and places it in a
control register
• The control unit then interprets the binary code and executes it
Operation code is a group of bits that define the operation to be performed like
add, subtract shift etc.
09/08/2024 4
Stored program organization
• Instructions are stored in one part of
the memory and data is placed in
another part
09/08/2024 5
• Control reads the 16-bit instruction from the program portion of the memory
• Uses the 12 bit address part to read the operand from data portion of the
memory
09/08/2024 6
• The instruction consists of a 12-
bit address, 3-bit opcode and 1
bit I for indirect address mode.
09/08/2024 7
• Computer Registers
09/08/2024 8
• Instruction format
The basic computer follows 3 instruction formats each having 16-bit representation
09/08/2024 9
• Memory reference instruction
12 bits are used to specify an address, 3 bits are for opcode, 1 bit specifies the
addressing mode
• Input-output instruction
Identified by the opcode 111 with 1 in the MSB. The memory operand is not required
and thus the remaining 12 bits are used to specify the I/O operation to be performed
09/08/2024 10
• If the 2nd part of the instruction code specifies an operand instead of an address
then the instruction is said to have an immediate operand
• If the 2nd part of the instruction code specifies the address of the operand then
the instruction is said to have direct address
• If the 2nd part of the instruction code specifies the address of the memory
location where the address of operand is stored then the instruction is said to
have indirect address
• To differentiate between direct and indirect address, one bit of instruction code
is used.
09/08/2024 11
Timing and Control
• The timing of all registers is controlled by the master clock generator. The control
signals regenerate the control unit provide inputs to multiplexers, flags, common
bus and processor registers
• 2 main types of control organization: hard-wired control and micro-programmed
control
09/08/2024 13
09/08/2024 14
09/08/2024 15
• Control unit
09/08/2024 16
• The 4-bit sequence counter can count form binary 0 to binary 15 which are
decoded and result in the generation of 16 timing signals T0 to T15.
• SC responds to the 1st positive transition of the clock. Initially the CLR input of SC
is active.
• During 1st positive transition, SC is cleared to 0which activates the timing signal
T0.
• At every positive transition of clock the SC is incremented thus producing timing
signals T0, T1, T2, T3, T4.
09/08/2024 17
• 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.
After each clock pulse, SC is incremented by one, so that the timing signals go
through a sequence T0, T1, T2, and so on.
09/08/2024 19
• Determining type of instruction
After decoding, timing signal becomes T3. During this time the control unit
determines the type of instruction read from the memory.
D7 is equal to 1 if opcode is 111, the instruction is a register reference or I/O
reference instruction.
If D7 = 0, opcode can be anything between 000 to 110 indicating that instruction is
a memory-reference instruction
09/08/2024 21
09/08/2024 22
09/08/2024 23
Bus architecture
• Single bus architecture: In a single bus structure, one common bus is used to
communicate between peripherals and microprocessors. It has disadvantages
due to the use of one common bus.
09/08/2024 24
Bus architecture
• Parts of a System bus: Processor, memory, Input and output devices are connected by system bus,
which consists of separate buses
(i)Address bus: Address bus is used to carry the address. It is unidirectional bus. The address is sent to
from CPU to memory and I/O port and hence unidirectional. It consists of 16, 20, 24 or more parallel
signal lines.
(ii)Data bus: Data bus is used to carry or transfer data to and from memory and I/O ports. They are
bidirectional. The processor can read on data lines from memory and I/O port and as well as it can write
data to memory. It consists of 8, 16, 32 or more parallel signal lines.
(iii)Control bus: Control bus is used to carry control signals in order to regulate the control activities. They
are bidirectional. The CPU sends control signals on the control bus to enable the outputs of addressed
memory devices or port devices. Some of the control signals are: MEMR (memory read), MEMW (memory
write), IOR (I/O read), IOW (I/O write), BR (bus request), BG (bus grant), INTR (interrupt request), INTA
(interrupt acknowledge), RST (reset), RDY (ready), HLD (hold), HLDA (hold acknowledge)
09/08/2024 25
Single Accumulator based CPU Organization
• The computers, present in the early days of computer history, had accumulator
based CPUs. In this type of CPU organization, the accumulator register is used
implicitly for processing all instructions of a program and store the results into
the accumulator.
• The instruction format that is used by this CPU Organization is one address field.
Due to this the CPU is known as One Address Machine.
• In this CPU Organization, the first ALU operand is always stored into the AC
register and the second operand is present either in Registers or in the Memory.
• AC register is the default address thus after data manipulation the results are
stored into the AC register
09/08/2024 26
• Multiple bus architecture: In a multiple bus structure, one bus is used to fetch
instructions while other is used to fetch data, required for execution. It is to
overcome the bottleneck of a single bus structure.
09/08/2024 27
• The format of instruction is: Opcode + Address
• It uses LOAD and STORE instructions for data transfer: e.g. LOAD X, STORE Y
• Here LOAD is memory read operation that is data is transferred from memory
location X to accumulator and STORE is a memory write operation that is data is
transferred from accumulator to memory location Y.
09/08/2024 28
General Register Organization
• Memory locations in a computer can be used to store the pointers, counters,
return addresses, temporary results etc. during instruction execution.
• This memory access is very time-consuming so registers included in the CPU
were used to store the intermediate values and each register was connected to
other through a common bus
09/08/2024 29
09/08/2024 30
• The output of each register is connected to two multiplexers (MUX) that form
two buses A and B.
• Using the select lines of MUX, one register or input data for that bus is selected
• The buses A and B give the output to the ALU.
• OPR input of ALU selects the micro-operation to be performed on the data.
• The result of micro-operation is available as output and also goes to inputs of all
the registers.
• The decoder selects the register that stores the result of output by activating the
Load (LD) signal of that register.
09/08/2024 31
• As an example
09/08/2024 32
Control Word
• Specified by a combination of 14 binary selection inputs
09/08/2024 33
09/08/2024 34
Field SELA SELB SELD OPR
Symbol R2 R3 R1 SUB
Control Word 010 011 001 00101
09/08/2024 35
Stack Organization
• Stack is a storage device that stores information in a manner that item stored
last is the first to be retrieved.
• In digital computers, stack is a memory unit with an address register called stack
pointer (SP). SP holds the address of the top of the stack.
• Two operations of stack are insertion (Push) and deletion (Pop) of items which
are simulated by incrementing or decrementing the stack pointer register
09/08/2024 36
• Stack can be placed in a portion of large memory
or it can be organized as a collection of finite
memory words or registers
Register stack
• SP contains binary numbers whose value is the
address of the memory word that is currently on
the top of stack
• The one-bit register FULL is set to 1 when stack is
full and register EMTY is set to 1 when stack is
empty
PUSH operation
Increment SP
Write item on top of stack
Check if stack is full
Mark the stack non-empty
POP operation
Read item from the top of stack
Decrement the SP
Check if stack is empty
Mark the stack not full
09/08/2024 38
Memory Stack
A stack can be implemented in the CPU by
assigning a portion of memory to a stack and a
processor register is used as a stack pointer.
09/08/2024 39
• For push operation
e.g. (3 * 4) + (5 * 6)
In RPN: 34 * 56 * +
Instruction Formats
• The instruction format symbolizes the bits of instruction as they appear in
memory words of control register
• Fields of instruction format
Operation code (Opcode) field: Specifies the operation to be performed
Address field: Designates a memory address or a processor register
Mode field: Specifies the way an operand or effective address is determined
• Opcode field contains a group of bits that define various processor operations like
add, subtract, complement
• Operands residing in memory are specified by memory address and operands
residing in the processor registers are specified by a register address
09/08/2024 43
• Mode field specifies a variety of ways for choosing operands from the given
address
• The instructions may have different lengths as per the number of addresses.
• The number of address fields depends on the internal organization of CPU and its
registers
09/08/2024 44
• Three address instruction
09/08/2024 47
Addressing Modes
• The way operands are chosen during a program execution depends on the
addressing mode of the instruction.
• The addressing mode specifies the rule for interpreting or modifying the address
field of the instruction before operand is referenced
• Most addressing modes modify the address field of the instruction but 2 modes
don’t use address field (Implied mode and Immediate mode)
09/08/2024 48
• Implied Mode: Operands are specified implicitly in the definition of the
instruction e.g. Complement Accumulator.
• Immediate mode: Operand is specified in the instruction itself. i.e. Instruction has
an operand field rather than intermediate field
• Register indirect mode: Instruction specifies a register that holds the address of
the memory location where operand is located
09/08/2024 49
• Indexed addressing mode: The contents of the index register are added address
part of the instruction to obtain the effective address
• Base register addressing mode: The contents of the base register are added to
the address part of the instruction to obtain the effective address.
09/08/2024 50
• Autoincrement/Autodecrement mode: The register is incremented or
decremented after its value has been used to access the memory
• Direct address mode: The effective address of the operand is equal to the address
part of the instruction
• Indirect address mode: The address field of the instruction gives the address of
memory location where the operand is actually located
• Relative address mode: the contents of the PC are added to the address part of
the instruction in order to obtain the effective address
09/08/2024 51
09/08/2024 52
• Instruction is stored in two addresses: 200 and 201
PC= 200 to fetch the instruction
Mode field specifies the addressing mode
09/08/2024 53
Data transfer and Manipulation
• Computer instructions can be divided into 03 categories
Data transfer: Transfer of data from one location to other
Data manipulation: Performing some arithmetic or logic or shift operations on
data
Program control: Provide decision-making capabilities and change the path of
the program when executed
09/08/2024 54
Data transfer instructions
09/08/2024 55
Data manipulation instructions
09/08/2024 56
Program control instructions
09/08/2024 57
Status bit conditions
09/08/2024 58
09/08/2024 59