UNIT-2 Instruction Set Architecture
UNIT-2 Instruction Set Architecture
UNIT-2 Instruction Set Architecture
Architecture
Basic Computer Introduction :
• Every different processor type has its own design (different registers, buses,
microoperations, machine instructions, etc)
• Modern processor is a very complex device
• It contains
– Many registers
– Multiple arithmetic units, for both integer and floating point calculations
– The ability to pipeline several consecutive instructions to speed execution
– Etc.
• However, to understand how processors work, we will start with a simplified processor
model
• 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
• We will use this to introduce processor organization and the relationship of the RTL
model to the higher level computer processor
THE BASIC COMPUTER
15 0
4095
16 bit data
INSTRUCTIONS :
• Program
• A sequence of (machine) instructions
• (Machine) Instruction
• A group of bits that tell the computer to perform a specific operation (a sequence
of micro-operation)
• 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 microoperations necessary to implement it.
Instruction Code :
An instruction code is a group of bits that instruct the computer to perform a specific
operation.
Opcode Operands
Operation Code :
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.
Accumulator (AC)
Computers that have a single-processor register usually assign to it the name accumulator (AC) accumulator
and label it AC.
The operation is performed with the memory operand and the content of AC.
Stored Program Organization :
INSTRUCTION FORMAT
• A computer instruction is often divided into two parts
1. An opcode (Operation Code) that specifies the operation for that instruction
2. An address that specifies the registers and/or locations in memory to use for that operation
• 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)
• Since the memory words, and hence the instructions, are 16 bits long, that leaves 3
bits for the instruction’s opcode
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 (0): the address in memory of the data to use (the address of the operand), or
• Indirect address (1): the address in memory of the address in memory of the data to use
Direct addressing Indirect addressing
22 0 ADD 457 35 1 ADD 300
300 1350
457 Operand
1350 Operand
+ +
AC AC
• The term "register transfer" implies the availability of hardware logic circuits that can
perform a stated microoperation and transfer the result of the operation to the same or
another register.
• The word "language" is borrowed from programmers, who apply this term to
programming languages.
• A register transfer language is a system for expressing in symbolic form the
microoperation sequences among the registers of a digital module.
• The statement below denotes a transfer of the content of register R1 into register R2.
R2 ← R1
• A statement that specifies a register transfer implies that circuits are available from the
outputs of the destination register has a parallel load capability.
• Every statement written in a register transfer notation implies a hardware construction for
implementing the transfer.
Register Transfer in detail with block diagram and timing diagram :
• Definition: Information transfer from one register to another is designated in symbolic form by
means of a replacement operator is known as Register Transfer.
R2 ← R1
• Denotes a transfer of the content of register R1 into register R2.
• Computer registers are designated by capital letters (sometimes followed by numerals) to denote
the function of the register.
For example:
• The most common way to represent a register is by a rectangular box with the name of the register inside,
as shown in figure.
• Bits 0 through 7 are assigned the symbol L (for low byte) and bits 8 through 15 are assigned the symbol H
(for high byte). The name of the 16-bit register is PC. The symbol PC(0-7) or PC(L) refers to the low-order
byte and PC(8-15) or PC(H) to the high-order byte.
• The statement that specifies a register transfer implies that circuits are available from the outputs of the
source register to the inputs of the destination register and that the destination register has a parallel load
capability.
Ans : 24
Ans : 17
Common Bus System :
• A typical digital computer has many registers, and paths must be provided to
transfer information from one register to another.
• The number of wires will be excessive if separate lines are used between each
register and all other registers in the system.
• A more efficient scheme for transferring information between registers in a
multiple register configuration is a common bus system.
• A bus structure consists of a set of common lines, one for each bit of a register,
through which binary information is transferred one at a time.
• Control signals determine which register is selected by the bus during each
particular register transfer.
• One way of constructing a common bus system is with multiplexers.
• The multiplexers select the source register whose binary information is then placed on
the bus.
• The construction of a bus system for four registers is shown in figure below.
• Each register has four bits, numbered 0 through 3.
• The bus consists of four 4 x 1 multiplexers each having four data inputs, 0 through 3, and
two selection inputs, S1 and S0.
• The diagram shows that the bits in the same significant position in each register are
connected to the data inputs of one multiplexer to form one line of the bus.
• The two selection lines S1 and S0 are connected to the selection inputs of all four
multiplexers.
• The selection lines choose the four bits of one register and transfer them into the four line
common bus.
• When S1S0 = 00, the 0 data inputs of all four multiplexers are selected and applied to the
outputs that form the bus.
• This causes the bus lines to receive the content of register A since the outputs of this
register are connected to the 0 data inputs of the multiplexers.
• In general, a bus system will multiplex k registers of n bits each to produce an n-line
common bus.
• The number of multiplexers needed to construct the bus is equal to n, the number of
bits in each register.
• The size of each multiplexer must be K x 1 since it multiplexes K data lines.
For example, a common bus for eight registers of 16 bits each requires 16 multiplexers, one
for each line in the bus. Each multiplexer must have eight data input lines and three
selection lines to multiplex one significant bit in the eight registers.
A digital computer has a common bus system for 16 registers of 32 bits each.
(i) How many selection input are there in each multiplexer?
(ii) What size of multiplexers is needed?
(iii) How many multiplexers are there in a bus?
• 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. A branch instruction calls for a transfer to a nonconsecutive instruction
in the program.
• 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.
Common Bus System for basic computer register :
• 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 number of wires will be excessive if connections are between the outputs of
each register and the inputs of the other registers. An efficient scheme for
transferring information in a system with many register is to use a common bus.
• The connection of the registers and memory of the basic computer to a common
bus system is shown in figure.
• The outputs of seven registers and memory are connected to the common bus. The
specific output that is selected for the bus lines at any given time is determined from the
binary value of the selection variables S2, S1, and S0.
• The number along each output shows the decimal equivalent of the required binary
selection.
• The particular register whose LD (load) input is enabled receives the data from the bus
during the next clock pulse transition. The memory receives the contents of the bus when
its write input is activated. The memory places its 16-bit output onto the bus when the read
input is activated and S2 S1 S0 = 1 1 1.
• Four registers, DR, AC, IR, and TR have 16 bits each.
• Two registers, AR and PC, have 12 bits each since they hold a memory address.
• When the contents of AR or PC are applied to the 16-bit common bus, the four most
significant bits are set to 0’s. When AR and PC receive information from the bus, only
the 12 least significant bits are transferred into the register.
• The input register INPR and the output register OUTR have 8 bits each and communicate
with the eight least significant bits in the bus.
• INPR is connected to provide information to the bus but OUTR can only receive
information from the bus.
• Five registers have three control inputs: LD (load), INR (increment), and CLR (clear). Two
registers have only a LD input.
• AR must always be used to specify a memory address; therefore memory address is
connected to AR.
• The 16 inputs of AC come from an adder and logic circuit. This circuit has three sets of
inputs.
1. Set of 16-bit inputs come from the outputs of AC.
2. Set of 16-bits come from the data register DR.
3. Set of 8-bit inputs come from the input register INPR.
• The result of an addition is transferred to AC and the end carry-out of the addition is
transferred to flip-flop E (extended AC bit).
• The clock transition at the end of the cycle transfers the content of the bus into the
designated destination register and the output of the adder and logic circuit into AC.
• Three control lines, S2, S1, and S0 control which register the bus selects as its input
S2 S1 S0 Register
0 0 0 x
0 0 1 AR
0 1 0 PC
0 1 1 DR
1 0 0 AC
1 0 1 IR
1 1 0 TR
1 1 1 Memory
INSTRUCTION FORMAT
• A computer instruction is often divided into two parts
1. An opcode (Operation Code) that specifies the operation for that instruction
2. An address that specifies the registers and/or locations in memory to use for that operation
• 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)
• Since the memory words, and hence the instructions, are 16 bits long, that leaves 3
bits for the instruction’s opcode
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
Direct addressing Indirect addressing
22 0 ADD 457 35 1 ADD 300
300 1350
457 Operand
1350 Operand
+ +
AC AC
34
Direct address
35
Indirect address :
36
Indirect address
37
Effective address:
• Effective address: Address where an operand is physically located
Addressing
Mode
39
Addressing Mode :
• It specifies how & from where the operands are obtained for instruction.
• This operation must be executed on some data stored in computer registers or memory words.
• The way the operands are select during program execution is dependent on addressing mode of the
instruction.
LOAD R1, 100 Load the content of memory address 100 to register R1. E.g. ADD 457
4. Indirect Addressing Mode :
• The address field of instruction specifies the address of effective
address.
• Mode is used to implement pointer.
• 2 times memory access required.
printf(“………”,*p);
EA = 800
EA = M [x]
5. Register Mode: (Register Direct Mode)
• The address field of instruction specifies a register which holds operand.
• Operand is present in the register.
• Register number is written in instruction.
• One register access required to fetch operand.
• ADD R1 R2
R1 R1 + R2
MM address = 32 bit
Register references = 6 bit
7. Autoincrement or Autodecrement Mode :
• Variant of register indirect mode.
• The content of register is automatically incremented or decremented to access
the sequential data (for same type operation).
• Used to access table of content (array) sequentially.
• Content of register (effective address) is Automatically increment or decrement.
Loc( A[3]) = Base add. + size (data type) * 3 (Index of Array element)
Loc( A[3]) = Base add. + W * 3 (W= size of each element)
Index register = W * I
• PC= 202
True False
PC-relative mode & Base Register mode are support relocation. (Not required change in instruction code)
Example:
Questions:
250
302+250= 552
200
1. Target add. = PC + offset
450 = 301 + offset
offset = 149
Opcode - 3 Operands - 5
Instruction – 8 bits
• Maximum opcode – 23 =8
• Maximum 8 distinct instruction can be supported by CPU.
• The timing diagram figure shows the time relationship of the control signals.
• The sequence counter SC responds to the positive transition of the clock.
• Initially, the CLR input of SC is active.
• The first positive transition of the clock clears SC to 0, which in turn activates the timing T0 out of the
decoder. T0 is active during one clock cycle.
• The positive clock transition labeled T0 in the diagram will trigger only those registers whose control
inputs are connected to timing signal T0.
• SC is incremented with every positive clock transition, unless its CLR input is active.
• This procedures the sequence of timing signals T0, T1, T2, T3 and T4, and so on. If SC is not cleared, the
timing signals will continue with T5, T6, up to T15 and back to T0.
• 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 Execution Cycle :
• After an instruction is executed, the cycle starts again at step 1, for the next
instruction
• This process continues unless a HALT instruction is encountered.
• Note: Every different processor has its own (different) instruction cycle
• Fetch and Decode
• Initially, the program counter PC is loaded with the address of 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 1.
• The following microoperation for fetch & decode phases can be specified by the following
resister transfer statements.
• However, the sequence counter SC must be incremented when D’7 I T3 = 1, so that the
execution of the memory-reference instruction can be continued with timing variable T4.
Disadvantages of CISC:-
• Slower execution: CISC processors take longer to execute instructions because
they have more complex instructions and need more time to decode them.
• More complex design: CISC processors have more complex instruction sets,
which makes them more difficult to design and manufacture.
• Higher power consumption: CISC processors consume more power than RISC
processors because of their more complex instruction sets.
Example:
• Suppose we have to add two 8-bit numbers.
• CISC approach: There will be a single command or instruction
for this like ADD which will perform the task.
• RISC approach: Here programmer will write the first load
command to load data in registers then it will use a suitable
operator and then it will store the result in the desired location.
• So, add operation is divided into parts i.e. load, operate, store
due to which RISC programs are longer and require more
memory to get stored but require fewer transistors due to less
complex command.
RISC CISC
Reduced Instruction Set Computer Complex Instruction Set Computer
An instruction executed in a single clock cycle. Instruction takes more than one clock cycle
Can perform only Register to Register Arithmetic Can perform REG to REG or REG to MEM or MEM
operations to MEM
An instruction fit in one word. Instructions are larger than the size of one word
The number of instructions are less as compared The number of instructions are more as compared
to CISC. to RISC.