Professional Documents
Culture Documents
Co Module 1 2019-20
Co Module 1 2019-20
MODULE 1
Basic Structure of Computers: Computer Types, Functional Units, Basic Operational
Concepts, Bus Structures, Software, Performance – Processor Clock, Basic Performance
Equation (upto 1.6.2 of Chap 1 of Text).
Machine Instructions and Programs: Numbers, Arithmetic Operations and Characters, IEEE
standard for Floating point Numbers, Memory Location and Addresses, Memory Operations,
Instructions and Instruction Sequencing (upto 2.4.6 of Chap 2 and 6.7.1 of Chap 6 of Text).
TYPES OF COMPUTERS
Desktop Computers
• These are most commonly used computers in home, schools and offices.
• This has
→ processing- & storage-units
Workstations
• These have more computational-power than PC.
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.
1
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
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:
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
• Memory in which any location can be reached in a short and fixed amount of time after specifying
its address is called RAM (Random Access Memory).
• Any arithmetic operation is initiated by bringing the required operand into the processor (i.e.
registers), where the operation is performed by the ALU.
Output Unit
• This unit is used to send processed-results to the outside world.
• Timing-signals are signals that determine when a given action is to take place.
2
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
• The instruction is then passed to the control-unit, which generates the timing-signals that determine
when a given action is to take place
• The PC(Program Counter) contains the memory-address of the next-instruction to be fetched &
executed.
• During the execution of an instruction, the contents of PC are updated to point to next instruction.
• The processor also contains „n‟ general-purpose registers R0 through Rn-1.
• The MAR (Memory Address Register) holds the address of the memory-location to be accessed.
• The MDR (Memory Data Register) contains the data to be written into or read out of the addressed
location.
• To fetch an operand, it's address is placed into MAR & control-unit issues Read signal. As a result,
the operand is transferred from memory into MDR, and then it is transferred from MDR to ALU.
3
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
• At some point during execution, contents of PC are incremented to point to next instruction in the
program. [The instruction is a combination of opcode and operand].
BUS STRUCTURE
• A bus is a group of lines that serves as a connecting path for several devices.
There are many ways to connect different parts inside a computer together.
A group of lines that serves as a connecting path for several devices is called a bus.
Address/data/control
• Bus must have lines for data transfer, address & control purposes.
4
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
• Because the bus can be used for only one transfer at a time, only 2 units can actively use the bus at
any given time.
• Bus control lines are used to arbitrate multiple requests for use of the bus.
• Main advantage of single bus: Low cost and flexibility for attaching peripheral devices.
• Systems that contain multiple buses achieve more concurrency in operations by allowing 2 or more
transfers to be carried out at the same time. Advantage: better performance. Disadvantage: increased
cost.
• The devices connected to a bus vary widely in their speed of operation. To synchronize their
operational speed, the approach is to include buffer registers with the devices to hold the information
during transfers.
Buffer registers prevent a high-speed processor from being locked to a slow I/O device during a
sequence of data transfers.
5
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
Illustration of the steps taken by the CPU to execute an instruction that adds two numbers. The
instruction is: R = X + Y.
Software
❑ In order for a user to enter and run an application program, the computer must already contain
some system software in its memory
6
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
❑ System software is a collection of programs that are executed as needed to perform functions
such as
◆ Controlling I/O units to receive input information and produce output results
❑ Translating programs from source form prepared by the user into object form consisting of
machine instructions
❑ Linking and running user-written application programs with existing standard library routines,
such as numerical computation packages
❑ System software is thus responsible for the coordination of all activities in a computing system
Operating system
❑ system (OS)Operating
◆ This is a large program, or actually a collection of routines, that is used to control the sharing of
and interaction among various computer units as they perform application programs
❑ The OS routines perform the tasks required to assign computer resource to individual application
programs
◆ These tasks include assigning memory and magnetic disk space to program and data files,
moving data between memory and disk units, and handling I/O operations
❑ In the following, a system with one processor, one disk, and one printer is given to explain the
basics of OS
◆ Assume that part of the program’s task involves reading a data file from the disk into the
memory, performing some computation on the data, and printing the results
7
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
Multiprogramming or Multitasking
Performance
❑ The speed with which a computer executes programs is affected by the design of its hardware
and its machine language instructions
❑ Because programs are usually written in a high-level language, performance is also affected by
the compiler that translates programs into machine languages
8
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
Processor Clock
The clock speed or operating frequency usually measured in hertz is the fundamental rate in
cycles per second, at which a computer performs its most basic operations.
Every computer has the “clock generator” to generate clock signals used
to synchronize the activities within the various chips. To do this, a crystal is used.
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 the length P of one clock cycle, its inverse is the clock rate, R=1/P
T – processor time required to execute a program that has been prepared in high-level language
N – number of actual machine language instructions needed to complete the execution (note:
loop)
S – average number of basic steps needed to execute one machine instruction. Each step
completes in one clock cycle
R – clock rate
9
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
T=(NxS)/R
where T is the processor time required to execute a program, N is the number of instruction
executions, and S is the average number of basic steps needed to execute one machine instruction
1.
2. A program contains 1000 instructions. Out of that 25% instructions requires 4 clock
cycles,40% instructions requires 5 clock cycles and remaining require 3 clock cycles for
execution. Find the total time required to execute the program running in a 1 GHz machine.
10
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
2. One’s complement
3. Two’s complement
Binary Digit or Bit is the smallest unit of computation on most digital computers
11
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
Power
Calculation Value
of 2
0
2 1 1
1
2 2 2
Dec
Binary
imal
0 00 1 0
2 * 0 + 2 * 0 = 2*0 +1*0 = 0+0=0
1 01 1 0
2 * 0 + 2 * 1 = 2*0 +1*1 =0+1= 1
1 0
2 10 2 * 1 + 2 * 0 = 2*1 +1*0 = 2+0=2
1 0
3 11 2 * 1 + 2 * 1 = 2*1 +1*1 = 2+1=3
Decimal Binary
0 000 Power of 2 Calculation Value
0
1 001 2 1
1
2 010 2 2 2
2
3 011 2 2*2 4
4 100
5 101
6 110
7 111
12
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
Converting from decimal to binary (base 10 to base 2) will also produce a weighted binary
number with the right-hand most bit being the Least Significant Bit or LSB, and the left-hand
most bit being the Most Significant Bitor MSB, and we can represent this as
Convert binary to decimal by finding the decimal equivalent of the binary array of
digits 1011001012 and expanding the binary digits into a series with a base of 2giving an
equivalent of 35710 in decimal or denary.
7-bit Binary
Decimal
Number
5 0000101
14 0001110
26 0011010
53 0110101
What is the biggest decimal number that you can represent in binary using 8-bit ?
13
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
How many different decimal number that you can represent in binary using 8-bit ?
We can use a single bit to identify the sign of a signed binary number as being positive or
negative in value. So to represent a positive binary number (+n) and a negative (-n)
binary number, we can use them with the addition of a sign.
For signed binary numbers the most significant bit (MSB) is used as the sign bit. If the
sign bit is “0”, this means the number is positive in value. If the sign bit is “1”, then the
number is negative in value. The remaining bits in the number are used to represent the
magnitude of the binary number in the usual unsigned binary number format way.
Then we can see that the Sign-and-Magnitude (SM) notation stores positive and negative
values by dividing the “n” total bits into two parts: 1 bit for the sign and n–1 bits for the
value which is a pure binary number. For example, the decimal number 53 can be
expressed as an 8-bit signed binary number as follows:
If all bits in a
byte are inverted by
changing each 1 to 0 and
each 0 to 1, we have
formed the one’s complement of the number.
14
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
Two’s Complement
The two’s complement is a method for representing positive and negative integer values in
binary. The useful part of two’s complement is that it automatically includes the sign bit.
+ 1 Add 1
-----------
15
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
The two’s complement is a method for representing positive and negative integer values in
binary. The useful part of two’s complement is that it automatically includes the sign bit.
16
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
The bit size is always important with twos complement, since you must be able to tell
where the sign bit is.
◼ First, you convert the magnitude of the number to binary, and pad to the word size
(4 bits).
◼ Otherwise, you must negate the binary number by inverting the bits and adding 1.
The bit size is always important with twos complement, since you must be able to tell
where the sign bit is.
◼ First, you convert the magnitude of the number to binary, and pad to the word size
(4 bits).
◼ Otherwise, you must negate the binary number by inverting the bits and adding 1.
0110
Negate 1001
Add 1 1
--------
17
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
The bit size is always important with twos complement, since you must be able to tell
where the sign bit is.
◼ First, you convert the magnitude of the number to binary, and pad to the word size
(8 bits).
◼ Otherwise, you must negate the binary number by inverting the bits and adding 1.
Using 7 bits to represent each number, write the representations of 23 and -23 in signed
magnitude and 2's complement integers
18
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
19
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
The operation is carried out by means of the following steps: (i) At first, 2’s complement of the
subtrahend is found.(ii) Then it is added to the minuend.(iii) If the final carry over of the sum is
1, it is dropped and the result is positive.(iv) If there is no carry over, the two’s complement of
the sum will be the result and it is negative
Convert the following pairs of decimal numbers to 5-bit 2’s-complement numbers, then add
them.
a. -5 and 7 b. -3 and -8
20
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
Arithmetic Overflow:
In 2's complement number representation system, n bits can represent values in the range
(-2n-1) to (+2n-1 – 1).
21
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
Repeat for subtraction operation, where the second number of each pair to be
subtracted from first number. State whether or not overflow occurs in each case
22
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
23
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
24
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
Big-endian is an order in which the "big end" (most significant value in the sequence) is
stored first (at the lowest storage address).
Little-endian is an order in which the "little end" (least significant value in the sequence)
is stored first.
25
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
B
ig-
Endia
n and
Little-
Endia
n
Assign
ments
Hexadecimal numbers: A group of 4 bits can take any value between 0 (0000 binary) and 15
(1111 binary). In hexadecimal, we replace each group of 4 bits with a single digit to represent
the value 0 to 15. Since we only have digits 0 to 9, we use letters A to E to represent values 10 to
15. Here is a table of binary, denary and hex values:
26
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
For example,
◼ If the word length is 16 (2 Bytes), aligned words begin at byte addresses 0, 2, 4,....
◼ If the word length is 32 (4 Bytes), aligned words begin at byte addresses 0, 4, 8,....
Words are said to have Unaligned Addresses, if they begin at an arbitrary byte-address
Memory Operations
Data transfer between memory and processor register (Ex.: MOV, LOAD, STOREPUSH,
POP )
Arithmetic and logical operations on data (Ex.: ABB, SUB, DIV, MUL)
27
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
1. Memory Location
2. Processor register
28
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
C=A+B
i.e., C <- [A]+[B] Meaning: Add the contents of the memory location A and B ; And Store the
result in memory location C
29
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
ANSWER
MOVE B, C //C <- [B] Move the contents of memory location B to Memory
//Location C
ADD A, C //Add the contents of Memory location A with C. And store the result
General Format:
Example: ADD A
Acc <- [Acc]+[A] Meaning : Add the contents of accumulator with the memory location
A ; And Store the result in the accumulator register
30
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
Note:
Load A ;will load accumulator with the contents of the memory location A
Store A ;will store the contents of the accumulator into memory location A
31
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
Problems
32
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
R3<–[R1]+[R2]
A, B-source operands
C-destination operands
B <–[A] + [B]
33
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
5) Branching
• Branch-type of instruction loads a new value into program counter.
• So processor fetches & executes instruction at this new address called “branch target”
• Conditional branch-causes a branch if a specified condition is satisfied.
• E.g. Branch>0 LOOP –conditional branch instruction .it executes only if it satisfies
condition.
6) Condition codes
• Recording required information in individual bits called “condition code flags”.
• These flags are grouped together in a special processor register called “condition code
register” or “status register”
• Individual condition code flags-1 or 0.
• 4 commonly used flags.
Instruction Execution: There are 2 phases for executing an instruction. They are, • Instruction Fetch •
Instruction Execution Instruction Fetch: The instruction is fetched from the memory location whose
address is in PC. This is then placed in IR. Instruction Execution: Instruction in IR is examined and
decoded to determine which operation is to be performed. Program execution Steps: To begin executing a
program, the address of first instruction must be placed in PC. The processor control circuits use the
information in the PC to fetch & execute instructions one at a time in the order of increasing order. This is
called Straight line sequencing. During the execution of each instruction, the PC is incremented by 4 to
point to the address of next instruction.
34
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
35
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
Floating-Point Representation
◼ For example:
36
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
Single Precision
Double Precision
37
Bahubali College of Engineering, Shravanabelagola
Computer Organisation 18EC35 K Ramamani, HOD in E&CE
38