CSC 303 Lecture Note-1
CSC 303 Lecture Note-1
Computer does not understand human language. Any data, viz., letters, symbols, pictures, audio, videos,
etc., fed to computer should be converted to machine language first, which is a sequence of zeros and
ones.
Computers not only process numbers, letters and special symbols but also complex types of data such as
sound and pictures. However, these complex types of data take a lot of memory and processor time
when coded in binary form. This limitation necessitates the need to develop better ways of handling
long streams of binary digits. Higher number systems are used in computing to reduce these streams of
binary digits into manageable form. This helps to improve the processing speed and optimize memory
usage.
To a computer, everything is a number, i.e., alphabets, pictures, sounds, etc., are numbers. A number
system is a set of symbols used to represent values derived from a common base or radix. Number
systems can be classified into four major categories:
Binary 2 01
Octal 8 01234567
Decimal 10 0123456789
Hexadecimal 16 0123456789ABCDEF
1
Bits − A bit is a smallest possible unit of data that a computer can recognize or use. Computer usually
uses bits in groups.
Bytes − group of eight bits is called a byte. Half a byte is called a nibble.
1 Byte 8 Bits
Text Code
Text code is format used commonly to represent alphabets, punctuation marks and other symbols. Four
most popular text code systems are −
2
EBCDIC
ASCII
Extended ASCII
Unicode
EBCDIC
Extended Binary Coded Decimal Interchange Code is an 8-bit code that defines 256 symbols. Given
below is the EBCDIC Tabular column
ASCII
American Standard Code for Information Interchange is an 8-bit code that specifies character values
from 0 to 127.
Extended ASCII
Extended American Standard Code for Information Interchange is an 8-bit code that specifies character
values from 128 to 255.
Unicode
Unicode Worldwide Character Standard uses 4 to 32 bits to represent letters, numbers and symbol.
4
CONVERSION
When many number systems are considered together, the subscript must always be put so as to
differentiate the number systems. The magnitude of a number can be considered using these parameters:
Absolute value
Place value or positional value
Base value
The absolute value is the magnitude of a digit in a number. For example, the digit 5 in 7458 has an
absolute value of 5 according to its value in the number line.
The place value of a digit in a number refers to the position of the digit in that number i.e. whether;
tens, hundreds, thousands etc. The total value of a number is the sum of the place value of each digit
making the number.
The base value of a number also known as the radix, depends on the type of the number systems that is
being used. The value of any number depends on the radix. For example, the number 100 10 is not
equivalent to 1002.
To convert numbers from one system to another, the following will be considered:
- Converting between binary and decimal numbers.
- Add up the products, the answer will be the decimal number in base ten.
EXAMPLE
Divide the integral part continuously by 2, for the fractional part, proceed as follows:
Multiply the fractional part by 2 and note down the product
- Take the fractional part of the immediate product and multiply it by 2 again.
- Continue this process until the fractional part of the subsequent product is 0 or starts to repeat
itself.
- Combine the two parts together to set the binary equivalent.
Example
6
0.750×2 =1.500
0.500×2 =1.000 (fraction becomes zero)
Therefore 0.37510 = 0.0112
NB: When converting a real number from binary to decimal, work out the integral part and the fractional
parts separately then combine them.
To convert a base 8 number to its decimal equivalent we use the same method as we did with binary
numbers. However, it is important to note that the maximum absolute value of an octal digit is 7. For
example, 982 is not a valid octal number because digit 9 is not an octal digit, but 7368 is valid because
all the digits are in the range 0-7. Example below shows how to convert an octal number to a decimal
number.
Example
Convert 5128 to its base 10 equivalent
Place value 82 81 80
64 8 1
Octal digit 5 1 2
Write each number under its place value as shown below
Multiply each number by its place value
N10= (5 x 82) + (1 x 81) + (2 x 80)
= (5 x 64) + 8 + 2
= 320 + 8 + 2
N10= 33010
Therefore 5128 =33010
7
To convert an octal number to binary, each digit is represented by three binary digits because the
maximum octal digit i.e. 7 can be represented with a maximum of seven digits. See table 1: Table 1:
Octal to Binary
Example
Solution
Working from left to the right, each octal number is represented using three digits and then combined
we get the final binary equivalent. Therefore:
3=0112
2=0102
1=0012
Combining the three from left to right
3 2 1
011 010 001
3218 = 0110100012
8
To convert hexadecimal number to base 10 equivalent we proceed as follows:
First, write the place values starting from the right-hand side.
- If a digit is a letter such as ‘A’ write its decimal equivalent
- Multiply each hexadecimal digit with its corresponding place value and then add the products.
- The following examples illustrate how to convert hexadecimal number to a decimal number
Example
Convert the hexadecimal number 11116 to its binary equivalent
Solution
Since F is equivalent to a binary number 11112 the hexadecimal number are therefore represented using
4 digits as shown in the table 2 below.
9
00 00 0000
01 01 0001
02 02 0010
03 03 0011
04 04 0100
05 05 0101
06 06 0110
07 07 0111
08 08 1000
09 09 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111
The simplest method of converting a hexadecimal number to binary is to express each hexadecimal digit
as a four bits’ binary digit number and then arranging the group according to their corresponding
positions as shown in the example below.
To convert binary numbers to their binary equivalents, simply group the digits of the binary number into
groups of four from right to left e.g. 11010001.The next step is to write the hexadecimal equivalent of
each group e.g. 1101- D
0001- 1
The equivalent of 11010001 is D1H or D116
Example
10
Convert 32116 to its binary equivalents
Hexadecimal 3 2 1
Binary Equivalent 0011 0010 0001
Combining the three sets of bits, we get 0011001000012
32116 = 0011001000012
It has proved difficult to develop devices that can understand natural language directly due to the
complexity of natural languages. However, it is easier to construct electric circuits based on the binary
or ON and OFF logic. All forms of data can be represented in binary system format. Other reasons for
the use of binary are that digital devices are more reliable, small and use less energy as compared to
analog devices.
A fixed-point number consists of a whole or integral part and a fractional part, with the two parts
separated by a radix point (decimal point in base 10, binary point in base 2, etc.).
10.1012 to decimal
3.375 to binary
Fixed-point representation has a radix point known as decimal point. Fixed-point numbers having
decimal points at the right end of the number are treated as integers because the fixed-point numbers
having decimal points at the left end of the number are treated as fractions. In this method, the decimal
point position is settled because the number saved in the memory is considered as an integer or as a
fraction.
Binary numbers can be divided into two: signed and unsigned binary numbers. The unsigned are
continually considered as positive integers and are defined as 0s in the MSB while the signed contrast
for negative numbers and are defined as 1s in the MSB.
11
Signed Numbers
Signed numbers contain both sign and magnitude of the number. Generally, the sign is placed in front of
number. So, we have to consider the positive sign for positive numbers and negative sign for negative
numbers. Therefore, all numbers can be treated as signed numbers if the corresponding sign is assigned
in front of the number.
If sign bit is zero, it indicates the binary number is positive. Similarly, if sign bit is one, it indicates the
binary number is negative.
Representation of Un-Signed Binary Numbers
The bits present in the un-signed binary number holds the magnitude of a number. That means, if the
un-signed binary number contains ‘N’ bits, then all N bits represent the magnitude of the number, since
it does not have any sign bit.
Example
Consider the decimal number 108. The binary equivalent of this number is 1101100. This is the
representation of unsigned binary number 108
10810 = 11011002
It is having 7 bits. These 7 bits represent the magnitude of the number 108.
Representation of Signed Binary Numbers
The Most Significant Bit (MSB)
The MSB of signed binary numbers is used to indicate the sign of the numbers. Hence, it is also called
as sign bit. The positive sign is represented by placing ‘0’ in the sign bit. Similarly, the negative sign is
represented by placing ‘1’ in the sign bit.
If the signed binary number contains ‘N’ bits, then N−1 bits only represent the magnitude of the number
since one bit, MSB is reserved for representing sign of the number. Below is an 8-bit representation:
magnitude
Sign bit
There are three types of representations for signed binary numbers
● Sign-Magnitude form
● 1’s complement form
● 2’s complement form
Representation of a positive number in all these 3 forms is same. But, only the representation of negative
number will differ in each form.
Example
12
Consider the positive decimal number +108. The binary equivalent of magnitude of this number is
1101100. These 7 bits represent the magnitude of the number 108. Since it is positive number, consider
the sign bit as zero, which is placed on left most side of magnitude.
+108
+10810 = 01101100
Therefore, the signed binary representation of positive decimal number +108 is 𝟎𝟏𝟏𝟎𝟏𝟏𝟎𝟎. So, the
same representation is valid in sign-magnitude form, 1’s complement form and 2’s complement form for
positive decimal number +108.
Sign-Magnitude form
In sign-magnitude form, the MSB is used for representing sign of the number and the remaining bits
represent the magnitude of the number. So, just include sign bit at the left most side of unsigned binary
number. This representation is similar to the signed decimal numbers representation.
Example
Consider the negative decimal number -108. The magnitude of this number is 108. We know the
unsigned binary representation of 108 is 1101100. It is having 7 bits. All these bits represent the
magnitude.
Since the given number is negative, consider the sign bit as 1, which is placed on left most side of
magnitude.
−108
−10810 = 11101100
Therefore, the sign-magnitude representation of -108 is 11101100.
+6 0110
-6 1110
+0 0000
-0 1000
+7 0111
-7 1111
The above are examples of sign magnitude. Note that it is 4-bit representation
13
Range
From the above table, it is obvious that if the word size is n bits, the range of numbers that can be
represented is from - (2n-1 -1) to + (2n-1 -1). A table of word size and the range of Sign Magnitude (SM)
numbers that can be represented as shown in the following.
Word size The range for SM numbers
4 -7 to +7
8 -127 to +127
16 -32767 to +32767
32 -2147483647 to +2147483647
Notice that the bit sequence 1101corresponds to the unsigned number 13, as well as the number –5 in
SM notation. Its value depends only on the way the user or the programmer interprets the bit sequence.
Disadvantages of sign magnitude
● There are two notations for 0 (0000 and 1000), which is very inconvenient when the computer
wants to test for a 0 result.
● It is not convenient for the computer to perform arithmetic.
Hence, due to the above mentioned ambiguities, sign magnitude notation is generally not used to
represent signed numbers inside a computer.
The 1’s complement of a number is obtained by complementing all the bits of signed binary number.
So, 1’s complement of positive number gives a negative number. Similarly, 1’s complement of negative
number gives a positive number.
That means, if you perform two times 1’s complement of a binary number including sign bit, then you
will get the original signed binary number.
Example
Consider the negative decimal number -108. The magnitude of this number is 108. The signed binary
representation of 108 (in 8-bit) is 01101100, the MSB of this number is zero, which indicates positive
number. Complement of zero is one and vice-versa. So, replace zeros by ones and ones by zeros in order
to get the negative number.
−10810 = 10010011
Therefore, the 1’s complement of 10810 is
10010011
100100112.
14
2’s complement form
The 2’s complement of a binary number is obtained by adding one to the 1’s complement of signed
binary number. So, 2’s complement of positive number gives a negative number. Similarly, 2’s
complement of negative number gives a positive number.
That means, if you perform two times 2’s complement of a binary number including sign bit, then you
will get the original signed binary number.
In a computer, numbers are stored in registers where there is reserved a designated number of bits for
the storage of numbers in binary form. Registers come in different sizes, four, eight, sixteen,etc.
It refers to the operational units of the computer and their interconnection that realize the architectural
specification.
15
Why Study Computer Architecture?
1. Enable better systems: make computer faster, cheaper, smaller and more reliable by
exploiting advances and changes in underlying technology.
3. Enable better solutions to problems: software innovation is built on trends and changes in
computer architecture.
5. Technology shift: such as memory bottleneck, data intensive applications, security and
privacy issues, power/energy constraints etc.
• Microarchitecture: It describes the data paths, data processing elements and data storage
elements. It also describes how to implement the ISA.
• System Design: Which includes all of the other hardware components within a
computing system such as:
ISA
An Instruction Set Architecture (ISA) is part of the abstract model of a computer that defines
how the CPU is controlled by the software. The ISA defines the supported data types, the
registers, how the hardware manages main memory, key features (such as virtual memory) of
instructions a microprocessor can execute, and the input/output model of multiple ISA
16
implementations. The ISA can be extended by adding instructions or other capabilities, or by
adding support for larger addresses and data values.
Functions of ISA
The ISA acts as an interface between the hardware and the software, specifying both what
the processor is capable of doing as well as how it gets done.
The ISA provides the only way through which a user is able to interact with the hardware.
It can be viewed as a programmer’s manual because it’s the portion of the machine that’s
visible to the assembly language programmer, the compiler writer, and the application
programmer.
It allocates memory to instructions and also acts upon memory address mode.
Importance of ISA
Understanding what the instruction set can do and how the compiler makes use of those
instructions can help developers write more efficient code.
It can also help developers understand the output of the compiler which can be useful for
debugging.
Computer Architecture is concerned with the way Computer Organization is concerned with the
hardware components are connected together to form a structure and behavior of a computer system as
computer system. seen by the user.
It acts as the interface between hardware and software. It deals with the components of a connection in a
system.
It helps us to understand the functionalities of a Computer Organization tells us how exactly all
system. the units in the system are arranged and
interconnected.
17
A programmer can view architecture in terms of Whereas Organization expresses the realization of
instructions, addressing modes and registers. architecture.
It deals with high-level design issues. Computer Organization deals with low-level
design issues.
In computer organization, instruction formats refer to the way instructions are encoded and represented
in machine language. There are several types of instruction formats, including zero, one, two, and three-
address instructions.
Each type of instruction format has its own advantages and disadvantages in terms of code size,
execution time, and flexibility. Modern computer architectures typically use a combination of these
formats to provide a balance between simplicity and power.
A computer performs a task based on the instructions provided. Instructions in computers are comprised
of groups called fields. These fields contain different information for computers which are all written in
0s and 1s. Each field has a different significance or meaning. The most common fields are:
Address field which contains the location of the operand, i.e., register or memory location.
18
Mode field which specifies how operand is to be founded.
Generally, CPU organization is of three types based on the number of address fields:
Stack organization
In the first organization, the operation is performed using a special register called the accumulator.
In the second, multiple registers are used for the computation purpose.
In the third organization, they work on stack based operation because it does not contain any address
field. We generally see a blend of various organizations applied.
Types of Instructions
These instructions do not specify any operands or addresses. Instead, they operate on data stored in
registers or memory locations implicitly defined by the instruction. For example, a zero-address
instruction might simply add the contents of two registers together without specifying the register
names.
A stack-based computer does not use the address field in the instruction. To evaluate an expression, it
is first converted to reverse Polish Notation i.e. Postfix Notation.
Expression: X =(A+B)*(C+D)
Postfixed: X=AB+CD+*
TOP means top of stack
M[X] is any memory location
19
PUSH A TOP = A
PUSH B TOP = B
PUSH C TOP = C
PUSH D TOP = D
Expression: X = (A+B)*(C+D)
AC is accumulator
M[] is any memory location
M[T] is temporary location
20
LOAD A AC = M[A]
ADD B AC = AC + M[B]
STORE T M[T] = AC
LOAD C AC = M[C]
ADD D AC = AC + M[D]
MUL T AC = AC * M[T]
STORE X M[X] = AC
21
MOV R1, A R1 = M[A]
MUL R1, R2 R1 = R1 * R2
MOV X, R1 M[X] = R1
Expression: X = (A+B)*(C+D)
R1, R2 are registers
M[] is any memory location
22
ADD R1, A, B R1 = M[A] + M[B]
Advantages
Zero-address instructions
They are simple and can be executed quickly since they do not require any operand fetching or
addressing. They also take up less memory space.
One-address instructions
They allow for a wide range of addressing modes, making them more flexible than zero-address
instructions. They also require less memory space than two or three-address instructions.
Two-address instructions
They allow for more complex operations and can be more efficient than one-address instructions
since they allow for two operands to be processed in a single instruction. They also allow for a
wide range of addressing modes.
Three-address instructions
They allow for even more complex operations and can be more efficient than two-address
instructions since they allow for three operands to be processed in a single instruction. They also
allow for a wide range of addressing modes.
Disadvantages
Zero-address instructions
They can be limited in their functionality and do not allow for much flexibility in terms of
addressing modes or operand types.
One-address instructions
They can be slower to execute since they require operand fetching and addressing.
Two-address instructions
They require more memory space than one-address instructions and can be slower to execute since
they require operand fetching and addressing.
Three-address instructions
They require even more memory space than two-address instructions and can be slower to execute
since they require operand fetching and addressing.
Overall, the choice of instruction format depends on the specific requirements of the computer
architecture and the trade-offs between code size, execution time, and flexibility.
23
A computer consists of four main components namely, Input unit, Central Processing Unit (which is
made up of Memory unit, Arithmetic & logical unit, Control unit), secondary storage and an Output unit.
A. INPUT UNIT
Input units are used by the computer to read the data. The most commonly used input devices are
keyboards, mouse, joysticks, trackballs, microphones, etc.
However, the most well-known input device is a keyboard. Whenever a key is pressed, the
corresponding letter or digit is automatically translated into its corresponding binary code and
transmitted over a cable to either the memory or the processor.
The Memory unit can be referred to as the storage area in which programs are kept which are
running, and that contains data needed by the running programs. It enables a processor to access
running execution applications and services that are temporarily stored in a specific memory
location.
The memory is divided into large number of small parts called cells. Each location or cell has a
unique address, which varies from zero to memory size minus one. For example, if the computer
has 64k words, then this memory unit has 64 * 1024 = 65536 memory locations. The address of
these locations varies from 0 to 65535. The memory unit can be categorized into three namely,
cache, primary memory and secondary memory.
Cache memory
Cache memory is also a kind of memory which is used to fetch the data very fast. It is a very high-speed
semiconductor memory which can speed up the CPU. It acts as a buffer between the CPU and the main
memory. It is used to hold those parts of data and program which are most frequently used by the CPU.
The parts of data and programs are transferred from the disk to cache memory by the operating system,
from where the CPU can access them.
24
Characteristics
Cache memory is faster than main memory.
It consumes less access time as compared to main memory.
It stores programs that can be executed within a short period of time.
It stores data for temporary use.
Primary Memory
Primary storage is a volatile memory that holds only those data and instructions on which the computer
is currently working on. It contains a large number of semiconductor storage cells, capable of storing a
bit of information. The data and instruction required to be processed resides in the main memory.
Primary memory is divided into two: Random Access Memory (RAM) and Read Only Memory (ROM).
Characteristics
It has a limited capacity
It is generally made up of semiconductor devices
It is a volatile form of memory, means when the computer is shut down, anything contained in
RAM is lost.
These memories are not as fast as the cache.
25
o Dynamic RAM (DRAM)
DRAM, unlike SRAM must be continually refreshed in order to maintain the data. This is done by
placing the memory on a refresh circuit that rewrites the data several hundred times per second. DRAM
is used for most system memory as it is cheap and small. All DRAMs are made up of memory cells,
which are composed of one capacitor and one transistor.
The very first ROMs were hard-wired devices that contained a pre-programmed set of data or
instructions. This kind of ROMs are known as masked ROMs, which are inexpensive.
PROM is read-only memory that can be modified only once by a user. The user buys a blank PROM and
enters the desired contents using a PROM program. Inside the PROM chip, there are small fuses which
are burnt open during programming. It can be programmed only once and is not erasable.
EPROM can be erased by exposing it to ultra-violet light for a duration of up to 40 minutes. Usually, an
EPROM eraser achieves this function. During programming, an electrical charge is trapped in an
insulated gate region. The charge is retained for more than 10 years because the charge has no leakage
path. For erasing this charge, ultra-violet light is passed through a quartz crystal window (lid). This
exposure to ultra-violet light dissipates the charge during normal use, the quartz lid is sealed with a
sticker.
The ALU is where the CPU performs all the arithmetic and logic operations. Every task that a
computer carries out is completed here, e.g typing into a word processor involves adding binary
digits to the file and then calculating which pixels on the screen should change so that you can
see the characters. The ALU’s operations fall into two parts:
- Arithmetic operations like addition, subtraction, multiplication, division and
- Logical operations like AND, OR, NOT operations.
The control unit is a component of a computer's central processing unit that coordinates the operation of
the processor. It tells the computer's memory, arithmetic/logic unit and input and output devices how to
respond to a program's instructions. It is also known as the nerve center of a computer system.
C. SECONDARY MEMORY
This type of memory is also known as external memory. It is a non-volatile form of memory. It is slower
than the main memory. These are used for storing data/information permanently and on a long-term
basis. The CPU directly does not access these memories, instead they are accessed via input-output
routines. The contents of secondary memories are first transferred to the main memory and then the
CPU can access it. The most common examples of secondary memory are magnetic disks, magnetic
tapes, and optical disks.
27
D. OUTPUT UNIT
The primary function of the output unit is to send the processed results to the user. Output devices
display information in a way that the user can understand. They are pieces of equipment that are used to
generate information or any other response processed by the computer. The most common example of
an output device is a monitor. Others include the printer, plotter, speakers, etc.
Location: It deals with the location of the memory device in the computer system. There are three
possible locations:
CPU: This is often in the form of CPU registers and small amount of cache
Internal or main: This is the main memory like RAM or ROM. The CPU can directly access
the main memory.
28
External or Secondary: It comprises of secondary storage devices like hard disks, magnetic
tapes. The CPU does not access these devices directly. It uses device controllers to access
secondary storage devices.
Capacity: The capacity of any memory device is expressed in terms of word size and number of words
Word size: Words are expressed in bytes (8 bits) and a word can mean any number of bytes.
Commonly used word sizes are 1 byte (8 bits), 2 bytes (16 bits) and 4 bytes (32 bits).
Number of words: This specifies the number of words available in the particular memory
device. For example, if a memory device is given as 4K x 16. This means the device has a word
size of 16 bits and a total of 4096(4K) words in memory.
Unit of Transfer: It is the maximum number of bits that can be read or written into the memory at a
time. In case of main memory, it is mostly equal to word size. In case of external memory, unit of
transfer is not limited to the word size; it is often larger and is referred to as blocks.
Random Access: If storage locations in a particular memory device can be accessed in any order
and access time is independent of the memory location being accessed. Such memory devices are
said to have a random-access mechanism. RAM IC’s use this access method.
Serial Access: If memory locations can be accessed only in a certain predetermined sequence,
this access method is called serial access. Magnetic Tapes, CD-ROMs employs serial access
methods.
Semi Random Access: Memory devices such as magnetic hard disks use this access method
were each track has a read/write head thus each track can be accessed randomly but access
within each track is restricted to a serial access.
Performance: The performance of the memory system is determined using three parameters
Access Time: In random access memories, it is the time taken by memory to complete the
read/write operation from the instant that an address is sent to the memory. For non-random
29
access memories, it is the time taken to position the read write head at the desired location.
Access time is widely used to measure performance of memory devices.
Memory cycle time: It is defined only for Random Access Memories and is the sum of the
access time and the additional time required before the second access can commence.
Transfer rate: It is defined as the rate at which data can be transferred into or out of a memory
unit.
Physical type: Memory devices can be either semiconductor memory (like RAM) or magnetic surface
memory (like Hard disks).
Physical Characteristics: Volatile/Non- Volatile: If a memory device continues hold data even if
power is turned off then the memory device is non-volatile else it is volatile.
Organization: Erasable/Non-erasable: The memories in which data once programmed cannot be erased
are called Non-erasable memories. Memory devices in which data in the memory can be erased is called
erasable memory e.g. RAM (erasable), ROM (non-erasable)
MEMORY HIERARCHY
Memory is one of the important units in any computer system. It serves as a storage for all the
processed and the unprocessed data or programs in a computer system. However, due to the fact
that most computer users often stored large amount of files in their computer memory devices,
the use of one memory device in a computer system has become inefficient and unsatisfactory.
This is because only one memory cannot contain all the files needed by the computer users and
when the memory is large, it decreases the speed of the processor and the general performance
of the computer system.
Therefore, to curb this challenges, memory unit must be divided into smaller memories for more
storage, speedy program executions and the enhancement of the processor performance. The
recently accessed files or programs must be placed in the fastest memory since the memory with
large capacity is cheap and slow and the memory with smaller capacity is fast and costly. The
30
organization of smaller memories to hold the recently accessed files or programs closer to the
CPU is termed memory hierarchy. These memories are successively larger as they move away
from the CPU. The hierarchy system encompasses all the storage devices used in a computer
system. It ranges from the cache memory, which is smaller in size but faster in speed to a
relatively auxiliary memory which is larger in size but slower in speed. The smaller the size of
the memory the costlier it becomes.
The Computer memory hierarchy looks like a pyramid structure which is used to describe the
differences among memory types. It separates the computer storage based on hierarchy.
Level-1 − Cache
Cache memory is used to store the segments of a program that are frequently accessed by the processor.
It is expensive and the smallest in size, generally in Megabytes and is implemented by using
static RAM. It is very costly compared to the main memory and the auxiliary memory.
Level-2 − Primary or Main Memory
31
It directly communicates with the CPU and with auxiliary memory devices through an I/O
processor. Main memory is less expensive than cache memory and larger in size generally in Gigabytes.
This memory is implemented by using dynamic RAM. During program execution, the files that are not
currently needed by the CPU are often moved to the auxiliary storage devices in order to create space in
the main memory for the currently needed files to be stored. The main memory is made up of Random
Access Memory (RAM) and Read Only Memory (ROM).
Level-3 − Secondary storage
Secondary storage devices like Magnetic Disks are present at level 3. They are used as backup storage.
They are cheaper than both cache and main memory and larger in size generally in a few TB. They are
relatively slow in speed. They store programs that are not currently needed by the CPU.
In a system or computer, most of the tasks are controlled with the help of a processor or CPU (Central
processing unit), which is the main component of a computer. The CPU usually has two main
systems: control unit (CU) and arithmetic and logic unit (ALU). The control unit (CU) is used to
synchronize the tasks with the help of sending timings and control signals. On the other hand,
mathematical and logical operations can be handled with the help of ALU.
Two types of control unit are Micro programmed control units and hardwired control units. Instructions
are executed with the help of these two control units.
In the hardwired control unit, the execution of operations is much faster, but the implementation,
modification, and decoding are difficult. In contrast, implementing, modifying, decoding micro-
programmed control units is very easy. The micro-programmed control unit is also able to handle
complex instructions. With the help of control signals generated by micro-programmed and hardwired
control units, fetching and execution of instructions are done.
Control Signals
In order to generate the control signals, both the control signals were basically designed. The
functionality of a processor's hardware is operated with the help of these control signals. The control
signals are used to know about various types of things, which are described as follows:
32
o Control signals are used to know what operation is going to be performed.
o It is used to know about the sequence of operations that are performed by the processor.
o It is used to know about the timing at which an operation must be executed and many other types
of things.
With the help of generating control signals, the hardwired control unit is able to execute the instructions
at a correct time and proper sequence. As compared to the micro-programmed, the hardwired CU is
generally faster. In this CU, the control signals are generated with the help of PLA (programmable Logic
Array) circuit and state counter. Here the Central processing unit requires all these control signals. With
the help of hardware, the hardwired control signals are generated, and it basically uses the circuitry
approach.
The hardwired control unit contains various components in the form of circuitry which will be discussed
one by one so that we can properly understand the "generation of control signals". The components of
the hardwired CU are:
Instruction register
Instruction decoder
Step Counter
Clock
Condition Signals
External input
The Instruction Register is a type of processor register used to contain an instruction that is currently in
execution. The instruction register is used to generate the OP-code bits respective of the operation as
well as the addressing mode of operands.
The above generated Op-code bits are received in the field of an instruction decoder. The instruction
decoder interprets the operation and instruction's addressing mode. Now on the basis of the addressing
mode of instruction and operation which exists in the instruction register, the instruction decoder sets the
corresponding Instruction signal INSi to 1. Some steps are used to execute each instruction,
i.e., instruction fetch, decode, operand fetch, Arithmetic and logical unit, and memory store. In
general, these five steps are used to execute an instruction.
The information about the current step of instruction must be known by the control unit. The Step
Counter is implemented, which is used to contain the signals. For the step counter to know about the
33
current step of instruction, a Clock is implemented. The one-clock cycle of the clock will be completed
for each step.
When the execution in current step is completed, the Counter Enable will "disable" the Step Counter so
that it will stop, then increment to the next step signal.
The Condition Signals is used if the execution of instruction depends on some conditions. There are
various conditions in which the signals are generated with the help of control signals that can be less
than, greater than, less than equal, greater than equal, and many more.
The external input is the last one. It is used to tell the Control Signal Generator about the interrupts,
which will affect the execution of an instruction.
So, on the basis of the input obtained by the conditional signals, step counter, external inputs, and
instruction register, the control signals will be generated with the help of Control signal Generator.
A micro-programmed control unit can be described as a simple logic circuit, useful it in two ways, i.e., it
is able to execute each instruction with the help of generating control signals, and it is also able to do
sequencing through microinstructions. It will generate the control signals with the help of programs. The
program which is used to create the control signals is known as the "Micro-program". The micro-
program is placed on the processor chip, which is a type of fast memory. This memory is also known as
the control store or control memory.
A micro-program is used to contain a set of microinstructions (or control word) , each of which contains
different bit patterns. The n bit words are contained by each microinstruction. On the basis of the bit
pattern of a control word, every control signals differ from each other.
The instruction execution in a micro-programmed control unit is also performed in steps, as in the
hardwired CU. So for each step, the micro-program contains a control word/ microinstruction. To
execute a particular instruction, a sequence of microinstructions is needed. This process is known as the
micro-routine.
Instruction fetch is the first step. In this step, the instruction is fetched from the Instruction Register
(IR) with the help of a Microinstruction address register.
34
Decode is the second step. In this step, the instructions obtained from the instruction register will be
decoded with the help of a microinstruction address generator. Here, the starting address of a micro-
routine is obtained, which enables an easy performance of the operation, which is mentioned in the
instruction. It will also load the starting address into the micro-program counter.
Increment is the third step. In this step, the control word, which corresponds to the starting address of a
micro-program, will be read. When the execution proceeds, the value of the micro-program counter will
be increased so that it can read the successive control words of a micro-routine.
End bit is the fourth step. In this step, the microinstruction of a micro-routine contains a bit, which is
known as the end bit. The execution of the microinstruction will be successfully completed when the
end bit is set to 1.
This is the last step, and in this step, the micro-program address generator will again go back to Step
1 so that we can fetch a new instruction, and this process or cycle goes on.
So in the micro-programmed control unit, the micro-programs are stored with the help of Control
memory or Control store. The implementation of this CU is very easy and flexible, but it is slower as
compared to the Hardwired control unit.
Differences Between Hardwired and Microprogrammed Control Unit
35
Advantages of Hardwired Control Unit
The following are the advantages of Hardwired control unit:
REGISTERS
Registers are a type of computer memory used to quickly accept, store, and transfer data and
instructions that are being used immediately by the CPU. The registers used by the CPU are often
termed as processor registers. A processor register may hold an instruction, a storage address, or
any data (such as bit sequence or individual characters).
Some mostly used registers are Accumulator (AC), Program Counter (PC), Memory Address
Register (MAR), Memory Data Register (MDR) and Current Instruction Register (CIR).
i. Accumulator Register (AC): The accumulator register is located inside the ALU,
It is used during arithmetic & logical operations of ALU.
ii. Program Counter (PC): Program counter register is also known as Instruction
Pointer (IP) register. This register stores the address of the next instruction to be
fetched for execution. When the instruction is fetched, the value of IP is
incremented. Thus this register always points or holds the address of next
instruction to be fetched.
37
iii. Memory Address Register (MAR): This register holds the address of memory
where CPU wants to read or write data. When CPU wants to store some data in the
memory or reads the data from the memory, it places the address of the required
memory location in the MAR.
iv. Memory Data Register (MDR): MDR is the register of a control unit that contains
the data to be stored in the computer storage (e.g. RAM) or the data after a fetch
from the computer storage. It acts like a buffer and holds anything that is copied
from the memory ready for the processor to use it.
Instruction Register (CIR) is the part of a CPU's control unit that holds the
instruction currently being executed or decoded. In simple processors, each
instruction to be executed is loaded into the instruction register, which holds it while
it is decoded, prepared and ultimately executed.
Others include data register, address register, input and output registers, etc.
RISC
In the RISC architecture, the instruction set of the computer system is simplified to reduce the
execution time. It has a small set of instructions that generally includes register-to-register operations.
The RISC architecture uses comparatively a simple instruction format that is easy to decode. The
instruction length can be fixed and aligned to word boundaries. RISC processors can execute only one
instruction per clock cycle.
38
The following are some important characteristics of a RISC Processor −
RISC architectures are characterized by a small, simple instruction set and a highly efficient execution
pipeline. This allows RISC processors to execute instructions quickly, but it also means that they can
only perform a limited number of tasks.
CISC
The CISC architecture comprises a complex instruction set. A CISC processor has a variable-length
instruction format. In this processor architecture, the instructions that require register operands can take
only two bytes. In a CISC processor architecture, the instructions which require two memory addresses
can take five bytes to comprise the complete instruction code. Therefore, in a CISC processor, the
execution of instructions may take a varying number of clock cycles. The CISC processor also provides
direct manipulation of operands that are stored in the memory.
CISC architectures have a large, complex instruction set and a less efficient execution pipeline. This
allows CISC processors to perform a wider range of tasks, but they are not as fast as RISC processors
when executing instructions.
The important differences between RISC and CISC architectures are highlighted below:
39
S.No Attribute RISC CISC
.
Clock cycle These simple instructions This architecture has a set of special purpose
3. are executed in one clock circuits which help execute the instructions at
cycle. a high speed.
Ease of These chips are relatively These chips are complex to design.
4.
design simple to design.
Addressing Simple addressing formats The instructions interact with memory using
9.
format/mode are supported. complex addressing modes.
Fault tolerance refers to the property that enables the system to continue to function correctly even when
some of its components fail. In other words, fault tolerance means how an operating system (OS)
responds and allows hardware or software malfunctions and fails. The ability of OS to recover and
tolerate faults can be handled through software, hardware, or a combination solution that leverages load
balancers. Some computer systems use multiple duplicate fault tolerance systems to handle faults
gracefully, which is called a fault-tolerant network. Fault-tolerant systems use backup components that
automatically replace failed components to ensure that no break occurs in service.
LOGIC GATES
Logic gates are the main structural part of a digital system. They are a block of hardware that produces
signals of binary 1 or 0 when input logic requirements are satisfied. Each gate has a distinct graphic
symbol, and its operation can be described by means of algebraic expressions.
The seven basic logic gates includes: AND, OR, XOR, NOT, NAND, NOR, and XNOR. A truth table
can be used to represent the relationship between the input-output binary variables for each gate. This
can be done in a tabular form. Each gate has one or two binary input variables designated by A and B
and one binary output variable designated by x.
AND GATE:
The AND gate is an electronic circuit which gives a high output only if all its inputs are high. The AND
operation is represented by a dot (.) sign.
41
OR GATE:
The OR gate is an electronic circuit which gives a high output if one or more of its inputs are high. The
operation performed by an OR gate is represented by a plus (+) sign.
NOT GATE:
The NOT gate is an electronic circuit which produces an inverted version of the input at its output. It is
also known as an Inverter.
NAND GATE:
The NOT-AND (NAND) gate which is equal to an AND gate followed by a NOT gate. The NAND gate
gives a high output if any of the inputs are low. The NAND gate is represented by a AND gate with a
small circle on the output. The small circle represents inversion.
NOR GATE:
42
The NOT-OR (NOR) gate which is equal to an OR gate followed by a NOT gate. The NOR gate gives a
low output if any of the inputs are high. The NOR gate is represented by an OR gate with a small circle
on the output. The small circle represents inversion.
EXCLUSIVE-NOR/Equivalence GATE:
The 'Exclusive-NOR' gate is a circuit that does the inverse operation to the XOR gate. It will give a low
output if one of its inputs is high but not both of them. The small circle represents inversion.
Boolean algebra
Boolean algebra can be considered as an algebra that deals with binary variables and logic operations.
Boolean algebraic variables are designated by letters such as A, B, x, and y. The basic operations
performed are AND, OR, and complement.
43
The Boolean algebraic functions are mostly expressed with binary variables, logic operation symbols,
parentheses, and equal sign. For a given value of variables, the Boolean function can be either 1 or 0.
For instance, consider the Boolean function:
F = x + y'z
The logic diagram for the Boolean function F = x + y'z can be represented as:
The Boolean function F = x + y'z is transformed from an algebraic expression into a logic diagram
composed of AND, OR, and inverter gates.
A truth table can represent the relationship between a function and its binary variables. To
represent a function in a truth table, we need a list of the 2^n combinations of n binary variables.
The truth table for the Boolean function F = x + y'z can be represented as:
44
Examples of Boolean algebra simplifications
using logic gates
In this section, we will look at some of the examples of Boolean algebra
simplification using Logic gates.
1. F1 = xyz'
2. F2 = x + y'z
3. F3 = xy' + x'z
45
Truth tables for F1= xyz', F2= x+y'z, F3= xy'+x'z and F4= x'y'z+x'yz+xy'
x y z F1 F2 F3 F4
0 0 0 0 0 0 0
0 0 1 0 1 1 1
0 1 0 0 0 0 0
0 1 1 0 0 1 1
1 0 0 0 1 1 1
1 0 1 0 1 1 1
Map 1 1 0 1 1 0 0
1 1 1 0 1 0 0
Simplification
The Map method involves a simple, straightforward procedure for simplifying Boolean expressions.
Map simplification may be regarded as a pictorial arrangement of the truth table which allows an easy
interpretation for choosing the minimum number of terms needed to express the function algebraically.
The map method is also known as Karnaugh map or K-map.
46
Each combination of the variables in a truth table is called a min-term. When expressed in a truth
table a function of n variables will have 2^n min-terms, equivalent to the 2^n binary numbers
obtained from n bits.
There are four min-terms in a two variable map. Therefore, the map consists of four squares, one for
each min-term. The 0's and 1's marked for each row, and each column designates the values of variable
x and y, respectively.
Two-variable map:
There are eight min-terms in a three-variable map. Therefore, the map consists of eight squares.
47
o The map drawn in part (b) in the above image is marked with numbers in each row and each
column to show the relationship between the squares and the three variables.
o Any two adjacent squares in the map differ by only one variable, which is primed in one square
and unprimed in the other. For example, m5 and m7 lie in the two adjacent squares. Variable y is
primed in m5 and unprimed in m7, whereas the other two variables are the same in both the
squares.
o From the postulates of Boolean algebra, it follows that the sum of two min-terms in adjacent
squares can be simplified to a single AND term consisting of only two literals. For example,
consider the sum of two adjacent squares say m5 and m7:
m5+m7 = xy'z+xyz= xz(y'+y)= xz.
1. F(x,y,z) = Σ (2,3,4,5)
First, 1 is marked in each min-term that represents the function. Hence, 010, 011, 100, 101 are marked
with 1's.
Subsequently, we have to find possible adjacent squares. These are indicated in the map by two
rectangles, each enclosing two 1's.
48
The upper right rectangle represents the area enclosed by x'y. The lower left rectangle represents the
product term xy'.
F= x'y+ xy'
There are cases where two squares in the map are considered to be adjacent even though they do
not touch each other. In the figure below, m0 is adjacent to m2 and m4 is adjacent to m6 because
the min-terms differ by one variable.
Algebraically verification:
2. F(x,y,z) = Σ(3,4,6,7)
49
As you can see, there are four squares marked with 1's, one for each min-term of the function.
The other two adjacent squares are combined in the third column to give a two-literal term yz.
The remaining two squares with 1's are shown in the above diagram with their values enclosed in half
rectangles. When these two half rectangles are combined, it yields two literal term xz'.
50