Computer Architectures And Organisation
Computer Architectures And Organisation
(Internal Design)
WHY COA??
Computer Architecture helps us
• to understand the functionalities of a system
• how exactly all the units in the system are arranged and
interconnected.
• A programmer can view architecture in terms of instructions,
addressing modes and registers.
Objectives of Studying COA
• To know the background of internal communication of computer
• To have better idea on how to write assemble language programs
• To be clear with memory management techniques
• To better with IO devices communication with processor
• To notice how to perform computer arithmetic operations
• To be clear with pipeline
Unit 1- Functional Blocks of a Computer
• Output Unit: The output unit consists of output devices that are
attached with the computer. It converts the binary data coming from
CPU to human understandable form. The common output devices are
monitor, printer, plotter etc.
Memory :
These are numbered as R0, R1, R2….Rn-1, and used to store temporary data during any ongoing operation. Its
content can be accessed by assembly programming. Modern CPU architectures tends to use more GPR so that
register-to-register addressing can be used more, which is comparatively faster than other addressing modes.
1. Carry C: Set to 1 if an add operation produces a carry or a subtract operation produces a borrow; otherwise
cleared to 0.
2. Overflow V: Useful only during operations on signed integers.
3. Zero Z: Set to 1 if the result is 0, otherwise cleared to 0.
4. Negate N: Meaningful only in signed number operations. Set to 1 if a negative result is produced.
5. Extend X: Functions as a carry for multiple precision arithmetic operations.
These are generally decided by ALU.
Advantages
1.Fast access: Since the registers are located inside the processor,
they can be accessed quickly without having to wait for data to
be fetched from memory.
2.Reduced memory access: The use of registers can help reduce the
number of memory accesses required, which can improve the
overall performance of the system.
3.Specialized functionality: Each register has a specific function, such
as the accumulator for arithmetic operations and the program
counter for storing the address of the next instruction. This
specialized functionality can make programming and debugging
easier.
4.Reduced complexity: By providing dedicated registers for specific
purposes, reduces the complexity of the programming and
execution process.
The Instruction Set Architecture (ISA) of a CPU is a set of rules that
defines the software interface between the hardware and the
software.
6. I/O Instructions:
1. If applicable, instructions for input/output operations.
7. Exception Handling:
1. Mechanisms for handling exceptions, interrupts, and other abnormal conditions.
Importance Of Instruction Set
Architecture ( ISA )
Defining The Compatibility And Portability
• It ensures that software written for a particular ISA can run on any microprocessor
that implements that ISA.
• This compatibility allows software developers to write applications that can be executed
on a wide range of microprocessors without requiring significant modifications or
recompilation.
Software Development
• The ISA defines the available instructions, addressing modes, and data types that
programmers can use to write software.
• It provides a high- level abstraction of the underlying hardware, allowing developers to
focus on writing efficient and optimized code without needing to understand the
intricacies of the microprocessor’s internal design.
Performance Optimization
• The ISA influences the performance of the microprocessor. The selection and design of instructions impact the execution
speed, code density, and efficiency of the processor.
• By carefully designing the ISA, microprocessor architects can optimize instruction execution and memory access,
leading to better performance in terms of speed and power consumption.
Compiler Design
• Compilers translate high-level programming languages into machine code that can be executed by the microprocessor.
• By understanding the ISA, compiler designers can develop optimization techniques and code generation strategies
that exploit the microprocessor’s features, improving the performance of the generated code.
Hardware Design
• The ISA serves as a blueprint for microprocessor designers to implement the hardware architecture.
• Hardware designers use the ISA as a reference to ensure compatibility, develop efficient pipelining and caching
strategies, and optimize the microarchitecture for improved performance and power efficiency.
System Bus in Computer Architecture
Examples-
• A 32-bit bus has thirty two (32) wires and thus can transmit
32 bits of data at a time.
• A 64-bit bus has sixty four (64) wires and thus can transmit
64 bits of data at a time.
2) Control Bus
• control bus is used to transfer the control and timing signals from
one component to the other component.
• The CPU uses control bus to communicate with the devices that are
connected to the computer system.
• The CPU transmits different types of control signals to the system
components.
• It is bi-directional.
• Control signals are generated in the control unit of CPU.
• Timing signals are used to synchronize the memory and I/O
operations with a CPU clock.
Typical control signals hold by control bus
• Memory read – Data from memory address location to be placed on data bus.
• Memory write – Data from data bus to be placed on memory address location.
• I/O Read – Data from I/O address location to be placed on data bus.
• I/O Write – Data from data bus to be placed on I/O address location.
• Other control signals hold by control bus are interrupt, interrupt acknowledge,
bus request, bus grant and several others.
• The type of action taking place on the system bus is indicated by these control
signals.
Example-
• When CPU wants to read or write data, it sends the memory read or memory
write control signal on the control bus to perform the memory read or write
operation from the main memory. Similarly, when the processor wants to read
from an I/O device, it generates the I/O read signal.
3) Address Bus
Example-
• When CPU wants to read or write data, it sends the memory read or memory write control
signal on the control bus to perform the memory read or write operation from the main
memory and the address of the memory location is sent on the address bus.
• If CPU wants to read data stored at the memory location (address) 4, the CPU send the
value 4 in binary on the address bus.
• The width of address bus determines the amount of physical memory
addressable by the processor.
• It determines the size of the memory that the computer can use.
• The wider is the address bus, the more memory a computer will be able to
use.
• The addressing capacity of the system can be increased by adding more
address lines.
EXAMPLE
• An address bus that consists of 16 wires can convey 216 (= 64K) different
addresses.
• An address bus that consists of 32 wires can convey 232 (= 4G) different
addresses.
Q-1 Which of the following system bus is used to designate the source or destination of
the data on the bus itself?
• Control bus
• Data bus
• Address bus
Q-2 The bus which is used to transfer data from main memory to peripheral device is-
• Data bus
• Output bus
• Control bus
• Address bus
Q3- How many memory locations a system with a 32-bit address bus can address?
• 28
• 216
• 232
• 32
Q4- How many bits can be transmitted at a time using a bus with 32 data lines?
• 8 bits
• 16 bits
• 32 bits
• 232 bits
Q5- A microprocessor has a data bus with 64 lines and an address bus with 32 lines.
The maximum number of bits that can be stored in memory is-
• 32 x 232
• 32 x 264
• 64 x 232
• 64 x 264
Q6- The address bus with a ROM of size 1024 x 8 bits is-
• 8 bits
• 10 bits
• 12 bits
• 16 bits
Q-7 The data bus width of a ROM of size 2048 x 8 bits is-
• 8
• 10
• 12
• 16
Instruction Execution Cycle
• A program residing in the memory unit of the computer consists of a sequence of
instructions. The program is executed in the computer by going through a cycle for each
instruction.
• Each instruction cycle in turn is subdivided into a sequence of sub cycles or phases. In the basic
computer each instruction cycle consists of the following phases:
1. Fetch an instruction from memory.
2. Decode the instruction.
3. Read the effective address from memory if the instruction has an indirect address.
4. Execute the instruction.
• Upon completion of step 4, the control goes back to step 1 to fetch, decode, and execute the next
instruction. This process continues indefinitely unless a HALT instruction is encountered.
The Instruction Execution Cycle, also known as the
machine cycle or instruction cycle, is the process by
which a computer processes a single instruction. It
consists of a sequence of steps that the central
processing unit (CPU) performs to fetch, decode,
execute, and store results for an instruction. The cycle is
repeated for each instruction in a program.
1.Fetch:
1. The CPU fetches the instruction from memory. The address of the instruction is typically
stored in the MAR and program counter (PC) contains address of next instruction to be
executed.
2. After each fetch cycle, the program counter is incremented to point to the next
instruction in memory.
2.Decode:
1. The fetched instruction is decoded to determine what operation needs to be performed
and what operands are involved.
2. The control unit extracts the opcode (operation code) from the instruction, which specifies
the operation to be performed.
3.Execute:
1. The CPU performs the operation specified by the opcode on the data operands. This may
involve arithmetic or logical operations, data transfers, or control transfers.
2. The result of the operation is stored in registers or memory.
4.Write back:
1. If the result of the execution is to be stored, it is written back to a register or memory
location.
2. The status flags in the CPU may also be updated based on the result.
• Timing signals play a crucial role in coordinating the various stages of
the instruction execution cycle within a computer's central processing
unit (CPU).
• These signals ensure that each stage occurs at the right time and in
the correct sequence.
Instruction execution cycle with associated
timing and control signals:
1. Fetch Stage:
Timing Signal: T0 and T1, Control Signal: Memory Read (MAR)
• At T0:
• The program counter (PC) holds the memory address of the FIRST instruction of
the program.
• The Memory Address Register (MAR) is loaded with the contents of the PC.
• The Memory Read (MREQ) signal is activated to request the instruction from
memory.
• At T1:
• The Instruction Register (IR) is loaded with the instruction fetched from memory.
• The PC is incremented to prepare for the next instruction.
2. Decode Stage:
Timing Signal: T2 Instruction Decode (ID)
• The instruction in the IR is decoded.
• The opcode IR (12-14) is extracted to determine the type of operation
to be performed.
• Operand addresses IR (0-11) moves to MAR
• Indirect bit IR(15) transferred to flip flop I
Execute Stage:
MICROOPERATIONS (1)
MICROOPERATION (2)
R f(R, R)
f: shift, load, clear, increment, add, subtract, complement,
and, or, xor, …
Computer Organization Computer Architecture
Register Transfer & -operations 63 Register Transfer Language
DESIGNATION OF REGISTERS
MAR
– Registers may also be represented showing the bits of data they contain
DESIGNATION OF REGISTERS
• Designation of a register
- a register
- portion of a register
- a bit of a register
15 0 15 8 7 0
R2 PC(H) PC(L)
Numbering of bits Subfields
REGISTER TRANSFER
R2 R1
REGISTER TRANSFER
R3 R5
– the data lines from the source register (R5) to the destination
register (R3)
– Parallel load in the destination register (R3)
– Control lines to perform the action
CONTROL FUNCTIONS
• Often actions need to only occur if a certain condition is true
• This is similar to an “if” statement in a programming language
• In digital systems, this is often done via a control signal, called
a control function
– If the signal is 1, the action takes place
• This is represented as:
P: R2 R1
Load
Transfer occurs here
• The same clock controls the circuits that generate the control function
and the destination register
• Registers are assumed to use positive-edge-triggered flip-flops
SIMULTANEOUS OPERATIONS
P: R3 R5, MAR IR
MEMORY TRANSFER
• Collectively, the memory is viewed at the register level as
a device, M.
• Since it contains multiple locations, we must specify
which address in memory we will be using
• This is done by indexing memory references
M
Memory Read
AR
unit Write
MEMORY READ
MEMORY WRITE
M[MAR] R1
MICROOPERATIONS
ARITHMETIC MICROOPERATIONS
• The basic arithmetic microoperations are
– Addition
– Subtraction
– Increment
– Decrement
C4 S3 S2 S1 S0
Binary Adder-Subtractor
B3 A3 B2 A2 B1 A1 B0 A0
C3 C2 C1 C0
FA FA FA FA
C4 S3 S2 S1 S0
Binary Incrementer A3 A2 A1 A0 1
x y x y x y x y
HA HA HA HA
C S C S C S C S
C4 S3 S2 S1 S0
ARITHMETIC CIRCUIT
Cin
S1
S0
A0 X0 C0
S1 D0
S0 FA
B0 0 4x1 Y0 C1
1 MUX
2
3
A1 X1 C1
S1 FA D1
S0
B1 0 4x1 Y1 C2
1 MUX
2
3
A2 X2 C2
S1 FA D2
S0
B2 0 4x1 Y2 C3
1 MUX
2
3
A3 X3 C3
S1 FA D3
S0
B3 0 4x1 Y3 C4
1 MUX
2
3 Cout
0 1
LOGIC MICROOPERATIONS
• Specify binary operations on the strings of bits in registers
– Logic microoperations are bit-wise operations, i.e., they work on the
individual bits of data
– useful for bit manipulations on binary data
– useful for making logical decisions based on the bit value
• There are, in principle, 16 different logic functions that can
be defined over two binary input variables
A B F0 F1 F2 … F13 F14 F15
0 0 0 0 0 … 1 1 1
0 1 0 0 0 … 1 1 1
1 0 0 0 1 … 0 1 1
1 1 0 1 0 … 1 0 1
Ai
0
Bi
1
4X1 Fi
MUX
2
3 Select
S1
S0
Function table
S1 S0 Output -operation
0 0 F=AB AND
0 1 F=AB OR
1 0 F=AB XOR
1 1 F = A’ Complement
– Selective-set AA+B
– Selective-complement AAB
– Selective-clear A A • B’
– Mask (Delete) AA•B
– Clear AAB
– Insert A (A • B) + C
– Compare AAB
– ...
SELECTIVE SET
1100 At
1010 B
1110 At+1 (A A + B)
SELECTIVE COMPLEMENT
1100 At
1010 B
0110 At+1 (A A B)
SELECTIVE CLEAR
1100 At
1010 B
0100 At+1 (A A B’)
MASK OPERATION
1100 At
1010 B
1000 At+1 (A A B)
CLEAR OPERATION
1100 At
1010 B
0110 At+1 (A A B)
INSERT OPERATION
• An insert operation is used to introduce a specific bit pattern
into A register, leaving the other bit positions unchanged
• This is done as
– A mask operation to clear the desired bit positions, followed by
– An OR operation to introduce the new bits into the desired
positions
– Example
» Suppose you wanted to introduce 1010 into the low order
four bits of A: 1101 1000 1011 0001 A (Original)
1101 1000 1011 1010 A (Desired)
SHIFT MICROOPERATIONS
• There are three types of shifts
– Logical shift
– Circular shift
– Arithmetic shift
• What differentiates them is the information that goes into
the serial input
LOGICAL SHIFT
• In a logical shift the serial input to the shift is a 0.
CIRCULAR SHIFT
• In a circular shift the serial input is the bit that is shifted out of
the other end of the register.
ARITHMETIC SHIFT
• An arithmetic shift is meant for signed binary numbers
(integer)
• An arithmetic left shift multiplies a signed number by two
• An arithmetic right shift divides a signed number by two
• The main distinction of an arithmetic shift is that it must keep
the sign of the number the same as it performs the
multiplication or division
ARITHMETIC SHIFT
• An left arithmetic shift operation must be checked for the
overflow
0
sign
bit
S
MUX H0
0
1
A0
A1 S
MUX H1
0
A2 1
A3
S
MUX H2
0
1
S
MUX H3
0
1
Serial
input (IL)
• Purpose:
–Microinstructions translate machine instructions (complex
instructions understood by the CPU) into even smaller, simpler
operations that the CPU's hardware can directly execute.
–They act as an intermediate layer between machine code and the
hardware circuitry, providing more granular control over the internal
operations.
FORMAT OF MICROINSTRUCTION
• F1, F2, F3 are the micro-operation fields. They determine micro-operations for
the computer.
• CD is the condition for branching. They choose the status bit conditions.
• BR is the branch field. It determines the type of branch.
• AD is the address field. It includes the address field whose length is 7 bits.
• LINK FOR DETAIL DOCUMENT
Computer Organization Computer Architecture
• We have 7 CPU registers that their outputs are connected to
2 MUX 8 X 1 to form the 2 buses A and B.
• The A and B are inputted to ALU unit in which its operation is selected
by their select lines among different arithmetic and logic operations.
• The resulted ALU data can is directed to the input of all 7 registers
which one of them will be selected according to 3 X 8 decoder
connected to LD inputs of the register.
• For example to perform operation R1 = R2 + R3
• The control then provides
• MUXA select R2
• MUXB select R3
• OPR in ALU operation for ADD
• SELD to direct destination register R1
These four control signals are generated in control unit in start of each clock cycle
ensuring operands are selected beside correct ALU operation and result is chosen
in one clock cycle only.
Control word
Encoding of ALU Operations