Professional Documents
Culture Documents
R: Output or Result
• carry-in
• carry-out,
• overflow,
• division-by-zero
Construction of ALU
1|Page
A 1-Bit ALU
The logical operations are easiest, because they map directly onto the hardware
components in Figure B.2.1.The 1-bit logical unit for AND and OR looks like Figure B.5.1. The
multiplexor on the right then selects a AND b or a OR b, depending on whether the value of
Operation is 0 or 1. The line that controls the multiplexor is shown in color to distinguish it
from the lines containing data. Notice that we have renamed the control and output lines of
the multiplexor to give them names that reflect the function of the ALU The next function to
include is addition. An adder must have two inputs for the operands and a single-bit output
for the sum. There must be a second output to pass on the carry, called Carry Out. Since the
Carry Out from the neighbor adder must be included as an input, we need a third input. This
input is called Carry In.
2|Page
FIGURE A 1-bit adder. This adder is called a full adder; it is also called a (3,2)
adder because it
has 3 inputs and 2 outputs. An adder with only the a and b inputs is called a (2,2)
adder or half adder.
3|Page
Figure: A 32-bit ALU constructed from 32 1-bit ALUs
4|Page
Figure :A 1-bit ALU that performs AND, OR, and addition on a and b or a and b.
By selecting b (Binvert = 1) and setting CarryIn to 1 in the least significant bit of
the ALU, we get two’s complement subtraction of b from a instead of addition of
b to a.
5|Page
Figure: A 1-bit ALU that performs AND, OR, and addition on A and B or A and B.
By selecting a (A invert = 1) and b (B invert = 1), we get a NOR b instead of a AND
b.
6|Page
3.3 Instruction execution
1. fetch the next instruction from memory into the instruction register
2. change the program counter to point to the following instruction
3. determine the type of instruction just fetched
4. if the instruction uses a word in a memory, determine where it is
5. fetch the word , if needed into a CPU register
6. execute the instruction
7. go to step 1 to begin executing the following instruction
This sequence of steps is frequently referred to as the fetch-decode- execute cycle.
7|Page
Instruction execution in detail
3. In case of a memory instruction (direct or indirect) the execution phase will be in the next clock pulse.
If the instruction has an indirect address, the effective address is read from main memory, and any
required data is fetched from main memory to be processed and then placed into data registers(Clock
Pulse: T3). If the instruction is direct, nothing is done at this clock pulse. If this is an I/O instruction or a
Register instruction, the operation is performed (executed) at clock Pulse.
Op-code field
address field
mode field
8|Page
Figure: Instruction format
Operand addressing
It defines as follows:
• For a given instruction set architecture, addressing modes define how machine
language instructions identify the operand (or operands) of each instruction.
Effective address: The address of operand produced by the application of the rule for
interpreting or modifying the address field of the instruction before the operand is
actually referenced.
Instruction
Op-code operand
10 | P a g e
In this mode,
• The instruction tells where the value can be found, but the value itself is out in
memory.
• The address field contains the address of the operand
• Effective address (EA) = address field (A)
• In a high level language, direct addressing is frequently used for things like
global variables.
• Advantage
• Single memory reference to access data
• More flexible than immediate
• e.g. ADD A
— Add contents of cell A to accumulator
— Look in memory at address A for operand
• Single memory reference to access data
• No additional calculations to work out effective address
• Limited address space
Indirect addressing:
In this mode Memory cell pointed to by address field contains the address of (pointer to) the operand
11 | P a g e
Figure : Addressing diagram of indirect addressing mode
Register addressing mode:
Register addressing mode is conceptually same as the direct addressing mode but specifies a
register instead of memory location. thus
• Operand is held in register named in address filed
• Effective address(EA) = R
• Limited number of registers
• Very small address field needed
— Shorter instructions
— Faster instruction fetch
Indexed addressing:
It is frequently useful to be able to reference memory words at a known offset from a register. The
addressing memory by giving a register( explicit or implicit) plus a constant offset is called indexed
addressing.
• A = base
• R = displacement
• EA = A + R
• Good for accessing arrays
— EA = A + R
— R++
Based indexed addressing:
the memory addressing is computed by adding up two registers plus an(optional) offset. In which one
of the register is base and other is the index.
For example:
MOV R4 (R2+R5)
a. hardwired control
b. micro-programmed control
c. The
d. first approach is to physically connect all of the control lines to the actual machine
e. instructions. The instructions are divided up into fields, and different bits in the
f. instruction are combined through various digital logic components to drive the control
g. lines. This is called hardwired control, and is illustrated in figure (1)
14 | P a g e
The control unit is implemented using hardware (for example: NAND gates, flip-flops, and counters).We need a
special digital circuit that uses , as inputs, the bits from the Opcode field in our instructions, bits from the flag
(or status) register,
signals from the bus, and signals from the clock. It should produce, as outputs, the control signals to drive the
various components in the computer.
The advantage of hardwired control is that is very fast. The disadvantage is that the instruction set and the
control logic are directly tied together by special circuits that are complex and difficult to design or modify. If
someone designs a hardwired computer and later decides to extend the instruction set, the physical components
in the computer must be changed. This is prohibitively expensive, because not only must new chips be
fabricated but also the old ones must be located and replaced.
Microprogramming is a second alternative for designing control unit of digital computer (uses software for
control). A control unit whose binary control variables are stored in memory is called a microprogrammed
control unit. The control variables at any given time can be represented by a string of 1's and 0's called a
control word (which can be programmed to perform various operations on the component of the system). Each
word in control memory contains within it a microinstruction. The microinstruction specifies one or more
microoperatiotins for the system.
A sequence of microinstructions constitutes a micr-oprogram. A memory that is part of a control unit is
control memory.
A more advanced development known as dynamic microprogramming permits a microprogram to be loaded
initially from an auxiliary memory such as a magnetic disk. Control units that use dynamic microprogramming
employ a writable control memory; this type of memory can be used for writing (to change the microprogram)
but is used mostly for reading.
The general configuration of a microprogrammed control unit is demonstrated in the block diagram of Figure
(2). The control memory is assumed to be a ROM, within which all control information is permanently stored.
15 | P a g e
The control memory address register specifies the address of the microinstruction and the control data register
holds the microinstruction read from memory the microinstruction contains a control word that specifies one or
more microoperations for the data processor. Once these operations are executed, the control must determine
the next address. The location of the next microinstruction may be the one next in sequence, or it may be locate
somewhere else in the control memory. For this reason it is necessary to use some bits of the present
microinstruction to control the generation of the address of the next microinstruction. The next address may also
be a function of external input conditions. While the microoperations are being executed, the next address is
computed in the next address generator circuit and then transferred into the control address register
to read the next microinstruction.
The next address generator is sometimes called a microprogram sequencer, as it determines the address
sequence that is read from control memory, the address of the next microinstruction can be specified several
ways, depending on the sequencer inputs. Typical functions of a microprogram sequencer are incrementing the
control address register by one, loading into the control address register an address from control memory,
transferring an external address or loading an initial address to start the control
operations.
The main advantages of the microprogrammed control are the fact that once the hardware configuration is
established; there should be no need for further hardware or wiring changes. If we want to establish are different
control sequence for the system, all we need to do is specify different set microinstructions for control memory.
The hardware configuration should not be changed for different operations; the only thing that must be changed
is the microprogram residing in control memory.
Microinstructions are stored in control memory in groups, with each group specifying routine. Each computer
instruction has microprogram routine in control memory to generate the microoperations that execute the
instruction. The hardware that controls the address sequencing of the control memory must be capable of
sequencing the microinstructions within a routine and be to branch from one routine to another. The address
sequencing capabilities required in a control memory are:
1. Incrementing of the control address register.
2. Unconditional branch or conditional branch, depending on status bit conditions.
3. A mapping process from the bits of the instruction to an address for control memory.
4. A facility for subroutine call and return.
Figure (3) shows a block diagram of control memory and the associated hardware needed for selecting the next
microinstruction address. The microinstruction in control memory contains a set of bits to initiate
microoperations in computer registers and other bits to specify the method by which the address is obtained.
The diagram shows four different paths from which the control address register (CAR) receives the address.
The incrementer increments the content of the control address register by one, to select the next
microinstruction in sequence. Branching is achieved by specifying the branch address in one of the fields of the
microinstruction. Conditional branching is obtained by using part of the microinstruction to select a specific
status bit in order to determine its condition. An external address is transferred into control memory via a
mapping logic circuit. The return address for a subroutine is stored in a special register whose value is then
used when the microprogram wishes to return from the subroutine.
16 | P a g e
In brief,
Hard‐wired Control Unit‐advantages
1. Minimizes the average number of clock cycles needed per instruction
2. occupies a relatively small area (typically 10%) of the CPU chip area
3. High efficiency in terms of operation speed
4. is to minimize cost of the circuit
17 | P a g e
1. Any instruction to be executed on a CPU can be broken down into a set of sequential micro
operations –each specifying a RTL operation on the data path. The set of micro operations to be
executed on the RTL components at any time step is referred as microinstructions.
The sequence of control signals necessary to execute the sequential microinstructions stored in
ROM called control ROM
2. To implement an instruction on the data path , the control signals stored in the ROM can be
accessed
3. The control signals read from the ROM are used to control the micro operations associated with
a microinstruction to be executed at any time step
4. The address of the next micro instruction is generated
5. The steps 3,4 and 5 are repeated till the set of sequential microinstructions associated with the
instruction is executed
Intel supporters implement CISC architecture so they provide that software implementation is easily. So the
hardware designing to be more complex but software coding would be relatively easy. On the other hand,
Apple supporters want the hardware to be simple and easy and software to take the major role. There for
they implement RISC based architecture.
RISC Architecture
RISC architecture based computer provide the minimum set of instructions that can handle all essential
operation and instruction complexity is reduce by the
Having few simple instructions that are the same length and execute in single clock in RISC
Allowed memory access only with explicit load and store instructions
Hence each instruction takes less time to complete work but execution time is different.
18 | P a g e
Examples: – Atmel AVR, Apple, LC3, MIPS, PowerPC (IBM), SPARC (Sun)
CISC Architecture
CISC architecture based computer are designed to reduce the cost of memory because the bigger
programs requires more storage thus increasing the cost of memory and large memory becomes more
expensive. To solve these problems, the number of instructions per program can be reduced by
embedding multiple operations within a single instruction, thereby making instructions more complex.
19 | P a g e
CISC Characteristics
The design of an instruction set for a computer must take into consideration not only machine language
constructs, but also the requirements imposed on the use of high-level programming languages. The
translation from high-level to machine language programs is done by means of a compiler program. One
reason for the trend to provide a complex instruction set is the desire to simplify the compilation and improve
the overall computer performance. The task of a compiler is to generate a sequence of machine instructions
for each high-level language statement.
The task is simplified if there are machine instructions that implement the statements directly. The essential
goal of a CISC architecture is to attempt to provide a single machine instruction for each statement that is
written in a high-level language.
Examples of CISC architectures are the Digital Equipment Corporation VAX computer and the IBM 370
computer.
2. Some instructions that perform specialized tasks and are used infrequently
RISC Characteristics
20 | P a g e
The concept of RISC architecture involves an attempt to reduce execution time by simplifying the instruction
set of the computer. The major characteristics of a RISC processor are:
The small set of instructions of a typical RISC processor consists mostly of register-to-register operations, with
only simple load and store operations for memory access.
Thus each operand is brought into a processor register with a load instruction. All computations are done
among the data stored in processor registers. Results are transferred to memory by means of store
instructions. This architectural feature simplifies the instruction set and encourages the optimization of
register manipulation. The use of only a few addressing modes results from the fact that almost all instructions
have simple register addressing. Other addressing modes may be included, such as immediate operands and
relative mode. By using a relatively simple instruction format, the instruction length can be fixed and aligned
on
word boundaries. An important aspect of RISC instruction format is that it is easy to decode. Thus the
operation code and register fields of the instruction code can be accessed simultaneously by the control. By
simplifying the instructions and their format, it is possible to simplify the control logic. For faster operations, a
hardwired control is preferable over a microprogrammed control.
A characteristic of RISC processors is their ability to execute one instruction per clock cycle. This is done by
overlapping the fetch, decode, and execute phases of two or three instructions by using a procedure referred
to as pipelining. A load or store instruction may require two clock cycles because access to memory takes
more time than register operations. Efficient pipelining, as well as a few other characteristics, are sometimes
attributed to RISC, although they may exist in non-RISC architectures as well. Other characteristics attributed
to RISC architecture are:
A relatively large number of registers in the processor unit Use of overlapped register windows to speed-up
procedure call and return Efficient instruction pipeline Compiler support for efficient translation of high-level
language programs into machine language programs. A large number of registers is useful for storing
intermediate results and for optimizing operand references. The advantage of register storage as opposed to
memory storage is that registers can transfer information to other registers much faster than the transfer of
information to and from memory. Thus register-to-memory operations can be minimized by keeping the most
frequent accessed operands in registers. Studies that show improved performance for RISC architecture do
not differentiate between the effects of the reduced instruction set and the effects of a large register file. For
this reason a large number of registers in the processing unit are sometimes associated with RISC processors.
21 | P a g e
22 | P a g e