Module 2 Coa
Module 2 Coa
Processor Unit:
The processor unit consists of arithmetic unit, logic unit, a number of
registers and internal buses that provides data path for transfer of
information between register and arithmetic logic unit.
The block diagram of processor unit is shown in figure below where all
registers are connected through common buses.
The registers communicate each other not only for direct data transfer but
also while performing various micro-operations.
Here two sets of multiplexers select register which perform input data for
ALU.
A decoder selects destination register by enabling its load input.
The function select in ALU determines the particular operation that to be
performed.
For an example to perform the operation: R3 R1 + R2
1. MUX A selector (SELA): to place the content of R1 into bus A.
2. 2.MUX B selector (SELB): to place the content of R2 into bus B.
3. 3.ALU operation selector (OPR): to provide arithmetic addition A
+ B.
4. 4.Decoder destination selector (SELD): to transfer the content of
the output bus into R3.
Control Unit
The control unit (CU) is a critical component of the CPU that directs the
operations of the processor. Here's a breakdown of its functionality based on the
description you provided:
The control unit's primary function is to interpret instructions and orchestrate the
necessary operations within the CPU. Here's how it works:
1. Interpreting Instructions:
o The CU decodes the opcode in the instruction register to
understand the operation that needs to be performed.
2. Directing Data Movement:
o It determines the movement of data between the ALU (Arithmetic
Logic Unit), memory, and registers. It ensures that data is properly
routed to the correct components for the operation.
3. Coordinating Operations:
o The control unit manages all activities of the processor, including:
Interfacing with the ALU for computation tasks.
Communicating with main memory for data fetching and
storing.
Managing interactions with peripheral devices and storage
devices.
4. Handling System States:
o The CU ensures that the processor operates correctly by
monitoring system states, which include the status of the processor
flags (e.g., zero flag, carry flag, etc.) and triggering necessary
actions based on the current state of the system.
Inputs to the Control Unit
1. Flags:
o These flags (like zero, carry, overflow, etc.) hold information about
the result of the last ALU operation. They are used to make
decisions during program execution.
2. Clock:
o The clock signal synchronizes the operations of the processor,
ensuring that all micro-operations happen at specific time intervals
or clock cycles.
3. Instruction Register (IR):
o The opcode from the instruction register tells the control unit what
micro-operations to carry out during the execution cycle.
4. Control Signals from the Control Bus:
o These signals indicate external events like interrupts or I/O
operations, which can prompt the CU to take specific actions, such
as halting the CPU or acknowledging peripheral devices.
Input Analysis: The CU receives data like flags, the clock pulse, the
instruction register's opcode, and external control signals.
Processing: Based on the input, the CU decodes the instruction and
orchestrates the sequence of micro-operations, interacting with the ALU,
registers, memory, and peripherals.
Output Generation: The CU outputs control signals that ensure correct data
transfer and execution of tasks.
The Central Processing Unit (CPU) is the core component of a computer that
performs most of the processing inside. It executes instructions from a program,
making it the "brain" of the computer. The CPU's structure can be broken down
into several key components, and its functions involve a series of tasks to ensure
that instructions are processed and data is manipulated correctly. These tasks
include fetching instructions, interpreting instructions, fetching data, processing
data, and writing data.
Processor Organization
The following are the five critical functions that a CPU performs during the
execution of a program:
1. Fetch Instructions:
Action: The CPU fetches the next instruction from memory (RAM). The
address of this instruction is stored in the Program Counter (PC).
How It Works:
o The PC provides the address of the next instruction to the memory
unit.
o The instruction is then fetched from memory and loaded into the
Instruction Register (IR) for decoding and execution.
o The Program Counter (PC) is incremented after the instruction is
fetched, so it points to the next instruction.
2. Interpret Instructions:
3. Fetch Data:
Action: The CPU fetches any data required for the operation (for example,
operands for arithmetic operations).
How It Works:
o The data may be located in registers, main memory (RAM), or I/O
devices.
o If data is in memory, the CPU uses the Address Bus to get the
address of the data and fetches it through the Data Bus.
4. Process Data:
Action: The CPU performs the actual operation on the fetched data (like
performing a calculation or logical comparison).
How It Works:
o The Arithmetic and Logic Unit (ALU) performs the required
operations, such as addition, subtraction, multiplication, logical
comparisons, etc.
o The ALU may also involve shifting data, performing bitwise
operations, or other operations depending on the instruction.
5. Write Data:
Action: The CPU writes the processed data back to memory or a register,
or it may output the data to an I/O device.
How It Works:
o The Data Bus is used to send the results to either a register,
memory, or I/O port.
o If data is written back to memory, the address of the location is
specified by the Address Bus.
This process repeats continuously, ensuring that the CPU can carry out a sequence
of tasks efficiently.
Instruction Format
Computers execute tasks based on a sequence of instructions. These instructions
are grouped into fields, each containing specific information that guides the CPU
in performing operations. The layout of these instruction bits is called an
instruction format. This format determines how the instruction is structured and
executed by the processor.
Definition of Instruction Format
An instruction format is a sequence of bits that defines the structure of a machine
language instruction. It consists of:
Opcode (Operation Code): Specifies the operation to be executed.
Operand: Represents the data or memory location involved in the
operation.
Addressing Mode: Determines how the operand is interpreted (e.g., direct,
indirect, register addressing).
The instruction format influences the efficiency and complexity of the CPU’s
instruction set. The length of an instruction is typically maintained in multiples of
8 bits (1 byte).
Types of Instruction Formats
Based on the number of addresses present in an instruction, instruction formats
can be classified into four main types:
1. Zero (0) Address Instruction Format
No address field is present in the instruction.
Uses stack-based architecture for operations.
Operands are implicitly on the stack (e.g., PUSH A, POP B).
Example:
Assembly Language: PUSH A, PUSH B
Stack Operation: TOS <- A, TOS <- B
2. One (1) Address Instruction Format
Contains only one address field.
One operand is stored in the accumulator, and the other in memory.
Requires special instructions like LOAD (to fetch data) and STORE (to
save data).
Example:
Assembly Language: LOAD C, ADD B, STORE T
Register Operation: AC <- M[T], AC <- M[C]
3. Two (2) Address Instruction Format
Contains two address fields.
The result of the operation can be stored in a different location.
Requires shorter assembly language instructions compared to three-
address formats.
Example:
Assembly Language: MOV R1, A, ADD R1, B
Register Operation: R1 <- M[A], R2 <- M[C]
4. Three (3) Address Instruction Format
Contains three address fields.
Requires shorter assembly instructions but more bits to store the
instruction.
Example:
Assembly Language: ADD R1, A, B
Register Operation: R1 <- M[A] + M[B]
Parts of an Instruction Format
Each instruction format consists of the following essential components:
1. Addressing Mode: Defines how an operand is accessed (e.g., direct,
indirect, register, or immediate addressing).
2. Operation Code (Opcode): Specifies the operation to be performed by the
processor.
3. Operand: Represents the data or memory address required for execution.
The number of operands varies based on the instruction format.
Fetch cycle
The address of the next instruction to execute is in the Program Counter (PC) at
the beginning of the fetch cycle.
Step 1: The address in the program counter is transferred to the Memory Address
Register (MAR), as this is the only register that is connected to the system bus
address lines.
Step 2: The address in MAR is put on the address bus, now a Read order is
provided by the control unit on the control bus, and the result appears on the data
bus and is then copied into the memory buffer register. Program counter is
incremented by one, to get ready for the next instruction. These two acts can be
carried out concurrently to save time.
Step 3: The content of the MBR is moved to the instruction register (IR).
After an instruction is fetched, the next step is to get the required data (source
operand) for execution. In this case, indirect addressing is used, meaning the
instruction contains a reference to a memory location where the actual data is
stored. Other addressing modes could also be used, but here, indirect addressing is
applied. If the operand is stored in a register, no additional fetching is needed.
Once the instruction is executed, a similar process is followed to store the result
back into memory if necessary.
Microoperations take place:
T1: MAR ←IR (address)
T2: MBR ←Memory T3:
IR (address) ← (MBR(Address))
Step 1: The instruction address field is passed to the MAR. This is used to fetch
the operand 's address.
Step 2: The address field of the IR is updated from the MBR.
Step 3: The IR is now in the state. Now IR is ready for the execute cycle
The initial three cycles (Fetch, Indirect, and Interrupt) are predictable and quick.
Each requires simple, small, and fixed micro-operation sequences. The same
micro-operation is repeated every time around in each event. Execute instruction
cycle is different from them. Like, there is N different series of micro-operations
that can occur for a computer with different N opcodes.
Example ADD R, X
T1: MAR ← (IR (address))
T2: MBR ← Memory
T3: R ← (R) + (MBR)
Step 1: The address portion of IR is loaded into the MAR.
Step 2: The address field of the IR is updated from the MBR, so the reference
memory location is read.
Step 3: Now, the contents of R and MBR are added by the ALU
RISC Architecture
It is a highly customized set of instructions used in portable devices due to system
reliability such as Apple iPod, mobiles/smartphones, Nintendo DS,
Features of RISC Processor
Some important features of RISC processors are:
1. One cycle execution time: For executing each instruction in a computer,
the RISC processors require one CPI (Clock per cycle). And each CPI
includes the fetch, decode and execute method applied in computer
instruction.
2. Pipelining technique: The pipelining technique is used in the RISC
processors to execute multiple parts or stages of instructions to perform
more efficiently.
3. A large number of registers: RISC processors are optimized with
multiple registers that can be used to store instruction and quickly respond
to the computer and minimize interaction with computer memory.
4. It supports a simple addressing mode and fixed length of instruction for
executing the pipeline.
5. It uses LOAD and STORE instruction to access the memory location.
6. Simple and limited instruction reduces the execution time of a process in a
RISC.
CISC Processor
CISC (Complex Instruction Set Computer) is a microprocessor architecture
developed by Intel.
It has a large collection of complex instructions ranging from simple to
specialized assembly-level instructions.
Takes longer to execute instructions due to complex operations.
Reduces the number of instructions in each program but ignores the number of
cycles per instruction.
Emphasizes building complex instructions in hardware, as hardware is faster
than software.
Slower than RISC but requires fewer instructions to perform tasks.
Examples: VAX, AMD, Intel x86, System/360.
Characteristics of CISC Processor
Following are the main characteristics of the RISC processor:
Shorter code length, requiring less RAM.
Complex instructions may take multiple clock cycles to execute.
Fewer instructions needed to write an application.
Easier assembly language programming.
Supports complex data structures and compilation of high-level languages.
Has fewer registers (typically 5 to 20) and more addressing modes.
Instructions can be larger than a single word.
Focuses on hardware-based instruction execution for speed.
RISC CISC
It is a Reduced Instruction Set It is a Complex Instruction Set
Computer. Computer.
It emphasizes on software to optimize It emphasizes on hardware to optimize
the instruction set. the instruction set.
It is a hard-wired unit of programming Microprogramming unit in CISC
in the RISC Processor. Processor.
It requires multiple register sets to It requires a single register set to store
store the instruction. the instruction.
RISC has simple decoding of CISC has complex decoding of
instruction. instruction.
Uses of the pipeline are simple in Uses of the pipeline are difficult in
RISC. CISC.
It uses a limited number of It uses a large number of instructions
instructions that requires less time to that requires more time to execute the
execute the instructions. instructions.
It uses LOAD and STORE that are It uses LOAD and STORE instruction
independent instructions in the in the memory-to-memory interaction
register-to-register a program's of a program.
interaction.
RISC has more transistors on memory CISC has transistors to store complex
registers. instructions.
The execution time of RISC is very The execution time of CISC is longer.
short.
RISC architecture can be used with CISC architecture can be used with
high-end applications like low-end applications like home
telecommunication, image processing, automation, security system, etc.
video processing, etc.
It has fixed format instruction. It has variable format instruction.
The program written for RISC Program written for CISC architecture
architecture needs to take more space tends to take less space in memory.
in memory.
Example of RISC: ARM, PA-RISC, Examples of CISC: VAX, Motorola
Power Architecture, Alpha, AVR, 68000 family, System/360, AMD and
ARC and the SPARC. the Intel x86 CPUs.
Register Organization
Registers are temporary storage locations inside the CPU.
A register is a very very fast memory that is built into the CPU.
Registers are used to store data temporarily.
Different processors have different register.
Registers are normally measured by the number of bits they can hold, for
example, an 8-bit register means it can store 8 bits of data or a 32-bit register
means it can store 32 bits of data.
Control Memory
The control function that specifies a microoperation is called as control
variable.
When control variable is in one binary state, the corresponding
microoperation is executed. For the other binary state the state of registers
does not change.
The active state of a control variable may be either 1 state or the 0 state,
depending on the application.
For bus-organized systems the control signals that specify microoperations
are groups of bits that select the paths in multiplexers, decoders, and
arithmetic logic units.
Control Word: The control variables at any given time can be represented
by a string of 1’s and 0's called a control word.
All control words can be programmed to perform various operations on
the components of the system.
Microprogram control unit: A control unit whose binary control variables
are stored in memory is called a microprogram control unit.
The control word in control memory contains within it a microinstruction.
The microinstruction specifies one or more micro-operations for the
system.
A sequence of microinstructions constitutes a microprogram.
The control unit consists of control memory used to store the
microprogram.
Control memory is a permanent i.e., read only memory (ROM).
The general configuration of a micro-programmed control unit
organization is shown as block diagram below.
The control memory is ROM so all control information is permanently stored.
The control memory address register (CAR) specifies the address of the
microinstruction and the control data register (CDR) holds the
microinstruction read from memory.
The next address generator is sometimes called a microprogram sequencer. It
is used to generate the next micro instruction address.
The location of the next microinstruction may be the one next in sequence or it
may be located somewhere else in the control memory.
So, it is necessary to use some bits of the present microinstruction to control
the generation of the address of the microinstruction.
Sometimes the next address may also be a function of external input
conditions.
The control data register holds the present microinstruction while next address
is computed and read from memory. The data register is times called a
pipeline register.
A computer with a microprogrammed control unit will have two separate
memories: a main memory and a control memory
The microprogram consists of microinstructions that specify various internal
control signals for execution of register microoperations
These microinstructions generate the microoperations to:
o fetch the instruction from main memory
o evaluate the effective address
o execute the operation
o return control to the fetch phase for the next instruction
Address Sequencing
Microinstructions are stored in control memory in groups, with each group
specifying a routine.
Each computer instruction has its own microprogram routine to generate the
microoperations.
The hardware that controls the address sequencing of the control memory
must be capable of sequencing the microinstructions within a routine and be
able to branch from one routine to another
Steps the control must undergo during the execution of a single computer
instruction:
o Load an initial address into the CAR when power is turned on in the
computer. This address is usually the address of the first
microinstruction that activates the instruction fetch routine – IR holds
instruction
o The control memory then goes through the routine to determine the
effective address of the operand – AR holds operand address
o The next step is to generate the microoperations that execute the
instruction by considering the opcode and applying a mapping process.
The transformation of the instruction code bits to an address in
control memory where the routine of instruction located is
referred to as mapping process.
o After execution, control must return to the fetch routine by executing
an unconditional branch
In brief the address sequencing capabilities required in a control memory are:
o Incrementing of the control address register.
o Unconditional branch or conditional branch, depending on status bit
conditions.
o A mapping process from the bits of the instruction to an address for
control memory.
o A facility for subroutine call and return.
The below figure shows a block diagram of a control memory and the
associated hardware needed for selecting the next microinstruction address.
Conditional Branching
Conditional branching is obtained by using part of the microinstruction to
select a specific status bit in order to determine its condition.
The status conditions are special bits in the system that provide parameter
information such as the carry-out of an adder, the sign bit of a number, the
mode bits of an instruction, and i/o status conditions.
The status bits, together with the field in the microinstruction that specifies a
branch address, control the branch logic.
The branch logic tests the condition, if met then branches, otherwise,
increments the CAR.
If there are 8 status bit conditions, then 3 bits in the microinstruction are used
to specify the condition and provide the selection variables for the multiplexer.
For unconditional branching, fix the value of one status bit to be one load the
branch address from control memory into the CAR.
Mapping of Instruction
A special type of branch exists when a microinstruction specifies a branch to
the first word in control memory where a microprogram routine is located.
The status bits for this type of branch are the bits in the opcode.
Assume an opcode of four bits and a control memory of 128 locations. The
mapping process converts the 4-bit opcode to a 7-bit address for control
memory shown in below figure.
Addressing Modes
Instruction Types
Instruction types in computer architecture can be classified into several categories
based on the operation they perform. Here's a breakdown of each:
1. Data Transfer Instructions:
o These instructions move data between registers, memory, and I/O
devices.
o Examples include:
MOV: Move data from one location to another (e.g., from a
register to memory).
PUSH/POP: Push data onto the stack or pop data from the
stack.
LOAD/STORE: Load data from memory into a register or
store data from a register into memory.
2. Arithmetic Instructions:
o These instructions perform basic arithmetic operations like
addition, subtraction, multiplication, and division.
o Examples include:
ADD: Add two operands.
SUB: Subtract one operand from another.
MUL: Multiply two operands.
DIV: Divide one operand by another.
3. Logical Instructions:
o These instructions perform logical operations, typically bitwise, on
data.
o Examples include:
AND: Perform a bitwise AND between two operands.
OR: Perform a bitwise OR between two operands.
XOR: Perform a bitwise exclusive OR between two
operands.
NOT: Perform a bitwise NOT (invert all bits of an
operand).
4. Control Instructions:
o These instructions alter the sequence of execution in a program,
usually through branching or loops.
o Examples include:
JUMP (JMP): Jump to another part of the program.
CALL: Call a function or subroutine.
RET: Return from a function or subroutine.
NOP (No Operation): A placeholder instruction that does
nothing (used for timing or debugging).
5. Input/Output (I/O) Instructions:
o These instructions are responsible for data transfer between the
processor and external devices (like keyboards, displays, or disks).
o Examples include:
IN: Read data from an input device or port.
OUT: Write data to an output device or port.
READ/WRITE: Instructions for more complex I/O
operations, such as reading from or writing to a file or a
network socket.
Each of these instruction types plays a vital role in enabling the processor to
perform a wide range of tasks and interact with various hardware components.
LOAD R1, 1000 ; Load value from memory address 1000 into R1
LOAD R2, 1004 ; Load value from memory address 1004 into R2
ADD R3, R1, R2 ; R3 = R1 + R2
STORE R3, 2000 ; Store result in memory address 2000
HALT ; Stop execution