You are on page 1of 100

Computer Architecture

Er. Hari K.C.


Asst. Professor
Soch College of IT
Tribhuvan University
harikc@wrc.edu.np

Soch college of IT - Hari K.C. 1


Syllabus of Computer Architecture
Course Title: Computer Architecture
Full Marks: 60 + 20 + 20
Semester: III

• This course includes concepts of instruction set architecture, organization


or micro-architecture, and system architecture. The instruction set
architecture includes programmer’s abstraction of computer. The micro-
architecture consist internal representation of computers at register and
functional unit level. The system architecture includes organization of
computers at the cache and bus level.

Soch college of IT - Hari K.C.


Unit 1: Data Representation (4 Hrs.)
1.1. Data Representation: Binary Representation, BCD, Alphanumeric
Representation,
Complements, Fixed Point representation, Representing Negative
Numbers, Floating Point Representation, Arithmetic with
Complements, Overflow, Detecting Overflow
1.2. Other Binary Codes: Gray Code, self Complementing Code,
Weighted Code, Excess-3 Code, EBCDIC
1.3. Error Detection Codes: Parity Bit, Odd Parity, Even parity, Parity
Generator & Checker

Soch college of IT - Hari K.C.


Unit 2: Register Transfer and Microoperations (5 Hrs.)
2.1. Microoperation, Register Transfer Language, Register Transfer,
Control Function
2.2. Arithmetic Microoperations: Binary Adder, Binary Adder-
subtractor, Binary Incrementer, Arithmetic Circuit
2.3. Logic Microoperations, Hardware Implementation, Applications of
Logic Microoperations.
2.4. Shift Microoperations: Logical Shift, Circular shift, Arithmetic Shift,
Hardware Implementation of Shifter.

Soch college of IT - Hari K.C.


Unit 3: Basic Computer Organization and Design (8 Hrs.)
3.1. Instruction Code, Operation Code, Stored Program Concept
3.2. Registers and memory of Basic Computer, Common Bus System for
Basic Computer.
3.3. Instruction Format, Instruction Set Completeness, Control Unit of
Basic Computer,Control Timing Signals
3.4. Instruction Cycle of Basic computer, Determining Type of
Instruction, Memory Reference Instructions, Input-Output Instructions,
Program Interrupt & Interrupt Cycle.
3.5. Description and Flowchart of Basic Computer

Soch college of IT - Hari K.C.


Unit 4: Microprogrammed Control (4 Hrs.)
4.1. Control Word, Microprogram, Control Memory, Control Address
Register,Sequencer
4.2. Address Sequencing, Conditional Branch, Mapping of Instructions,
Subroutines,Microinstruction Format, Symbolic Microinstructions
4.3. Design of Control Unit

Unit 5: Central Processing Unit (4 Hrs.)


5.1. Major Components of CPU, CPU Organization
5.2. Instruction Formats, Addressing Modes, Data Transfer and manipulation,
Program Control, Subroutine Call and Return, Types of Interrupt
5.3. RISC vs CISC, Pros and Cons of RISC and CISC, Overlapped Register
Windows
Soch college of IT - Hari K.C.
Unit 6: Pipelining (6 Hrs.)
6.1. Parallel Processing, Multiple Functional Units, Flynn’s Classification
6.2. Pipelining: Concept and Demonstration with Example, Speedup
Equation, Floating Point addition and Subtraction with Pipelining
6.3. Instruction Level Pipelining: Instruction Cycle, Three & Four-
Segment Instruction Pipeline, Pipeline Conflicts and Solutions
6.4. Vector Processing, Applications, Vector Operations, Matrix
Multiplication

Unit 7: Computer Arithmetic (6 Hrs.)


7.1. Addition and Subtraction with Signed Magnitude Data, Addition
and Subtraction with Signed 2’s Complement Data
7.2. Multiplication of Signed Magnitude Data, Booth Multiplication,
Division of Signed magnitude Data, Divide Overflow
Soch college of IT - Hari K.C.
Unit 8: Input Output Organization (4 Hrs.)
8.1. Input-Output Interface: I/O Bus and Interface Modules, I/O vs. Memory Bus,
Isolated vs. Memory-Mapped I/O
8.2. Asynchronous Data Transfer: Strobe, Handshaking
8.3. Modes of Transfer: Programmed I/O, Interrupt-Initiated I/O, Direct memory
Access
8.4. Priority Interrupt: Polling, Daisy-Chaining, Parallel Priority Interrupt
8.5. Direct Memory Access, Input-Output Processor, DMA vs. IOP

Unit 9: Memory Organization (4 Hrs.)


9.1 Memory Hierarchy, Main Memory, RAM and ROM Chips, Memory address Map,
Memory Connection to CPU, Auxiliary Memory (magnetic Disk, Magnetic Tape)
9.2 Associative Memory: Hardware Organization, Match Logic, Read Operation,
Write Operation
9.3 Cache Memory: Locality of Reference, Hit & Miss Ratio, Mapping, Write Policies
Soch college of IT - Hari K.C.
Lab and Practicals:
The laboratory work includes implementing and simulating the algorithms, studied in the
course,
by using high level languages like C or VHDL. The laboratory works should include at least
following concepts;
• Simulate features like overflow, data representation by using VHDL
• Simulate design of different units by using VHDL
• Simulate pipelining by using VHDL
• Implement algorithms for computer arithmetic using high level language like C or C++

Text Books:
1. M. Morris Mano, “Computer System Architecture”, Prentice-Hall of India, Pvt. Ltd.,Third
edition, 2007
References Books:
1. William Stallings, “Computer Organization and Architecture”, Prentice-Hall of India,Pvt.
Ltd., Seventh edition, 2005.
2. Vincent P. Heuring and Harry F. Jordan, “Computer System Design and Architecture”,
Prentice-Hall of India, Pvt. Ltd., Second edition, 2003.
Soch college of IT - Hari K.C.
Chapter 01: Data Representation
Number System
• Number of digits used in a number system is called its base or radix (r).
We can categorize number system as below:
- Binary number system (r = 2)
- Octal Number System (r = 8)
- Decimal Number System (r = 10)
- Hexadecimal Number system (r = 16)
• Digital computer is a digital system that perform various
computational tasks
• The word “digital” implies that information in computer is
represented by variables that take discrete values.
• For example: 0,1,2,3,4,5........,8,9 provide 10 discrete values.
• For example: 0,1 provide 2 discrete values
• It is easier to realize computing machine with a logic that has only
two states.
• True –False, 1 -0, high – low, on-off etc.
• Digital computers use binary number system which has two states: 0
and 1
• A binary digit is called a bit.
• Information is represented in digital computer using group of bits.
• Data representation refer to the internal method used to represent
various types of data stored in the digital computer.
• Computer used different types of codes to represent data such as
text, images, video and sound.
• 1 or 0 = bits
• 8 bits = 1 byte
• 2 or more bytes = 1 word
Data Types
• Registers and Main memory are the effective way to store the data in
the computers
• Data type refer to the size and types of data used in computer.
• It can be classified as :
a) Numbers= integers, decimal
b) Letters= A, F,
c) Discrete symbols: IV
They are used as needed for arithmetic computation, data processing
and other specific purposes.
Number systems
• Number system is the way to represent the numbers.
• A number system of base or radix , r is a system that uses distinct symbols
for r digits.
• Basically there are two types of number system
a) Non positional number system: It uses the limited number of symbols in
which each symbol has a value. Each symbol represent the same value
regardless of its position in the number. The roman number system is a
good example of a non-positional number system.
b) Positional number system: A positional (numeral) system is a system for
representation of numbers by an ordered set of numerals symbols
(called digits) . The value of a numeral symbol depends on its position.
For each position a unique symbol or a limited set of symbols is used.
Number system used in Computers
• Binary Number system ( 0,1)

• Decimal Number system ( 0,1,2,3,4,5,6,7,8,9)

• Octal Number system ( 0,1,2,3,4,5,6,7)

• Hexadecimal Number system (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)


Binary Number system
• The number system represented by combination of two digit 1 and 0.
• Its base or radix is 2, r=2. Example = (101011)2
• Binary number system is a positional number system where each digit
has a value expressed in powers of 2.
Decimal Number system
• The number system represented by combination of ten digit from 0 – 9.
• The base or radix of decimal number system is 10. r= 10
• Example= (4519)10
• It is also a positional number system. Each position of digit represent
the specific power of base 10.
• The weightage of each position can be represented for 6 digit as:
Octal Number system
• The number system represented by combination of 8 digit from 0 – 7.
• The base or radix of octal number system is 8. i.e r=8
• Example: (761)8
• Each position of a digit represent a specific power of base 8.
• The weightage of each position can be represented for 6 digit as:
Hexadecimal number system
• The number system represented by combination of 16 digit from 0 –
9 and A-F.
• The base or radix of hexadecimal number system is 16. i.e r=16
• Example: (2DA)16
• Each position of a digit represent a specific power of base 16.
• The weightage of each position can be represented for 6 digit as:
Conversion from Binary Number system to
other number system
• Binary to decimal number system
(11010)2
= 1×24 + 1×23 + 0×22 + 1×21 + 0×20
= 16 + 8 + 0 + 2 + 0
= 2610

(11010.011)2
=1×24 + 1×23 + 0×22 + 1×21 + 0×20 + 0 x 2-1 + 1x 2-2 + 1x 2-3
= 16 + 8 + 0 + 2 + 0 + 0 + 0.25 + 0.125
=26 + 0.375
=26.37510
• Binary to Octal conversion
Convert binary number (10010110)2 into octal number.
(10010110)2 = ( ?)8
1) (10010110)2 = ( ?)8

= 010 010 110


=226
= (226)8

2) (10010110. 11010)2 = ( ?)8

= 010 010 110 . 101 100


= 2 2 6. 54
= (226.54)8
Binary to Hexadecimal number
• Convert (1101111101)2 to hexadecimal number

= 11 0111 1101
= 0011 0111 1101
= (3 7 D )16

• Convert (1101111101. 110) 2 to hexadecimal.


= (0011 0111 1101 . 1100)
= (3 7 D. C)16
Decimal to other number system
• Decimal to binary number system
In decimal to binary conversion, we convert a base 10 number to base 2 number by using simple methods. For example, if
1210 is a decimal number then its equivalent binary number is 11002.
To convert decimal to binary numbers, proceed the steps given below:
• Divide the given decimal number by “2” where it gives the result along with the remainder.
• If the given decimal number is even, then the result will be whole and it gives the remainder “0”
• If the given decimal number is odd, then the result is not divided properly and it gives the remainder “1”.
• By placing all the remainders in order in such a way, the Least Significant Bit (LSB) at the top and Most Significant Bit (MSB) at the bottom,
the required binary number will obtain.

Convert (294) 10 to ( ?) 2

Þ29410
Þ1001001102
• Convert ( 4.47)10 to ( ?) 2
Decimal to octal number system
Follow the steps given below to learn the decimal to octal conversion:
• Write the given decimal number
• If the given decimal number is less than 8 the octal number is the same.
• If the decimal number is greater than 7 then divide the number by 8.
• Note the remainder we get after division
• Repeat step 3 and 4 with the quotient till it is less than 8
• Now, write the remainders in reverse order(bottom to top)
• The resultant is the equivalent octal number to the given decimal number.
• Convert (1792)10 to ( ? )8

= (3400)8
• Exercise 1: Convert (127.56)10 to Octal.
• Exercise 2: Convert 5210 to octal.
• Exercise 3: Convert 10010 to octal.
Decimal to Hexadecimal Number system
Conversion steps:
• Divide the number by 16.
• Get the integer quotient for the next iteration.
• Get the remainder for the hex digit.
• Repeat the steps until the quotient is equal to 0.
Convert (7562)10 to Hexadecimal:

756210 = 1D8A16
Convert 3563110 to hexadecimal

3563110 = 8B2F16
Octal to other number system conversion
1) Octal to Binary number conversion
There are various direct or indirect methods to convert a octal number
into binary number.
In an indirect method, you need to convert an octal number into other
number system (e.g., decimal or hexadecimal), then you can convert
into binary number by converting each digit into binary number from
hexadecimal system and using conversion system from decimal to
binary number.
Convert octal number 205 into binary
number.

= 133
• There is a simple direct method to convert an octal number to binary
number. Since there are only 8 symbols (i.e., 0, 1, 2, 3, 4, 5, 6, and 7)
in octal representation system and its base (i.e., 8) is equivalent of
23=8.
• So, you can represent each digit of octal in group of 3 bits in binary
number.

• Take Octal number as input


• Convert each digit of octal into binary.
• That will be output as binary number.
• Convert octal number 205 into binary number.
= (205)8
= (010 000 101)2
= (10000101)2

• Convert octal number 352.563 into binary number.


= (352.563)8
= (011 101 010 . 101 110 011)2
= (011101010.101110011)2
Convert octal number to hexadecimal number
• Convert (532) 8 to ( ? )16

5 à 101
3 à 011
2 à 010

(101 011 010 )2


Now select 4 bits
(1 0101 1010 )
= 0001 0101 1010
=(1 5 A )16
Codes used in Computers
• Code are the symbols and numbers used in computers. Basically, they
are used in traditional computers and digital devices.

Types of codes
• BCD codes
• XS3 codes
• Gray codes
• ASCII codes
BCD codes
• Binary Coded Decimal or BCD is simply the 4-bit binary code
representation of a decimal digit with each decimal digit replaced in
the integer and fractional parts with its binary equivalent.
• BCD Code uses four bits to represent the 10 decimal digits of 0 to 9.
• Standard binary coded decimal code is commonly known as a
weighted 8421 BCD code, with 8, 4, 2 and 1 representing the weights
of the different bits starting from the most significant bit (MSB) and
proceeding towards the least significant bit (LSB).
• The weights of the individual positions of the bits of a BCD code
are: 23 = 8, 22 = 4, 21 = 2, 20 = 1.
• But do not get confused, binary coded decimal is not the same as hexadecimal.
• The most common BCD code is the 8421 BCD code.
• Here 8, 4, 2 and 1 represent the weights of different bits in the four-bit groups, starting from the
(MSB) most significant bit (to extreme left) and proceeding towards the least significant (LSB) bit.
• The 4221 BCD and 5421 BCD are other weighted BCD codes shown in table. The numbers 4, 2, 2, 1
in 4221 BCD and 5, 4, 2 and 1 in 5421 BCD represent weights of the relevant bits.
• Now let us consider some examples, where we convert the given
decimal numbers to BCD.
• The 8421 BCD code for 9.2 is 1001.0010.

• The 4221 BCD code for 9.2 is 1111.0010.


• The 5421 BCD code for 9.2 is 1100.0010.
• BCD code is useful for outputting to displays that are always numeric
(0 to 9), such as those found in digital clocks or digital voltmeters.
XS3 codes (Excess 3 code)
• The excess – 3 code of a decimal number is achieved by adding the number 3 to a decimal number.
• For example to convert 15 to an excess-3 code, first 3 to be added to each digit as shown below:
Find the excess-3 code of (237.75)10
=> Sol:
1) The excess-3 code for (237)10 is obtained by adding 3 to all the digits
individually, that is 2, 3 and 7 will become 5, 6 and 10 respectively.
These 5, 6 and 10 decimals have to be converted into binary form and
the result is 0101 0110 1010.
The excess-3 code for (.75)10 is obtained by replacing 7 and 5 with 10
and 8 respectively by adding 3 to each digit. That is, the excess-3 code
for (.75) ₁₀ is.10101000.
Combining the results of the integral and fractional parts, the excess-3
code for (237.75)₁₀ is 010101101010.10101000
GRAY CODE
• The gray code is the code where one bit will be differed to the
preceding number.
• For example, decimal numbers 13 and 14 are represented by gray
code numbers 1011 and 1001, these numbers differ only in single
position that is the second position from the right.
• In the same way first position on the left changes for 7 and 8 which
are 0100 and 1100 and this is also called Unit-distance code.
• The gray code has very special place in digital electronics. Gray codes
are used in rotary and optical encoders, Karnaugh maps, and error
detection.
• The Gray Code is a sequence of binary number systems, which is also
known as reflected binary code.
Generation for gray code:
• Find the number of bits required to represent a number.
• Next, we find the code for 0, i.e., 0000, which is the same as binary.
• Now, we take the previous code, i.e., 0000, and change the most
significant bit of it.
• We perform this process reclusively until all the codes are not
uniquely identified.
• If by changing the most significant bit, we find the same code
obtained previously, then the second most significant bit will be
changed, and so on.
Binary code to Gray code Conversion
1) ( 01001)2 = (? ) graycode
Solution: 0+1+0+0+1
0 1 1 0 1

=( 0 1 1 0 1) graycode
Gray code to Binary conversion
1) ( 01101)gray = (? ) 2
Solution: 0 1 1 0 1
0 1 0 0 1

=( 0 1 0 0 1) 2
ASCII code
• ASCII, stands for American Standard Code for Information
Interchange.
• It's a 7-bit character code where every single bit represents a unique
character.
• Text files stored in ASCII format are sometimes called ASCII files.
• Text editors and word processors are usually capable of storing data
in ASCII format, although ASCII format is not always
the default storage format.
• Most data files, particularly if they contain numeric data, are not
stored in ASCII format. Executable programs are never stored in ASCII
format.
• It is a code for representing 128 English characters as numbers, with
each letter assigned a number from 0 to 127.
• For example, the ASCII code for uppercase M is 77.
Most computers use ASCII codes to represent text, which makes it
possible to transfer data from one computer to another.
Complements
• Complements are used in the digital computers in order to simplify
the subtraction operation and for the logical manipulations.
• For each radix-r system (radix r represents base of number system)
there are two types of complements.
S.N. Complement Description
1 Radix Complement The radix complement is
referred to as the r's
complement
2 Diminished Radix The diminished radix
Complement complement is referred to
as the (r-1)'s complement
Binary system complements

• 1's complement
• The 1's complement of a number is found by changing all 1's to 0's
and all 0's to 1’s.
• This is called as taking complement or 1's complement. Example of 1's
Complement is as follows:
2's complement

• The 2's complement of binary number is obtained by adding 1 to the


Least Significant Bit (LSB) of 1's complement of the number.
• 2's complement = 1's complement + 1
• Example of 2's Complement is as follows:
Binary Addition

• It is a key for binary subtraction, multiplication, division. There are


four rules of binary addition.
Binary Subtraction
• Subtraction and Borrow, these two words will be used very
frequently for the binary subtraction.
• There are four rules of binary subtraction.
Binary Multiplication
Binary Division

• Binary division is similar to decimal division.


• It is called as the long division procedure.
1’s Complement Subtraction
• In subtraction by 1’s complement we subtract two binary numbers
using carried by 1’s complement.
• The steps to be followed in subtraction by 1’s complement are:
i) write down 1’s complement of the subtrahend.
ii) add this with the minuend.
iii) If the result of addition has a carry over then it is dropped and an 1
is added in the last bit.
iv) If there is no carry over, then 1’s complement of the result of
addition is obtained to get the final result and it is negative.
Evaluate:
110101 – 100101

100101
101011 – 111001
Solution:
1’s complement of 111001 is 000110. Hence
Minued - 101011
1’s complement - 000110
110001

• Hence the difference is – 1 1 1 0


1011.001 – 110.10
Solution:
1’s complement of 0110.100 is 1001.011 Hence
Minued - 1011.001
1’s complement of subtrahend - 1001.011
Carry over - 1 0100.100
1
0100.101

Hence the required difference is 100.101


Subtraction by 2’s Complement
• With the help of subtraction by 2’s complement method we can easily
subtract two binary numbers.
• 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.
Evaluate:

(i) 110110 - 10110


Solution:
The numbers of bits in the subtrahend is 5 while that of minuend is 6. We make the
number of bits in the subtrahend equal to that of minuend by taking a `0’ in the sixth place
of the subtrahend.
Now, 2’s complement of 010110 is (101101 + 1) i.e.101010. Adding this with the minuend.

1 10110 Minuend
1 01010 2’s complement of subtrahend
Carry over 1 1 00000 Result of addition

After dropping the carry over we get the result of subtraction to be 100000.
10110 – 11010
Solution:
2’s complement of 11010 is (00101 + 1) i.e. 00110. Hence
Minued - 10110
2’s complement of subtrahend - 00110
Result of addition - 11100

As there is no carry over, the result of subtraction is negative and is


obtained by writing the 2’s complement of 11100 i.e.(00011 + 1) or
00100.
Hence the difference is – 100.
1010.11 – 1001.01
Solution:
2’s complement of 1001.01 is 0110.11. Hence
Minued - 1010.11

2’s complement of subtrahend - 0110.11

Carry over 1 0001.10

After dropping the carry over we get the result of subtraction as 1.10.
9’s Complement and 10’s Complement
• The complements are used to make the
arithmetic operations in digital system
easier.
• To obtain the 9’s complement of any
number we have to subtract the number
with (10n – 1) where n = number of
digits in the number.
• i.e (10n -1 – N)
where N is the Number
• It is relatively easy to find out the 10’s complement after finding out
the 9’s complement of that number.
• We have to add 1 with the 9’s complement of any number to obtain
the desired 10’s complement of that number.
• Let us take a decimal number 456, 9’s complement of this number
will be:

• 10’s complement of this number is:


Subtraction using 9’s
9’s complement subtraction
èLet A = 215, B = 155
First we have to find out 9’s complement of B

Now we have to add 9’s complement of B to A


• The left most bit of the result is called carry and is added back to the
part of the result without it.

• The result is 60.


• Another example is given as:
A = 4567
B = 1234

• We need to find out A – B


9’s complement of B
=8765

• Adding 9’s complement of B with A


• Adding the carry with the result we get
= 3333
Now the answer is 3333

Note: If there is no carry the answer will be


= – (9’s complement of the answer)
Subtraction by 10’s complement
Again, we will show the procedure by an example:
Taking the same data,
A = 215
B = 155
10’s complement of B = 845
Adding 10’s complement of B to A

In this case the carry is omitted


The answer is 60.
Taking the other example
A = 4567
B = 1234
10’s complement of B = 8766
Adding 10’s complement of B with A

To get the answer the carry is ignored

So, the answer is 3333


Representation of Binary Numbers
èBinary numbers can be represented in signed and unsigned way.
è Unsigned binary numbers do not have sign bit, whereas signed
binary numbers uses signed bit as well or these can be distinguishable
between positive and negative numbers.
è A signed binary is a specific data type of a signed variable.
Unsigned Numbers
• Unsigned numbers don’t have any sign, these can contain only
magnitude of the number.
• For example, representation of positive decimal numbers are positive
by default.
• We always assume that there is a positive sign symbol in front of
every number.
Represent decimal number 92 in unsigned binary
number.
Simply convert it into Binary number, it contains only magnitude of the
given number.
= (92)10
= (1x26+0x25+1x24+1x23+1x22+0x21+0x20)10
= (1011100)2
It’s 7 bit binary magnitude of the decimal number 92.
+92
Representation of Signed Binary Numbers
• There are three types of representations for signed binary numbers.
• Because of extra signed bit, binary number zero has two
representation, either positive (0) or negative (1), so ambiguous
representation.
• These are:
• Sign-Magnitude form,
• 1’s complement form,
• and 2’s complement form.
Sign-Magnitude form
• For n bit binary number, 1 bit is reserved for sign symbol.
• If the value of sign bit is 0, then the given number will be positive,
else if the value of sign bit is 1, then the given number will be
negative.
• Remaining (n-1) bits represent magnitude of the number.

• Example: 1 110
=-6
1’s complement form

• Since, 1’s complement of a number is obtained by inverting each bit of


given number.
• So, we represent positive numbers in binary form and negative numbers in
1’s complement form.
• There is extra bit for sign representation.
• If value of sign bit is 0, then number is positive and you can directly
represent it in simple binary form, but if value of sign bit 1, then number is
negative and you have to take 1’s complement of given binary number.
• You can get negative number by 1’s complement of a positive number and
positive number by using 1’s complement of a negative number.
2’s complement form
• Since, 2’s complement of a number is obtained by inverting each bit of
given number plus 1 to least significant bit (LSB).
• So, we represent positive numbers in binary form and negative numbers in
2’s complement form.
• There is extra bit for sign representation. If value of sign bit is 0, then
number is positive and you can directly represent it in simple binary form,
but if value of sign bit 1, then number is negative and you have to take 2’s
complement of given binary number.
• You can get negative number by 2’s complement of a positive number and
positive number by directly using simple binary representation.
• If value of most significant bit (MSB) is 1, then take 2’s complement from,
else not.
Assignments
• Convert 1268 to decimal.
• Convert 11012 to decimal.
• Convert B2D16 to decimal.
• +4510 in signed binary
• - 4510 in signed binary
• 10 -17 using 10’s complement subtraction
• 10 – 17 using 9’s complement subtraction
• 6523110 to BCD8421
Error Detection codes
• For reliable transmission and storage of digital data, error detection and
correction is required.
• Examples of codes which permit error detection and error correction are:
Parity Codes, Hamming Code, etc.
• Error means a condition when output information is not same as input
information.
• When transmission of digital signals takes place between two systems such
as a computer, the transmitted signal is combined with the "Noise". The
noise can introduce an error in the binary bits travelling from one system
to other.
• That means 0 may change to 1 or a 1 may change to 0.
Error Detecting Codes
• Whenever a message is transmitted then there are changes that it get scrambled by noise or
data gets corrupted.
• When we add some additional data to a given digital message which can help us
to detect if an error occurred during transmission of the message then adding such data is
called an error-detecting code.
• A simple example of error-detecting code is parity check.
Error Correcting Codes
• Along with Error detecting code, we can also pass some data which
help to figure out the original message from the corrupt message that
we received.
• This type of code is called an error-correcting code.
• Error correcting codes also deploys the same strategy as error
detecting codes but additionally, such codes also detects the exact
location of corrupt bit.
• In error correcting code, parity check has simple way to detect error
along with a sophisticated mechanism to determine the corrupt bit
location.
• Once corrupt bit is located, its value is reverted (from 0 to 1 or
1 to 0) to get the original message.
How to detect and correct errors?
• For the detection and correction of these errors, one or more than
one extra bits are added to the data bits at the time transmitting.
These extra bits are called as parity bits.
• They allow detection or correction of the errors. The data bits along
with the parity bits form a code word.
• Binary information may be transmitted through some communication
medium, e.g. using wires or wireless media. A corrupted bit will have
its value changed from 0 to 1 or vice versa.
• To be able to detect errors at the receiver end, the sender sends an
extra bit (parity bit) with the original binary message.
A parity bit is an extra bit included with the n-bit binary message to make the
total number of 1’s in this message (including the parity bit) either odd or even.
If the parity bit makes the total number of 1’s an odd (even) number, it is called
odd (even) parity.
• The table shows the required odd (even) parity for a 3-bit message.
• At the receiver end, an error is detected if the message does not match
have the proper parity(odd/even).
• Parity bits can detect the occurrence 1, 3, 5 or any odd number of errors in
the transmitted message.
• No error is detectable if the transmitted message has 2 bits in error since
the total number of 1’s will remain even (or odd) as in the original
message.
• In general, a transmitted message with even number of errors cannot be
detected by the parity bit.
• Binary information may be transmitted through some communication
medium, e.g. using wires or wireless media.
• Noise in the transmission medium may cause the transmitted binary
message to be corrupted by changing a bit from 0 to 1 or vice versa.
• To be able to detect errors at the receiver end, the sender sends an extra
bit (parity bit).
Parity Generator
• Parity generator and checker networks are logic circuits constructed
with exclusive-OR functions.
• Consider a 3-bit message to be transmitted with an odd parity bit. At
the sending end, the odd parity is generated by a parity generator
circuit.
• The output of the parity checker would be 1 when an error occurs i.e.
no. of 1’s in the four inputs is even.
x/yz Y’Z’ Y’Z YZ YZ’
X’ 1 1
X 1 1

P = X’Y’Z’ + XY’Z + X’YZ + XYZ’


P = X xor Y xor Z
P = x⊕y⊕z
px y z Error (e) Remarks
0 0 0 0 1 errror
Parity checker 0 0 0 1 0 No error
0 0 1 0 0 No error
0 0 1 1 1 error
0 1 0 0 0 No error
0 1 0 1 1 error
0 1 1 0 1 error
0 1 1 1 0 No error
1 0 0 0 0 No error
1 0 0 1 1 error
1 0 1 0 1 error
1 0 1 1 0 No error
1 1 0 0 1 error
1 1 0 1 0 No error
1 1 1 0 0 No error
1 1 1 1 1 error
Px/yz y’z’ Y’z Yz Yz’
P’x’ 1 1
P’x 1 1
Px 1 1
Px’ 1 1

e =p’x’y’z’ + p’x’yz + p’xy’z + p’xyz’ + pxy’z’ + pxyz + px’y’z + px’yz’

e= P xor x xor y xor y xor z

e = (p⊕x⊕y⊕z )’

You might also like