Module 1
Module 1
Module 1
Mangaluru
(Affiliated to Visvesvaraya Technological University, Belagavi)
COMPUTER ORGANIZATION
(17CS34)
Prepared By:
Ganaraj K
Assistant Professor
Dept of ISE
Sahyadri College of Engineering and Management
Mangaluru
COMPUTER ORGANIZATION
[As per Choice Based Credit System (CBCS) scheme]
(Effective from the academic year 2015 -2016)
SEMESTER - III
Subject Code 15CS34 IA Marks 20
CREDITS – 04
Course objectives:
This course will enable students to
• Understand the basics of computer organization: structure and operation of computers and their
peripherals.
• Understand the concepts of programs as sequences or machine instructions.
• Expose different ways of communicating with I/O devices and standard I/O interfaces.
• Describe hierarchical memory systems including cache memories and virtual memory.
• Describe arithmetic and logical operations with integer and floating-point operands.
• Understand basic processing unit and organization of simple processor, concept of pipelining and
other large computing systems.
Module -1 Teaching
Hours
Memory System: Basic Concepts, Semiconductor RAM Memories, Read Only Memories,
Speed, Size, and Cost, Cache Memories – Mapping Functions, Replacement Algorithms,
10 Hours
Performance Considerations, Virtual Memories, Secondary Storage.
Textbook 1: Ch 5: 5.1 to 5.4, 5.5.1, 5.5.2, 5.6, 5.7, 5.9
Module-4
7|Page
Arithmetic: Numbers, Arithmetic Operations and Characters, Addition and Subtraction of
Signed Numbers, Design of Fast Adders, Multiplication of Positive Numbers, Signed
10 Hours
Operand Multiplication, Fast Multiplication, Integer Division, Floating-point Numbers and
Operations.
Textbook 1: Ch 2: 2.1, Ch 6: 6.1 to 6.7
Module-5
Text Books:
1. Carl Hamacher, Zvonko Vranesic, Safwat Zaky: Computer Organization, 5th Edition, Tata McGraw Hill,
2002.
Reference Books:
1. William Stallings: Computer Organization & Architecture, 9th Edition, Pearson, 2015.
8|Page
Module 1: BASIC STRUCTURE OF COMPUTERS
TYPES OF COMPUTERS
Desktop Computers
• These are most commonly used computers in home, schools and offices.
• This has
→ processing- & storage-units
→ video & audio output-units
→ Keyboard & mouse input-units.
Notebook Computers (Laptops)
• This is a compact version of a personal-computer (PC) made as a portable-unit.
Workstations
• These have more computational-power than PC.
Enterprise Systems (Mainframes)
• These are used for business data-processing.
• These have large computational-power and larger storage-capacity than workstations.
• These are referred to as
→ server at low-end and
→ Super-computers at high end.
Servers
• These have large database storage-units and can also execute requests from other
computers.
• These are used in banks & educational institutions.
Super Computers
• These are used for very complex numerical-calculations.
• These are used in weather forecasting, aircraft design and military applications.
FUNCTIONAL UNITS
• A computer consists of 5 functionally independent main parts: 1)input,
2)memory,3)arithmetic & logic, 4)output and 5)control units.
Input Unit
• The computer accepts the information in the form of program & data through an input-
device.
Eg: keyboard
• Whenever a key is pressed, the corresponding letter/digit is automatically translated into its
corresponding binary-code and transmitted over a cable to either the memory or the
processor.
Memory Unit
• This unit is used to store programs & data.
• There are 2 classes of storage:
1) Primary-storage is a fast-memory that operates at electronic-speed. Programs must
be stored in the memory while they are being executed.
2) Secondary-storage is used when large amounts of data & many programs have to
be stored. Eg: magnetic disks and optical disks(CD-ROMs).
• The memory contains a large number of semiconductor storage cells(i.e. flip-flops), each
capable of storing one bit of information.
• The memory is organized so that the contents of one word can be stored or retrieved in one
basic operation.
Output Unit
• This unit is used to send processed-results to the outside world.
Eg: printer, graphic displays etc.
Control Unit
• This unit is used for controlling the activities of the other units (such as memory, I/O
device).
• This unit sends control-signals (read/write) to other units and senses their states.
• Data transfers between processor and memory are also controlled by the control-unit
through timing-signals.
• Timing-signals are signals that determine when a given action is to take place.
PROCESSOR CLOCK
• Processor circuits are controlled by a timing signal called a clock.
• The clock defines regular time intervals called clock cycles.
• To execute a machine instruction, the processor divides the action to be performed into a
sequence of basic steps such that each step can be completed in one clock cycle.
• Let P=length of one clock cycle R=clock rate. Relation between P and R is given by R=1/P
which is measured in cycles per second.
• Cycles per second is also called hertz(Hz)
-----(1)
As shown in above figure, 6 clock cycles are required to complete two operations.
• As shown in above figure, if we use pipelining & prefetching, only 4 cycles are required to
complete same two operations.
• While executing the Add instruction, the processor can read the Move instruction from
memory.
• In the ideal case, if all instructions are overlapped to the maximum degree possible,
execution proceeds at the rate of one instruction completed in each clock cycle.
• A higher degree of concurrency can be achieved if multiple instruction pipelines are
implemented in the processor i.e. multiple functional units can be used to execute different
instructions parallely. This mode of operation is known as superscalar execution.
• With Superscalar arrangement, it is possible to complete the execution of more than one
instruction in every clock cycle.
• If SPEC rating=50 means that the computer under test is 50times as fast as reference
computer.
• The test is repeated for all the programs in the SPEC suite, and the geometric mean of the
results is computed.
Let SPECi be the rating for program i in the suite. The overall SPEC rating for the computer
is given by
BYTE ADDRESSABILITY
• In byte addressable memory, successive addresses refer to successive byte locations in the
memory.
• Byte locations have addresses 0, 1, 2. . . . .
• If the word length is 32 bits, successive words are located at addresses 0, 4, 8. .with each
word having 4 bytes.
WORD ALIGNMENT
• Words are said to be aligned in memory if they begin at a byte address that is a multiple of
the number of bytes in a word.
• For example, if the word length is 16(2 bytes), aligned words begin at byte addresses 0, 2, 4
. . . . . And for a word length of 64, aligned words begin at byte addresses 0, 8, 16. . . . . . .
• Words are said to have unaligned addresses, if they begin at an arbitrary byte address.
MEMORY OPERATIONS
• Two basic operations involving the memory are: Load(Read/Fetch) and Store(Write).
• The Load operation transfers a copy of the contents of a specific memory location to the
processor. The memory contents remain unchanged.
• The steps for Load operation:
1) Processor sends the address of the desired location to the memory
2) Processor issues „read‟ signal to memory to fetch the data
3) Memory reads the data stored at that address
4) Memory sends the read data to the processor
• The Store operation transfers the information from the processor register to the specified
memory location. This will destroy the original contents of that memory location.
• The steps for Store operation are:
1) Processor sends the address of the memory location where it wants to store data
2) Processor issues „write‟ signal to memory to store the data
3) Content of register(MDR) is written into the specified memory location.
INSTRUCTIONS & INSTRUCTION SEQUENCING
• A computer must have instructions capable of performing 4 types of operations:
1) Data transfers between the memory and the processor registers (MOV, PUSH,
POP, XCHG),
2) Arithmetic and logic operations on data (ADD, SUB, MUL, DIV, AND, OR,
NOT),
3) Program sequencing and control (CALL.RET, LOOP, INT),
4) I/0 transfers (IN, OUT)
REGISTER TRANSFER NOTATION (RTN)
• We identify a memory location by a symbolic name (in uppercase alphabets).
For example, LOC, PLACE, NUM etc indicate
memory locations.R0, R5 etc indicate processor
register. DATAIN, OUTSTATUS etc indicate I/O
registers.
• For example,
R<-[LOC] means that the contents of memory location LOC are transferred into
processor register R1 (The contents of a location are denoted by placing square
brackets around the name of the location). R3<-[R1]+[R2] indicates the operation
that adds the contents of registers R1 and R2 ,and then places their sum into register
R3.
• This type of notation is known as RTN(Register Transfer Notation).
CONDITION CODES
• The processor keeps track of information about the results of various operations. This is
accomplished by recording the required information in individual bits, called condition code
flags.
• These flags are grouped together in a special processor-register called the condition code
register (or statue register).
ADDRESSING MODES
• The different ways in which the location of an operand is specified in an instruction are
referred to as addressing modes (Table 2.1).
• Clearly, the immediate mode is only used to specify the value of a source-operand.
INDIRECTION AND POINTERS
• In this case, 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. We
refer to this address as the effective address(EA) of the operand.
Indirect Mode
• The EA of the operand is the contents of a register(or memory-location) whose address
appears in the instruction.
• The register (or memory-location) that contains the address of an operand is called a
pointer. {The indirection is denoted by ( ) sign around the register or memory-location}.
E.g: Add (R1),R0;The operand is in memory. Register R1 gives the effective-
address(B) of the operand. The data is read from location B and added to
contents of register R0
* To execute the Add instruction in fig (a), the processor uses the value which is in register
R1, as the EA 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 fig (b). In this
case, the processor first reads the contents of memory location A, then requests a second read
operation using the value B as an address to obtain the operand
RELATIVE MODE
• This is similar to index-mode with an exception: The effective address is determined using
the PC in place of the general purpose register Ri.
• The operation is indicated as X(PC).
ASSEMBLY LANGUAGE
• A complete set of symbolic names and rules for their use constitute an assembly language.
• The set of rules for using the mnemonics in the specification of complete instructions and
programs is called the syntax of the language.
• Programs written in an assembly language can be automatically translated into a sequence
of machine instructions by a program called an assembler.
• The user program in its original alphanumeric text formal is called a source program, and
the assembled machine language program is called an object program.
• Move instruction is written is
MOVE R0,SUM ;The mnemonic MOVE represents the binary
pattern, or OP code, for the operation performed by
the instruction.
• The instruction
ADD #5,R3 ;Adds the number 5 to the contents of register R3 and puts
the result back into register R3.
MEMORY-MAPPED I/O
• Some address values are used to refer to peripheral device buffer-registers such as DATAIN
and DATAOUT.
• No special instructions are needed to access the contents of the registers; data can be
transferred between these registers and the processor using instructions such as Move, Load
or Store.
• For example, contents of the keyboard character buffer DATAIN can be
transferred to register R1 in the processor by the instruction
MoveByte DATAIN,R1
• The MoveByte operation code signifies that the operand size is a byte.
• The Testbit instruction tests the state of one bit in the destination, where the bit
position to be tested is indicated by the first operand.
STACKS
• A stack is a list of data elements with the accessing restriction that elements can be added
or removed at one end of the list only. This end is called the top of the stack, and the other
end is called the bottom (Figure: 2.21).
• The terms push and pop are used to describe placing a new item on the stack and removing
the top item from the stack, respectively.
• A processor-register is used to keep track of the address of the element of the stack that is
at the top at any given time. This register is called the SP (Stack Pointer).
SUBROUTINES
• A subtask consisting of a set of instructions which is executed many times is called a
subroutine.
• The program branches to a subroutine with a Call instruction (Figure: 2.24).
• Once the subroutine is executed, the calling-program must resume execution starting from
the instruction immediately following the Call instructions i.e. control is to be transferred
back to the calling-program. This is done by executing a Return instruction at the end of the
subroutine.
• The way in which a computer makes it possible to call and return from subroutines is
referred to as its subroutine linkage method.
• The simplest subroutine linkage method is to save the return-address in a specific location,
which may be a register dedicated to this function. Such a register is called the link register.
• When the subroutine completes its task, the Return instruction returns to the calling-
program by branching indirectly through the link-register.
• The Call instruction is a special branch instruction that performs the following operations:
→ Store the contents of PC into link-register.
→ Branch to the target-address specified by the instruction.
• The Return instruction is a special branch instruction that performs the operation:
→ Branch to the address contained in the link-register.
STACK FRAME
• Stack frame refers to locations that constitute a private work-space for the subroutine
(Figure:2.26).
• The work-space is
→ created at the time the subroutine is entered &
→ freed up when the subroutine returns control to the calling-program.
• Following is a program for adding a list of numbers using subroutine with the parameters
passed to stack
Multiply Ri,Rj
Rj= [Ri]*[Rj]
Division Ri,Rj
Rj=[Ri]/[Rj]