Module 2
Module 2
– In circular shift, the bit shifted out from one extreme bit
position enters the other extreme side. It is also known as
‘rotate’ operation.
– In arithmetic shift, sign bits remain unaffected and other bits
take part in shift operation
Datapath Organization
• The term datapath includes the following hardware components:
– ALU.
– Registers for temporary storage.
– Various digital circuits for executing different
micro-operations. These include hardware components such as
gates, latches, flip–flops, multiplexers, decoders, counters,
complementer, delay logic etc.
– Internal path for movement of data between ALU and registers.
– Driver circuits for transmitting signals to external units (control
unit, memory, I/O).
– Receiver circuits for incoming signals from external units.
INSTRUCTION CYCLE
• An instruction cycle includes the following stages:
• Fetch: Read the next instruction from memory into the
processor.
• Execute: Interpret the opcode and perform the indicated
operation.
• Interrupt: If interrupts are
enabled and an interrupt has
occurred, save the current
process state and service the
interrupt.
The Indirect Cycle
• The execution of an instruction may involve one or more operands
in memory, each of which requires a memory access.
• Indirect addressing is used, then additional memory accesses are
required.
• The main line of activity consists of alternating instruction fetch
and instruction execution activities.
• After an instruction is fetched, it is examined to determine if any
indirect addressing is involved.
• If so, the required operands are fetched using indirect addressing.
• Following execution, an interrupt may be processed before the
next instruction fetch.
• This illustrates more correctly the nature of the instruction cycle.
• Once an instruction is fetched, its operand specifiers must be
identified.
• Each input operand in memory is then fetched, and this process
may require indirect addressing.
• Register-based operands need not be fetched.
• Once the opcode is executed, a similar process may be needed to
store the result in main memory.
Data Flow
• The exact sequence of events during an instruction cycle depends on
the design of the processor.
• Let us assume that a processor that employs a memory address register
(MAR), a memory buffer register (MBR), a program counter (PC), and
an instruction register (IR).
• During the fetch cycle, an instruction is read from memory.
• The PC contains the address of the next instruction to be fetched.
• This address is moved to the MAR and placed on the address bus.
• The control unit requests a memory read, and the result is placed on the
data bus and copied into the MBR and then moved to the IR.
Meanwhile, the PC is incremented by 1, preparatory for the next fetch.
• Once the fetch cycle is over, the control unit examines the contents of
the IR to determine if it contains an operand specifier using indirect
addressing.
• If so, an indirect cycle is performed.
• The rightmost N bits of the MBR, which contain the address reference,
are transferred to the MAR.
• Then the control unit requests a memory read, to get the desired
address of the operand into the MBR.
• The fetch and indirect cycles are simple and predictable.
• The execute cycle takes many forms; the form depends on which of the
various machine instructions is in the IR.
• This cycle may involve transferring data among registers, read or write
from memory or I/O, and/or the invocation of the ALU.
• Like the fetch and indirect cycles, the interrupt cycle is simple and
predictable.
• The current contents of the PC must be saved so that the processor can
resume normal activity after the interrupt.
• Thus, the contents of the PC are transferred to the MBR to be written
into memory.
• The special memory location reserved for this purpose is loaded into
the MAR from the control unit.
• It might, for example, be a stack pointer.
• The PC is loaded with the address of the interrupt routine.
• As a result, the next instruction cycle will begin by fetching the
appropriate instruction.
Control Unit Design
• If we know the machine instruction set, including an understanding of
the effect of each opcode and an understanding of the addressing
modes, and if we know the set of user-visible registers, then we know
the functions that the processor must perform.
• This is not the complete picture.
• We must know the external interfaces, usually through a bus, and how
interrupts are handled.
• With this line of reasoning, the following list of those things needed to
specify the function of a processor emerges:
1. Operations (opcodes)
2. Addressing modes 5. Memory module interface
3. Registers 6. Interrupts
4. I/O module interface
• Items 1 through 3 are defined by the instruction set.
• Items 4 and 5 are typically defined by specifying the system bus.
• Item 6 is defined partially by the system bus and partially by the type
of support the processor offers to the operating system.
Hardwired Implementation
• A wide variety of techniques have been used.
• Most of these fall into one of two categories:
– Hardwired implementation
– Microprogrammed implementation
• In a hardwired implementation, the control unit is essentially a
state machine circuit.
• Its input logic signals are transformed into a set of output logic
signals, which are the control signals.
Control Unit
Control Unit Inputs
• The key inputs are the instruction register, the clock, flags, and
control bus signals.
• In the case of the flags and control bus signals, each individual bit
typically has some meaning (e.g., overflow).
• The other two inputs, however, are not directly useful to the
control unit.
• First consider the instruction register.
• The control unit makes use of the opcode and will perform
different actions (issue a different combination of control signals)
for different instructions.
• To simplify the control unit logic, there should be a unique logic
input for each opcode.
•
•
Control Unit Logic
• To define the hardwired implementation of a control unit, the
internal logic of the control unit that produces output control
signals as a function of its input signals.
• Essentially, what must be done is, for each control signal, to derive
a Boolean expression of that signal as a function of the inputs.
• This is best explained by example.
• Let us consider a single control signal, C5.
• This signal causes data to be read from the external data bus into
the MBR.
• We can see that it is used twice in Table
• Let us define two new control signals, P and Q, that have the
following interpretation:
– PQ = 00 Fetch Cycle
– PQ = 01 Indirect Cycle
– PQ = 10 Execute Cycle
– PQ = 11 Interrupt Cycle
• Then the following Boolean expression defines C5:
• That is, the control signal C5 will be asserted during the second
time unit of both the fetch and indirect cycles.
• This expression is not complete.
• C5 is also needed during the execute cycle.
• For our simple example, let us assume that there are only three
instructions that read from memory: LDA,ADD, and AND.
• Now we can define C5 as