COA Mod 1 Ktunotes - in
COA Mod 1 Ktunotes - in
COA Mod 1 Ktunotes - in
INTRODUCTION
Computer: A device that accepts input, processes data, stores data, and produces output, all
according to a series of stored instructions.
Software: A computer program that tells the computer how to perform particular tasks.
Hardware: Includes the electronic and mechanical devices that process the data; refers to the
computer as well as peripheral devices.
Peripheral devices: Used to expand the computer’s input, output and storage capabilities.
Network: Two or more computers and other devices that are connected, for the purpose of
sharing data and programs.
Computer Types:Computers are classified based on the parameters likeSpeed of operation, Cost,
Computational power and Type of application
Difference between computer organization and computer architecture
Architecture describes what the computer does and organization describes how it does it.
Computer organization:
Computer organization is concerned with the way the hardware components operate and
the way they are connected together to form computer system. It includes Hardware details
transparent to the programmer such as control signal and peripheral. It describes how the
computer performs. Example: circuit design, control signals, memory types this all are under
computer organization.
Computer Architecture:
Computer architecture is concerned with the structure and behavior of computer system
as seen by the user. It includes information, formats, instruction set and techniques for
addressing memory. It describes what the computer does.
FUNCTIONAL UNITS:
The computer system is divided into five separate units for its operation.
Input Unit.
ALU.
Control Unit.
Memory Unit.
Output Unit.
Input & Output unit
The method of feeding data and
programs to a computer is accomplished
secondary storage which refers to the external storage devices and other external media such as
hard drive and optical media.
Arithmetic Logical Unit (ALU)
After you enter data through the input device it is stored in the primary storage unit.
Arithmetic Logical Unit performs the actual processing of data and instruction. The major
operations performed by the ALU are addition, subtraction, multiplication, division, logic and
comparison.
Data is transferred to ALU from storage unit when required. After processing, the output
is returned back to storage unit for further processing or getting stored.
Control Unit
The next component of computer is the control unit, which acts like the supervisor seeing
whether things are done in proper fashion. Control unit controls and coordinates the entire
operations of the computer system.
The control unit determines the sequence in which computer programs and instructions
are executed. Things like processing of programs stored in the main memory, interpretation of
the instructions and issuing of signals for other units of the computer to execute them.
It also acts as a switch board operator when several users access the computer
simultaneously. Thereby it coordinates the activities of computer’s peripheral equipment as they
perform the input and output. Therefore it is the manager of all operations.
Central Processing Unit (CPU)
The Arithmetic Logical Unit (ALU), Control Unit (CU) and Memory Unit (MU) of a
computer system are jointly known as the central processing unit. We may call CPU as the brain
of any computer system. It is just like a human brain that takes all major decisions, makes all
sorts of calculations and directs different part of the computer by activating and controlling the
operations.
Add R1, R0 Add contents of R1, R0 and place the sum to R0.
BUS STRUCTURES
The bus shown in Figure 3 is a simple structure that implements the interconnection
network. Only one source/destination pair of units can use this bus to transfer data at any one
time.
The bus consists of three sets of lines used to carry address, data, and control signals. I/O
device interfaces are connected to these lines, as shown in Figure 4 for an input device. Each I/O
The memory consists of many millions of storage cells, each of which can store a bit of
information having the value 0 or 1. The memory is organized so that a group of n bits can be
stored or retrieved in a single, basic operation. Each group of n bits is referred to as a word of
information, and n is called the word length.
The memory of a computer can be schematically represented as a collection of words, as
shown in Figure 5.Modern computers have word lengths that typically range from 16 to 64 bits.
Aunit of 8 bits iscalled a byte. Machine instructions may require one or more words for
their representation. Accessing the memory to store or retrieve a single item of information,
either a wordor a byte, requires distinct names or addresses for each location.
The memory can have up to 2k addressable locations.The2k addresses constitute the
address space of the computer.
Figure 4 Figure 5
Byte Addressability
We now have three basic information quantities to deal with: bit, byte, and word. A byte
is always 8 bits, but the word length typically ranges from 16 to 64 bits. It is impractical to
assign distinct addresses to individual bit locations in the memory. The most practical
assignment is to have successive addresses refer to successive byte locations in the memory.
The term byte-addressable memory is used for this assignment. Byte locations have
addresses 0, 1, 2 . . . Thus, if the word length of the machine is 32 bits, successive words are
located at addresses 0, 4, 8… with each word consisting of four bytes.
Big-Endian and Little-Endian Assignments
There are two ways that byte addresses can be assigned across words. The name big-
endian is used when lower byte addresses are used for the more significant bytes (the leftmost
bytes) of the word. The name little-endian is used for the opposite ordering, where the lower
byte addresses are used for the less significant bytes (the rightmost bytes) of the word.
In both cases, byte addresses 0, 4, and 8… are taken as the addresses of successive words
in the memory of a computer with a 32-bit word length. These are the addresses used when
accessing the memory to store or retrieve a word.
Figure 6
Word Alignment
In the case of a 32-bit word length, natural word boundaries occur at addresses 0, 4, 8…
We say that the word locations have aligned addresses if they begin at a byte address that is a
multiple of the number of bytes in a word. For practical reasons associated with manipulating
binary-coded addresses, the number of bytes in a word is a power of 2. Hence, if the word length
is 16 (2 bytes), aligned words begin at byte addresses 0, 2, 4... and for a word length of 64 (23
bytes), aligned words begin at byte addresses 0, 8, 16…
MEMORY OPERATIONS
Both program instructions and data operands are stored in the memory. Two basic
operations involvingthe memory are needed, namely, Read and Write.The Read operation
transfers a copy of the contents of a specific memory location tothe processor. The memory
contents remain unchanged.
To start a Read operation, theprocessor sends the address of the desired location to the
memory and requests that itscontents be read. The memory reads the data stored at that address
and sends them to theprocessor.
The Write operation transfers an item of information from the processor to a
specificmemory location, overwriting the former contents of that location. To initiate a
Writeoperation, the processor sends the address of the desired location to the memory,
togetherwith the data to be written into that location. The memory then uses the address and
datato perform the write.
As another example, consider the operation that adds the contents of registers R1 and R2,
and places their sum into register R3. This action is indicated as
R3 ← [R1] + [R2]
This type of notation is known as Register Transfer Notation (RTN). Note that the
righthandside of an RTN expression always denotes a value, and the left-hand side is the name of
a location where the value is to be placed, overwriting the old contents of that location.
Assembly-Language Notation
We need another type of notation to represent machine instructions and programs. For
this, we use assembly language. For example, a generic instruction that causes the transfer
described above, from memory location LOC to processor register R1, is specified by the
statement
Move LOC, R1
The contents of LOC are unchanged by the execution of this instruction, but the old
contents of register R1 are overwritten.
The second example of adding two numbers contained in processor registers R1 and R2
and placing their sum in R3 can be specified by the assembly-language statement
Add R1, R2, R3
In this case, registers R1 and R2 hold the source operands, while R3 is the destination.
10
11
ADDRESSING MODES
The different ways for specifying the locations of instruction operands are known as
addressing modes.
In the addressing modes that follow, the instruction does not give the operand or its
address explicitly. Instead, it provides information from which the memory address of the
operand can be determined. This address is known as Effective Address (EA) of the
operand.
Indirect mode: The effective address of the operand is the contents of a register or
memory location whose address appears in the instruction. We denote indirection by placing the
name of the register given in the instruction in parentheses ().
To execute the Add instruction in Figure 2.11(a), the processor uses the value B, which is
in register R1, as the effective address of the operand. It requests a read operation from the
memory to read the contents of location B. The value read is the desired operand, which the
processor adds to the contents of register R0. Indirect addressing through a memory location is
also possible as shown in Figure 2.11(b). In this case the processor first reads the contents of
memory location A, then request a second read operation using the value B as an address to
obtain the operand.
12
The register or memory location that contains the address of an operand is called a
pointer.
13
Figure 2.13 illustrates two ways of using the index mode. In Figure 2.13(a), the index
register R1 contains the address of memory location and the value X defines an offset
(displacement) from this address to the location where the operand is found. Figure 2.13(b), Here
the constant X corresponds to a memory address and the contents of the index register define the
offset of the operand. in either case, the effective address is the sum of two values; one is given
explicitly in the instruction and the other is stored in a register.
Base with index: A second register may be used to contain the offset X, in which case the
index mode is written as, (Ri,Rj). The effective address is the sum of the contents of register Ri
and Rj.The second register is called as base register. This form of addressing provides more
flexibility in accessing operands, because both components of the effective address can be
changed.
Base with index and offset: Uses two registers plus a constant denoted as X(Ri,Rj). The
effective address is the sum of the constant X and the contents of register Ri and Rj. This added
flexibility is useful in accessing multiple components inside each item in a record, where the
beginning of an item is specified by (Ri,Rj) part of the addeessing mode.
4. Relative Addressing
In index addressing, if the program counter PC, is used instead of a general-purpose
register then X(PC) can be used to address a memory location that is X bytes away from the
location presently pointed to by the program counter. Since the addressed location is identified
"relative" to the program counter, which always identifies the current execution point in a
program, the name Relative mode is associated with this type of addressing.
Relative mode: The effective address is determined by the Index mode using the
program counter in place of the general-purpose register Ri.
This mode can be used to access data operands. But, its most common use is to specify
the target address in branch instructions. An instruction such as Branch>0 LOOP causes
program execution to go to the branch target location identified by the name LOOP if the branch
condition is satisfied.
5. Additional Modes
Many computers provide additional modes intended to aid certain programming tasks.
The two modes described next are useful for accessing data items in successive locations in the
memory.
Auto-increment mode:The effective address of the operand is the contents of a register
specified in the instruction. After accessing the operand, the contents of this register are
automatically incremented to point to the next item in a list.
We denote the Auto-increment mode by putting the specified register in parentheses, to
show that the contents of the register are used as the effective address, followed by a plus sign to
14
indicate that these contents are to be incremented after the operand is accessed. Thus, the Auto-
increment mode is written as (Ri)+
Auto-decrement mode:The contents of a register specified in the instruction are first
automatically decremented and are then used as the effective address of the operand.
The Auto-increment mode is written as -(Ri)
To execute a program, the processor fetches one instruction at a time and performs the
operations specified. Instructions are fetched from successive memory locations until a branch
or a jump instruction is encountered.
The processor keeps track of the address of the memory location containing the next
instruction to be fetched using the program counter, PC. After fetching an instruction, the
contents of the PC are updated to point to the next instruction in the sequence. A branch
instruction may load a different value into the PC. Another key register in the processor is the
instruction register, IR.
Suppose that each instruction comprises 4 bytes, and that it is stored in one memory
word. To execute an instruction, the processor has to perform the following three *steps:
1. Fetch the contents of the memory location pointed to by the PC. The contents of this
location are the instruction to be executed; hence they are loaded into the IR. In
register transfer notation, the required action is
IR←[[PC]]
15
2. Increment the PC to point to the next instruction. Assuming that the memory is byte
addressable, the PC is incremented by 4; that is
PC←[PC] + 4
3. Carry out the operation specified by the instruction in the IR.
Fetching an instruction and loading it into the IR is usually referred to as the instruction
fetch phase. Performing the operation specified in the instruction constitutes the instruction
execution phase.
Single Bus organization of Processor
Figure shows the organization in which the arithmetic and logic unit (ALU) and all the
registers are interconnected via a single common bus. This bus is internal to the processor and
should not be confused with the external bus that connects the processor to the memory and I/O
devices.
The data and address lines of the external memory bus are connected to the internal
processor bus via the memory data register, MDR, and the memory address register, MAR,
16
respectively. Register MDR has two inputs and two outputs. Data may be loaded into MDR
either from the memory bus or from the internal processor bus.
The data stored in MDR may be placed on either bus. The input of MAR is connected to
the internal bus, and its output is connected to the external bus. The control lines of the memory
bus are connected to the instruction decoder and control logic block.
Three registers Y, Z, and TEMP registers are used by the processor for temporary
storage during execution of some instructions. The multiplexer MUX selects either the output of
register Y or a constant value 4 to be provided as input A of the ALU. The constant 4 is used to
increment the contents of the program counter.
With few exceptions, an instruction can be executed by performing one or more of the
following operations in some specified sequence:
Transfer a word of data from one processor register to another or to the ALU
Perform an arithmetic or a logic operation and store the result in a processor register
Fetch the contents of a given memory location and load them into a processor
register
Store a word of data from a processor register into a given memory location
Register Transfers
Instruction execution involves a sequence of steps in which data are transferred from one
register to another. For each register, two control signals are used to place the contents of that
register on the bus or to load the data on the bus into
the register.
The input and output of register Ri are
connected to the bus via switches controlled by the
signals Riin and Riout, respectively. When Riin is set to
1, the data on the bus are loaded into Ri. Similarly,
when Riout, is set to 1, the contents of register Ri are
placed on the bus. While Riout is equal to 0, the bus
can be used for transferring data from other registers.
Suppose that we wish to transfer the contents
of register R1 to register R4. This can be
accomplished as follows: Figure 8
Enable the output of register R1 by setting R1out to 1. This places the contents of R1
on the processor bus.
Enable the input of register R4 by setting R4in, to 1. This loads data from the
processor bus into register R4.
17
7All operations and data transfers within the processor take place within time periods
defined by the processor clock.
18
Figure 10
As an example of a read operation, consider the instruction Move (R1),R2. The actions
needed to execute this instruction are:
1. MAR [RI]
2. Start a Read operation on the memory bus
3. Wait for the MFC(Memory Function Completed) response from the memory
4. Load MDR from the memory bus
5. R2 [MDR]
These actions may be carried out as separate steps, but some can be combined into a
single step. Each action can be completed in one clock cycle, except action 3 which requires one
or more clock cycles, depending on the speed of the addressed device.
The memory read operation requires three steps, which can be described by the signals
being activated as follows:
1. Rlout, MARin, Read
2. MDRinE, WMFC
3. MDRout, R2in
where WMFC is the control signal that causes the processor's control circuitry to wait for
the arrival of the MFC signal.
19
Consider the instruction Add (R3),R1 which adds the contents of a memory location
pointed to by R3 to register R 1.
Executing this instruction requires the following actions:
1. Fetch the instruction.
2. Fetch the first operand (the contents of the memory location pointed to by R3).
3. Perform the addition.
4. Load the result into RI.
Instruction execution proceeds as follows.
Step 1: The instruction fetch operation is initiated
by loading the contents of the PC into the MAR and
sending a Read request to the memory. The Select signal
is set to Select4, which causes the multiplexer MUX to
select the constant 4. This value is added to the operand at
input B, which is the contents of the PC, and the result is
stored in register Z.
Step 2: The updated value is moved from register
Z back into the PC, while waiting for the memory to
respond. Figure 11
Step 3:The word fetched from the memory is loaded into the IR.
(Steps 1 through 3 constitute the instruction fetch phase, which is the same for all
instructions.)
Step 4: The instruction decoding circuit interprets the contents of the IR. This enables the
control circuitry to activate the control signals for steps 4 through 7, which constitute the
execution phase. The contents of register R3 are transferred to the MAR in step 4, and a memory
read operation is initiated.
Step 5: the contents of R1 are transferred to register Y, to prepare for the addition
operation.
Step 6: When the Read operation is completed, the memory operand is available in
register MDR, and the addition operation is performed. The contents of MDR are gated to the
bus, and thus also to the B input of the ALU, and register Y is selected as the second input to the
ALU by choosing SelectY.
Step 7: The sum is stored in register Z, and then transferred to R1. The End signal causes
a new instruction fetch cycle to begin by returning to step 1.
This discussion accounts for all control signals in Figure 11 except Yin in step 2. There is
no need to copy the updated contents of PC into register Y when executing the Add instruction.
20
But, in Branch instructions the updated value of the PC is needed to compute the Branch target
address.
To speed up the execution of Branch instructions, this value is copied into register Y in
step 2. Since step 2 is part of the fetch phase, the same action will be performed for all
instructions. This does not cause any harm because register Y is not used for any other purpose at
that time.
Branch Instruction
A branch instruction replaces the contents of the PC with the branch target address. This
address is usually obtained by adding an offset X, which is given in the branch instruction, to the
updated value of the PC. Figure 12 gives a control sequence that implements an unconditional
branch instruction. Processing starts, as usual, with the fetch phase. This phase ends when the
instruction is loaded into the IR in step 3.
The offset value is extracted from the IR by the
instruction decoding circuit, which will also perform sign
extension if required. Since the value of the updated PC is
already available in register Y, the offset X is gated onto
the bus in step 4, and an addition operation is performed.
The result, which is the branch target address, is loaded
into the PC in step 5.
The offset X used in a branch instruction is usually Figure 12
the difference between the branch target address and the
address immediately following the branch instruction.
For example: if the branch instruction is at location 2000 and if the branch target address
is 2050, the value of X must be 46. The PC is incremented during the fetch phase before
knowing the type of the instruction being executed. Thus, when the branch address is computed
in step 4, the PC value uses the updated value, which points to the instruction following the
branch instruction in the memory.
We used the simple single-bus structure to illustrate the basic ideas. The resulting control
sequences are quite long because only one data item can be transferred over the bus in a clock
cycle.
To reduce the number of steps needed, most commercial processors provide multiple
internal paths that enable several transfers to take place in parallel. Figure depicts a three-bus
structure used to connect the registers and the ALU of a processor.
The register file is said to have three ports. There are two outputs, allowing the contents
of two different registers to be accessed simultaneously and have their contents placed on buses
A and B. The third port allows the data on bus C to be loaded into a third register during the
same clock cycle.
21
Buses A and B are used to transfer the source operands to the A and B inputs of the ALU,
where an arithmetic or logic operation may be performed. The result is transferred to the
destination over bus C. If needed, the ALU may simply pass one of its two input operands
unmodified to bus C. We will call the ALU control signals for such an operation R=A or R=B.
The three-bus arrangement obviates the need for registers Y and Z.
A second feature is the introduction of the
Incrementer unit, which is used to increment the PC by 4.
Using the Incrementer eliminates the need to add 4 to the PC
using the main ALU. The source for the constant 4 at the
ALU input multiplexer is still useful. It can be used to
increment other addresses, such as the memory addresses in
LoadMultiple and StoreMultiple instructions.
Consider the three-operand instruction
Add R4,R5,R6
The control sequence for executing this instruction is
given as below
22