0% found this document useful (0 votes)
0 views

C programming

The document outlines the syllabus for the CS1CMT01 Fundamentals of Digital Systems course at MG University, covering topics such as number systems, logic gates, Boolean algebra, combinational and sequential circuits. It details various number systems including decimal, binary, octal, and hexadecimal, along with their conversions and arithmetic operations. Additionally, it provides a structured approach to understanding digital logic through modules focused on logic gates, Boolean simplifications, and circuit design.

Uploaded by

rj7achuzzz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

C programming

The document outlines the syllabus for the CS1CMT01 Fundamentals of Digital Systems course at MG University, covering topics such as number systems, logic gates, Boolean algebra, combinational and sequential circuits. It details various number systems including decimal, binary, octal, and hexadecimal, along with their conversions and arithmetic operations. Additionally, it provides a structured approach to understanding digital logic through modules focused on logic gates, Boolean simplifications, and circuit design.

Uploaded by

rj7achuzzz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

- 1 -

CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Fundamentals of Digital Systems


CS1CMT01
(Complementary)

Module I: Number Systems, Operations and Codes


Decimal Numbers, Binary Numbers, Decimal to Binary
Conversion, Binary Arithmetic, 1’s and 2’s complement of binary
numbers, Signed numbers, Arithmetic operations with signed
numbers, Hexadecimal numbers, Binary to hexadecimal
conversion, Hexadecimal to binary conversion, Hexadecimal to
decimal conversion, Decimal to Hexadecimal conversion,
Hexadecimal addition and subtraction, Octal numbers, Octal to
decimal conversion, Decimal to Octal conversion, Octal to binary
conversion, Binary to Octal conversion, Binary coded decimal,
8421 BCD code, BCD addition, Digital codes- gray code, binary
to gray code conversion, Alphanumeric codes, parity codes.

Module II: Logic Gates, Logic Levels and Waveforms


Logic Levels and Digital waveforms, Logic Gates: AND, OR, NOT,
XOR, XNOR, NAND (Definition, Symbols, Truth Tables and
Operation). Universal Property of NAND and NOR gates. Logic
gate operations with pulse waveforms.

Module III: Boolean Algebra and Logic Simplifications.


Boolean operations and expressions, Laws and rules of Boolean
algebra, De-Morgan’s theorems, Boolean analysis of logic
circuits, simplification using Boolean algebra, standard forms of
Boolean expression, Boolean expressions and truth tables. The
Karnaugh Map, Karnaugh SOP minimization, Karnaugh POS
minimization, five variable Karnaugh maps.

Module IV: Combinational Logic and its functions.


Basic combinational Logic circuits, Implementing
combinational logic, combinational logic using NAND and NOR
gates, Basic overview of logic functions, Basic adders, parallel
binary adders, comparators, decoders, encoders, code
converters, multiplexers, DE multiplexers, parity generators/
checkers.
Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]
- 2 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Module V: Sequential Circuits.


Latches, RS flip flop using NAND/ NOR gates, Clocked RS, D, JK
and T flip flops, Edge triggered flip flops, Master slave flip flops,
Asynchronous counter operation, Synchronous counter
operations, Up/ Down Synchronous counter, Design of
synchronous counters. Basic shift register functions. Serial in-
Parallel out shift registers, Parallel in -Serial out shift registers,
Serial in- Serial out shift registers, Parallel in Parallel out shift
registers.

Book of Study:
1. Floyd and Jain- Digital Fundamentals, Eighth Edition,
Pearson Education

Reference:
1. A P Malvino and D P Leach - Digital Principles and
Applications, Fourth edition, Tata McGraw Hill Publishers,
co Ltd.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 3 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Module I

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 4 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Number Systems, Operations and Codes


If base or radix of a number system is ‘r’, then the numbers
present in that number system are ranging from zero to r-1. The
total numbers present in that number system is ‘r’. So, we will
get various number systems, by choosing the values of radix as
greater than or equal to two.

Let us discuss about the popular number systems and how to


represent a number in the respective number system. The
following number systems are the most commonly used.
 Decimal Number system
 Binary Number system
 Octal Number system
 Hexadecimal Number system

Decimal Number System


The base or radix of Decimal number system is 10. So, the
numbers ranging from 0 to 9 are used in this number system.
The part of the number that lies to the left of the decimal point
is known as integer part.

Similarly, the part of the number that lies to the right of the
decimal point is known as fractional part.

In this number system, the successive positions to the left of the


decimal point having weights of 100, 101, 102, 103 and so on.

Similarly, the successive positions to the right of the decimal


point having weights of 10-1, 10-2, 10-3 and so on. That means,
each position has specific weight, which is power of base 10

Example
Consider the decimal number 1358.246. Integer part of this
number is 1358 and fractional part of this number is 0.246.

The digits 8, 5, 3 and 1 have weights of 100, 101, 102 and 103
respectively.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 5 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Similarly, the digits 2, 4 and 6 have weights of 10-1, 10-2 and


10-3 respectively.

Mathematically, we can write it as


1358.246 = (1 × 103) + (3 × 102) + (5 × 101) + (8 × 100) +
(2 × 10-1) + (4 × 10-2) + (6 × 10-3)

After simplifying the right hand side terms, we will get the
decimal number, which is on left hand side.

Binary Number System


All digital circuits and systems use this binary number system.
The base or radix of this number system is 2. So, the numbers
0 and 1 are used in this number system.

The part of the number, which lies to the left of the binary point
is known as integer part. Similarly, the part of the number,
which lies to the right of the binary point is known as fractional
part.

In this number system, the successive positions to the left of the


binary point having weights of 20, 21, 22, 23 and so on. Similarly,
the successive positions to the right of the binary point having
weights of 2-1, 2-2, 2-3 and so on.

That means, each position has specific weight, which is power


of base 2.

Example
Consider the binary number 1101.011. Integer part of this
number is 1101 and fractional part of this number is 0.011. The
digits 1, 0, 1 and 1 of integer part have weights of 20, 21, 22, 23
respectively. Similarly, the digits 0, 1 and 1 of fractional part
have weights of 2-1, 2-2, 2-3 respectively.

Mathematically, we can write it as


1101.011 = (1 × 23) + (1 × 22) + (0 × 21) + (1 × 20) + (0 × 2-1) +
(1 × 2-2) + (1 × 2-3)
Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]
- 6 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

After simplifying the right hand side terms, we will get a decimal
number, which is an equivalent of binary number on left hand
side.

Octal Number System


The base or radix of octal number system is 8. So, the numbers
ranging from 0 to 7 are used in this number system. The part of
the number that lies to the left of the octal point is known as
integer part. Similarly, the part of the number that lies to the
right of the octal point is known as fractional part.

In this number system, the successive positions to the left of the


octal point having weights of 80, 81, 82, 83 and so on. Similarly,
the successive positions to the right of the octal point having
weights of 8-1, 8-2, 8-3 and so on. That means, each position has
specific weight, which is power of base 8.

Example
Consider the octal number 1457.236. Integer part of this
number is 1457 and fractional part of this number is 0.236. The
digits 7, 5, 4 and 1 have weights of 80, 81, 82 and 83 respectively.
Similarly, the digits 2, 3 and 6 have weights of 8-1, 8-2, 8-3
respectively.

Mathematically, we can write it as


1457.236 = (1 × 83) + (4 × 82) + (5 × 81) + (7 × 80) + (2 × 8-1) +
(3 × 8-2) + (6 × 8-3)

After simplifying the right hand side terms, we will get a decimal
number, which is an equivalent of octal number on left hand
side.

Hexadecimal Number System


The base or radix of Hexa-decimal number system is 16. So, the
numbers ranging from 0 to 9 and the letters from A to F are used
in this number system. The decimal equivalent of Hexa-decimal
digits from A to F are 10 to 15.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 7 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

The part of the number, which lies to the left of the hexadecimal
point is known as integer part. Similarly, the part of the
number, which lies to the right of the Hexa-decimal point is
known as fractional part.

In this number system, the successive positions to the left of the


Hexa-decimal point having weights of 160, 161, 162, 163 and so
on. Similarly, the successive positions to the right of the Hexa-
decimal point having weights of 16-1, 16-2, 16-3 and so on. That
means, each position has specific weight, which is power of
base 16.

Example
Consider the Hexa-decimal number 1A05.2C4. Integer part of
this number is 1A05 and fractional part of this number is 0.2C4.
The digits 5, 0, A and 1 have weights of 160, 161, 162 and 163
respectively. Similarly, the digits 2, C and 4 have weights of
16-1, 16-2 and 16-3 respectively.

Mathematically, we can write it as


1A05.2C4 = (1 × 163) + (10 × 162) + (0 × 161) + (5 × 160) +
(2 × 16-1) + (12 × 16-2) + (4 × 16-3)
After simplifying the right hand side terms, we will get a decimal
number, which is an equivalent of Hexa-decimal number on left
hand side.

Base Conversions
We have seen the four prominent number systems. Let us
convert the numbers from one number system to the other in
order to find the equivalent value.

Decimal Number to other Bases Conversion


If the decimal number contains both integer part and fractional
part, then convert both the parts of decimal number into other
base individually. Follow these steps for converting the decimal
number into its equivalent number of any base ‘r’.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 8 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

 Do division of integer part of decimal number and


successive quotients with base ‘r’ and note down the
remainders till the quotient is zero. Consider the remainders
in reverse order to get the integer part of equivalent number
of base ‘r’. That means, first and last remainders denote the
least significant digit and most significant digit respectively.

 Do multiplication of fractional part of decimal number and


successive fractions with base ‘r’ and note down the carry
till the result is zero or the desired number of equivalent
digits is obtained. Consider the normal sequence of carry in
order to get the fractional part of equivalent number of base
‘r’.

Decimal to Binary Conversion


The following two types of operations take place, while
converting decimal number into its equivalent binary number.
 Division of integer part and successive quotients with base
2.
 Multiplication of fractional part and successive fractions
with base 2.

Example
Consider the decimal number 58.25. Here, the integer part is
58 and fractional part is 0.25.

Step 1 − Division of 58 and successive quotients with base 2.


Operation Quotient Remainder
58/2 29 0 (LSB)
29/2 14 1
14/2 7 0
7/2 3 1
3/2 1 1
1/2 0 1(MSB)
⇒ (58)10 = (111010)2.

Therefore, the integer part of equivalent binary number is


111010.
Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]
- 9 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Step 2 − Multiplication of 0.25 and successive fractions with


base 2.
Operation Result Carry
0.25 x 2 0.5 0
0.5 x 2 1.0 1
- 0.0 -
⇒ (.25)10 = (.01)2

Therefore, the fractional part of equivalent binary number is


.01

⇒ (58.25)10 = (111010.01)2

Therefore, the binary equivalent of decimal number 58.25 is


111010.01.

Decimal to Octal Conversion


The following two types of operations take place, while
converting decimal number into its equivalent octal number.
 Division of integer part and successive quotients with base
8.
 Multiplication of fractional part and successive fractions
with base 8.

Example
Consider the decimal number 58.25. Here, the integer part is
58 and fractional part is 0.25.

Step 1 − Division of 58 and successive quotients with base 8.


Operation Quotient Remainder
58/8 7 2
7/8 0 7

⇒(58)10 = (72)8

Therefore, the integer part of equivalent octal number is 72.


Step 2 − Multiplication of 0.25 and successive fractions with
base 8.
Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]
- 10 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Operation Result Carry


0.25 x 8 2.00 2
- 0.00 -
⇒ (.25)10 = (.2)8

Therefore, the fractional part of equivalent octal number is .2


⇒ (58.25)10 = (72.2)8

Therefore, the octal equivalent of decimal number 58.25 is


72.2.

Decimal to Hexa-Decimal Conversion


The following two types of operations take place, while
converting decimal number into its equivalent hexa-decimal
number.
 Division of integer part and successive quotients with base
16.
 Multiplication of fractional part and successive fractions
with base 16.

Example
Consider the decimal number 58.25. Here, the integer part is
58 and decimal part is 0.25.

Step 1 − Division of 58 and successive quotients with base 16.


Operation Quotient Remainder
58/16 3 10=A
3/16 0 3

⇒ (58)10 = (3A)16

Therefore, the integer part of equivalent Hexa-decimal number


is 3A.

Step 2 − Multiplication of 0.25 and successive fractions with


base 16.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 11 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Operation Result Carry


0.25 x 16 4.00 4
- 0.00 -

⇒(.25)10 = (.4)6

Therefore, the fractional part of equivalent Hexa-decimal


number is .4.

⇒ (58.25)10 = (3A.4)16

Therefore, the Hexa-decimal equivalent of decimal number


58.25 is 3A.4.

Binary Number to other Bases Conversion


The process of converting a number from binary to decimal is
different to the process of converting a binary number to other
bases. Now, let us discuss about the conversion of a binary
number to decimal, octal and Hexa-decimal number systems
one by one.

Binary to Decimal Conversion


For converting a binary number into its equivalent decimal
number, first multiply the bits of binary number with the
respective positional weights and then add all those products.

Example
Consider the binary number 1101.11.

Mathematically, we can write it as


(1101.11)2 = (1 × 23) + (1 × 22) + (0 × 21) + (1 × 20) + (1 × 2-1) +
(1 × 2-2)
⇒ (1101.11)2 = 8 + 4 + 0 + 1 + 0.5 + 0.25 = 13.75
⇒ (1101.11)2 = (13.75)10
Therefore, the decimal equivalent of binary number 1101.11
is 13.75.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 12 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Binary to Octal Conversion


We know that the bases of binary and octal number systems are
2 and 8 respectively. Three bits of binary number is equivalent
to one octal digit, since 23 = 8.

Follow these two steps for converting a binary number into its
equivalent octal number.
 Start from the binary point and make the groups of 3 bits on
both sides of binary point. If one or two bits are less while
making the group of 3 bits, then include required number of
zeros on extreme sides.
 Write the octal digits corresponding to each group of 3 bits.

Example
Consider the binary number 101110.01101.

Step 1 − Make the groups of 3 bits on both sides of binary point.


101 110.011 01
Here, on right side of binary point, the last group is having only
2 bits. So, include one zero on extreme side in order to make it
as group of 3 bits.
⇒ 101 110.011 010

Step 2 − Write the octal digits corresponding to each group of 3


bits.
⇒ (101 110.011 010)2 = (56.32)8

Therefore, the octal equivalent of binary number


101110.01101 is 56.32.

Binary to Hexa-Decimal Conversion


We know that the bases of binary and Hexa-decimal number
systems are 2 and 16 respectively. Four bits of binary number is
equivalent to one Hexa-decimal digit, since 24 = 16.
Follow these two steps for converting a binary number into its
equivalent Hexa-decimal number.
 Start from the binary point and make the groups of 4 bits on
both sides of binary point. If some bits are less while making
Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]
- 13 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

the group of 4 bits, then include required number of zeros


on extreme sides.
 Write the Hexa-decimal digits corresponding to each group
of 4 bits.

Example
Consider the binary number 101110.01101

Step 1 − Make the groups of 4 bits on both sides of binary point.


10 1110.0110 1
Here, the first group is having only 2 bits. So, include two zeros
on extreme side in order to make it as group of 4 bits. Similarly,
include three zeros on extreme side in order to make the last
group also as group of 4 bits.
⇒ 0010 1110.0110 1000

Step 2 − Write the Hexa-decimal digits corresponding to each


group of 4 bits.
⇒ (0010 1110.0110 1000)2 = (2E.68)16

Therefore, the Hexa-decimal equivalent of binary number


101110.01101 is (2E.68).

Octal Number to other Bases Conversion


The process of converting a number from octal to decimal is
different to the process of converting an octal number to other
bases. Now, let us discuss about the conversion of an octal
number to decimal, binary and Hexa-decimal number systems
one by one.

Octal to Decimal Conversion


For converting an octal number into its equivalent decimal
number, first multiply the digits of octal number with the
respective positional weights and then add all those products.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 14 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Example
Consider the octal number 145.23.

Mathematically, we can write it as


(145.23)8 = (1 × 82) + (4 × 81) + (5 × 80) + (2 × 8-1) + (3 × 8-2)
⇒ (145.23)8 = 64 + 32 + 5 + 0.25 + 0.05 = 101.3
⇒ (145.23)8 = (101.3)10
Therefore, the decimal equivalent of octal number 145.23 is
101.3.

Octal to Binary Conversion


The process of converting an octal number to an equivalent
binary number is just opposite to that of binary to octal
conversion. By representing each octal digit with 3 bits, we will
get the equivalent binary number.

Example
Consider the octal number 145.23.
Represent each octal digit with 3 bits.
(145.23)8 = (001 100 101.010 011)2

The value doesn’t change by removing the zeros, which are on


the extreme side.
⇒ (145.23)8 = (1100101.010011)2

Therefore, the binary equivalent of octal number 145.23 is


1100101.010011.

Octal to Hexa-Decimal Conversion


Follow these two steps for converting an octal number into its
equivalent Hexa-decimal number.
 Convert octal number into its equivalent binary number.
 Convert the above binary number into its equivalent Hexa-
decimal number.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 15 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Example
Consider the octal number 145.23
In previous example, we got the binary equivalent of octal
number 145.23 as 1100101.010011.

By following the procedure of binary to Hexa-decimal


conversion, we will get
(1100101.010011)2 = (65.4C)16
⇒(145.23)8 = (65.4C)16

Therefore, the Hexa-decimal equivalent of octal number


145.23 is 65.4C.

Hexa-Decimal Number to other Bases Conversion


The process of converting a number from Hexa-decimal to
decimal is different to the process of converting Hexa-decimal
number into other bases. Now, let us discuss about the
conversion of Hexa-decimal number to decimal, binary and octal
number systems one by one.

Hexa-Decimal to Decimal Conversion


For converting Hexa-decimal number into its equivalent
decimal number, first multiply the digits of Hexa-decimal
number with the respective positional weights and then add all
those products.

Example
Consider the Hexa-decimal number 1A5.2

Mathematically, we can write it as


(1A5.2)16 = (1 × 162) + (10 × 161) + (5 × 160) + (2 × 16-1)
⇒ (1A5.2)16 = 256 + 160 + 5 + 0.125 = 421.125
⇒ (1A5.2)16 = (421.125)10

Therefore, the decimal equivalent of Hexa-decimal number


1A5.2 is 421.125.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 16 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Hexa-Decimal to Binary Conversion


The process of converting Hexa-decimal number into its
equivalent binary number is just opposite to that of binary to
Hexa-decimal conversion. By representing each Hexa-decimal
digit with 4 bits, we will get the equivalent binary number.

Example
Consider the Hexa-decimal number 65.4C
Represent each Hexa-decimal digit with 4 bits.
(65.4C)6 = (0110 0101.0100 1100)2

The value doesn’t change by removing the zeros, which are at


two extreme sides.
⇒ (65.4C)16 = (1100101.010011)2

Therefore, the binary equivalent of Hexa-decimal number


65.4C is 1100101.010011.

Hexa-Decimal to Octal Conversion


Follow these two steps for converting Hexa-decimal number
into its equivalent octal number.
 Convert Hexa-decimal number into its equivalent binary
number.
 Convert the above binary number into its equivalent
octal number.

Example
Consider the Hexa-decimal number 65.4C

In previous example, we got the binary equivalent of Hexa-


decimal number 65.4C as 1100101.010011.

By following the procedure of binary to octal conversion, we will


get
(1100101.010011)2 = (145.23)8
⇒ (65.4C)16 = (145.23)𝟖

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 17 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Therefore, the octal equivalent of Hexa-decimal number 65.4C


is 145.23.

Binary Numbers Representation


We can make the binary numbers into the following two groups
− Unsigned numbers and Signed numbers.

Unsigned Numbers
Unsigned numbers contain only magnitude of the number. They
don’t have any sign. That means all unsigned binary numbers
are positive. As in decimal number system, the placing of
positive sign in front of the number is optional for representing
positive numbers. Therefore, all positive numbers including
zero can be treated as unsigned numbers if positive sign is not
assigned in front of the number.

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, which indicates the binary number is positive.


Similarly, if sign bit is one, which 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 doesn’t 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.
Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]
- 18 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

(108)10 = (1101100)2
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) 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.

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
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)10 = (01101100)2

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.
Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]
- 19 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

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 one,
which is placed on left most side of magnitude.
(−108)10 = (11101100)2

Therefore, the sign-magnitude representation of -108 is


11101100.

1’s complement form


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. We know the signed binary
representation of 108 is 01101100.

It is having 8 bits. The MSB of this number is zero, which


indicates positive number. Complement of zero is one and vice-
Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]
- 20 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

versa. So, replace zeros by ones and ones by zeros in order to


get the negative number.
(−108)10 = (10010011)2
Therefore, the 1’s complement of (108)10 is (10010011)2.

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.

Example
Consider the negative decimal number -108.
We know the 1’s complement of (108)10 is (10010011)2
2’s compliment of (108)10 = 1’s compliment of (108)10 + 1.
= 10010011 + 1
= 10010100

Therefore, the 2’s complement of (108)10 is (10010100)2.

Binary Arithmetic
Let us discuss about the basic arithmetic operations, which can
be performed on any two signed binary numbers using 2’s
complement method. The basic arithmetic operations are
addition and subtraction.

Addition of two Signed Binary Numbers


Consider the two signed binary numbers A & B, which are
represented in 2’s complement form. We can perform the
addition of these two numbers, which is similar to the addition
of two unsigned binary numbers. But, if the resultant sum
contains carry out from sign bit, then discard (ignore) it in order
to get the correct value.
Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]
- 21 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

If resultant sum is positive, you can find the magnitude of it


directly. But, if the resultant sum is negative, then take 2’s
complement of it in order to get the magnitude.

Example 1
Let us perform the addition of two decimal numbers +7 and +4
using 2’s complement method.

The 2’s complement representations of +7 and +4 with 5 bits


each are shown below.
(+7)10 = (00111)2
(+4)10 = (00100)2

The addition of these two numbers is


(+7)10 +(+4)10= (00111)2+(00100)2
(+7)10 +(+4)10= (01011)2.

The resultant sum contains 5 bits. So, there is no carry out from
sign bit. The sign bit ‘0’ indicates that the resultant sum is
positive. So, the magnitude of sum is 11 in decimal number
system. Therefore, addition of two positive numbers will give
another positive number.

Example 2
Let us perform the addition of two decimal numbers -7 and -4
using 2’s complement method.

The 2’s complement representation of -7 and -4 with 5 bits


each are shown below.
(−7)10 = (11001)2
(−4)10 = (11100)2

The addition of these two numbers is


(−7)10 + (−4)10 = (11001)2 + (11100)2
⇒(−7)10 + (−4)10 = (110101)2.

The resultant sum contains 6 bits. In this case, carry is obtained


from sign bit. So, we can remove it
Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]
- 22 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Resultant sum after removing carry is (−7)10 + (−4)10 =


(10101)2.

The sign bit ‘1’ indicates that the resultant sum is negative. So,
by taking 2’s complement of it we will get the magnitude of
resultant sum as 11 in decimal number system. Therefore,
addition of two negative numbers will give another negative
number.

Subtraction of two Signed Binary Numbers


Consider the two signed binary numbers A & B, which are
represented in 2’s complement form. We know that 2’s
complement of positive number gives a negative number. So,
whenever we have to subtract a number B from number A, then
take 2’s complement of B and add it to A. So, mathematically
we can write it as
A - B = A + (2's complement of B)

Similarly, if we have to subtract the number A from number B,


then take 2’s complement of A and add it to B. So,
mathematically we can write it as
B - A = B + (2's complement of A)

So, the subtraction of two signed binary numbers is similar to


the addition of two signed binary numbers. But, we have to take
2’s complement of the number, which is supposed to be
subtracted. This is the advantage of 2’s complement technique.

Follow, the same rules of addition of two signed binary


numbers.

Example 3
Let us perform the subtraction of two decimal numbers +7 and
+4 using 2’s complement method.

The subtraction of these two numbers is


(+7)10 − (+4)10 = (+7)10 + (−4)10.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 23 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

The 2’s complement representation of +7 and -4 with 5 bits


each are shown below.
(+7)10 = (00111)2
(+4)10 = (11100)2
⇒(+7)10 + (+4)10 = (00111)2 + (11100)2 = (00011)2

Here, the carry obtained from sign bit. So, we can remove it. The
resultant sum after removing carry is
(+7)10 + (+4)10 = (00011)2

The sign bit ‘0’ indicates that the resultant sum is positive. So,
the magnitude of it is 3 in decimal number system. Therefore,
subtraction of two decimal numbers +7 and +4 is +3.

Example 4
Let us perform the subtraction of two decimal numbers +4 and
+7 using 2’s complement method.

The subtraction of these two numbers is


(+4)10 − (+7)10 = (+4)10 + (−7)10.

The 2’s complement representation of +4 and -7 with 5 bits


each are shown below.
(+4)10 = (00100)2
(-7)10 = (11001)2
⇒(+4)10 + (-7)10 = (00100)2 + (11001)2 = (11101)2

Here, carry is not obtained from sign bit. The sign bit ‘1’
indicates that the resultant sum is negative. So, by taking 2’s
complement of it we will get the magnitude of resultant sum as
3 in decimal number system. Therefore, subtraction of two
decimal numbers +4 and +7 is -3.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 24 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Codes
In the coding, when numbers or letters are represented by a
specific group of symbols, it is said to be that number or letter is
being encoded. The group of symbols is called as code. The
digital data is represented, stored and transmitted as group of
bits. This group of bits is also called as binary code.
Binary codes can be classified into two types.
 Weighted codes
 Unweighted codes

If the code has positional weights, then it is said to be weighted


code. Otherwise, it is an unweighted code. Weighted codes can
be further classified as positively weighted codes and negatively
weighted codes.

Binary Codes for Decimal digits


The following table shows the various binary codes for decimal
digits 0 to 9.
Decimal 8421 2421 84-2-1 Excess 3
Digit Code Code Code Code
0 0000 0000 0000 0011
1 0001 0001 0111 0100
2 0010 0010 0110 0101
3 0011 0011 0101 0110
4 0100 0100 0100 0111
5 0101 1011 1011 1000
6 0110 1100 1010 1001
7 0111 1101 1001 1010
8 1000 1110 1000 1011
9 1001 1111 1111 1100

We have 10 digits in decimal number system. To represent these


10 digits in binary, we require minimum of 4 bits. But, with 4
bits there will be 16 unique combinations of zeros and ones.

Since, we have only 10 decimal digits, the other 6 combinations


of zeros and ones are not required.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 25 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

8-4-2-1 code
 The weights of this code are 8, 4, 2 and 1.
 This code has all positive weights. So, it is a positively
weighted code.
 This code is also called as natural BCD (Binary Coded
Decimal) code.

Example
Let us find the BCD equivalent of the decimal number 786. This
number has 3 decimal digits 7, 8 and 6. From the table, we can
write the BCD (8421) codes of 7, 8 and 6 are 0111, 1000 and
0110 respectively.
∴ (786)10 = (011110000110)BCD

There are 12 bits in BCD representation, since each BCD code of


decimal digit has 4 bits.

2-4-2-1 code
 The weights of this code are 2, 4, 2 and 1.
 This code has all positive weights. So, it is a positively
weighted code.
 It is an unnatural BCD code. Sum of weights of unnatural
BCD codes is equal to 9.
 It is a self-complementing code. Self-complementing codes
provide the 9’s complement of a decimal number, just by
interchanging 1’s and 0’s in its equivalent 2421
representation.

Example
Let us find the 2421 equivalent of the decimal number 786. This
number has 3 decimal digits 7, 8 and 6. From the table, we can
write the 2421 codes of 7, 8 and 6 are 1101, 1110 and 1100
respectively.

Therefore, the 2421 equivalent of the decimal number 786 is


110111101100.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 26 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

8 4 -2 -1 code
 The weights of this code are 8, 4, -2 and -1.
 This code has negative weights along with positive
weights. So, it is a negatively weighted code.
 It is an unnatural BCD code.
 It is a self-complementing code.

Example
Let us find the 8 4-2-1 equivalent of the decimal number 786.
This number has 3 decimal digits 7, 8 and 6. From the table, we
can write the 8 4 -2 -1 codes of 7, 8 and 6 are 1001, 1000 and
1010 respectively.

Therefore, the 8 4 -2 -1 equivalent of the decimal number 786 is


100110001010.

Excess 3 code
 This code doesn’t have any weights. So, it is an un-weighted
code.
 We will get the Excess 3 code of a decimal number by adding
three (0011) to the binary equivalent of that decimal
number. Hence, it is called as Excess 3 code.
 It is a self-complementing code.

Example
Let us find the Excess 3 equivalent of the decimal number 786.
This number has 3 decimal digits 7, 8 and 6. From the table, we
can write the Excess 3 codes of 7, 8 and 6 are 1010, 1011 and
1001 respectively.
Therefore, the Excess 3 equivalent of the decimal number 786 is
101010111001

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 27 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Gray Code
The following table shows the 4-bit Gray codes corresponding
to each 4-bit binary code.
Decimal Binary Gray
Number Code Code
0 0000 0000
1 0001 0001
2 0010 0011
3 0011 0010
4 0100 0110
5 0101 0111
6 0110 0101
7 0111 0100
8 1000 1100
9 1001 1101
10 1010 1111
11 1011 1110
12 1100 1010
13 1101 1011
14 1110 1001
15 1111 1000
 This code doesn’t have any weights. So, it is an un-weighted
code.
 In the above table, the successive Gray codes are differed in
one bit position only. Hence, this code is called as unit
distance code.

Binary code to Gray Code Conversion


Follow these steps for converting a binary code into its
equivalent Gray code.
 Consider the given binary code and place a zero to the left of
MSB.
 Compare the successive two bits starting from zero. If the 2
bits are same, then the output is zero. Otherwise, output is
one.
 Repeat the above step till the LSB of Gray code is obtained.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 28 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Example
From the table, we know that the Gray code corresponding to
binary code 1000 is 1100. Now, let us verify it by using the above
procedure.

Given, binary code is 1000.

Step 1 − By placing zero to the left of MSB, the binary code will
be 01000.

Step 2 − By comparing successive two bits of new binary code,


we will get the gray code as 1100.

Error Detection and Correction Codes


We know that the bits 0 and 1 corresponding to two different
range of analog voltages. So, during transmission of binary data
from one system to the other, the noise may also be added. Due
to this, there may be errors in the received data at other system.
That means a bit 0 may change to 1 or a bit 1 may change to 0.
We can’t avoid the interference of noise. But, we can get back
the original data first by detecting whether any error(s) present
and then correcting those errors. For this purpose, we can use
the following codes.
 Error detection codes
 Error correction codes

Error detection codes are used to detect the error(s) present


in the received data (bit stream). These codes contain some
bit(s), which are included (appended) to the original bit stream.
These codes detect the error, if it is occurred during
transmission of the original data (bit stream).Example − Parity
code, Hamming code.

Error correction codes are used to correct the error(s) present


in the received data (bit stream) so that, we will get the original
data. Error correction codes also use the similar strategy of
error detection codes. Example − Hamming code.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 29 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Therefore, to detect and correct the errors, additional bit(s) are


appended to the data bits at the time of transmission.

Parity Code
It is easy to include (append) one parity bit either to the left of
MSB or to the right of LSB of original bit stream. There are two
types of parity codes, namely even parity code and odd parity
code based on the type of parity being chosen.

Even Parity Code


The value of even parity bit should be zero, if even number of
ones present in the binary code. Otherwise, it should be one. So
that, even number of ones present in even parity code. Even
parity code contains the data bits and even parity bit.

The following table shows the even parity codes


corresponding to each 3-bit binary code. Here, the even parity
bit is included to the right of LSB of binary code.

Binary Even Even Parity


Code Parity bit Code
000 0 0000
001 1 0011
010 1 0101
011 0 0110
100 1 1001
101 0 1010
110 0 1100
111 1 1111
Here, the number of bits present in the even parity codes is 4.
So, the possible even number of ones in these even parity codes
are 0, 2 & 4.
 If the other system receives one of these even parity
codes, then there is no error in the received data. The bits
other than even parity bit are same as that of binary code.
 If the other system receives other than even parity codes,
then there will be an error(s) in the received data. In this

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 30 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

case, we can’t predict the original binary code because


we don’t know the bit position(s) of error.
Therefore, even parity bit is useful only for detection of error in
the received parity code. But, it is not sufficient to correct the
error.

Odd Parity Code


The value of odd parity bit should be zero, if odd number of ones
present in the binary code. Otherwise, it should be one. So that,
odd number of ones present in odd parity code. Odd parity
code contains the data bits and odd parity bit.

The following table shows the odd parity codes corresponding


to each 3-bit binary code. Here, the odd parity bit is included to
the right of LSB of binary code.

Binary Odd Odd Parity


Code Parity bit Code
000 1 0001
001 0 0010
010 0 0100
011 1 0111
100 0 1000
101 1 1011
110 1 1101
111 0 1110

Here, the number of bits present in the odd parity codes is 4. So,
the possible odd number of ones in these odd parity codes are 1
& 3.
 If the other system receives one of these odd parity
codes, then there is no error in the received data. The bits
other than odd parity bit are same as that of binary code.
 If the other system receives other than odd parity codes,
then there is an error(s) in the received data. In this case,
we can’t predict the original binary code because we
don’t know the bit position(s) of error.

Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]


- 31 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

Therefore, odd parity bit is useful only for detection of error in


the received parity code. But, it is not sufficient to correct the
error.

Alphanumeric codes
Alphanumeric codes are sometimes called character codes
due to their certain properties. Now these codes are basically
binary codes. We can write alphanumeric data, including data,
letters of the alphabet, numbers, mathematical symbols and
punctuation marks by this code which can be easily
understandable and can be processed by the computers. Input
output devices such as keyboards, monitors, mouse can be
interfaced using these codes. 12-bit Hollerith code is the better
known and perhaps the first effective code in the days of
evolving computers in early days. During this period punch
cards were used as the inputting and outputting data. But
nowadays these codes are termed obsolete as many other
modern codes have evolved. The most common alphanumeric
codes used these days are ASCII code, EBCDIC code and
Unicode. Now we will discuss about them briefly.

ASCII code
The full form of ASCII code is American Standard Code for
Information Interchange. It is a seven bit code based on the
English alphabet.

In 1967 this code was first published and since then it is being
modified and updated. ASCII code has 128 characters some of
which are enlisted below to get familiar with the code.
DEC OCT HEX BIN Symbol Description
0 000 00 00000000 NUL Null char
1 001 01 00000001 SOH Start of Heading
2 002 02 00000010 STX Start of Text
3 003 03 00000011 ETX End of Text
4 004 04 00000100 EOT End of Transmission
5 005 05 00000101 ENQ Enquiry
6 006 06 00000110 ACK Acknowledgment
7 007 07 00000111 BEL Bell
Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]
- 32 -
CS1CMT01 Fundamentals of Digital Systems (Complementary) MG University, Kottayam

8 010 08 00001000 BS Back Space


9 011 09 00001001 HT Horizontal Tab
10 012 0A 00001010 LF Line Feed
11 013 0B 00001011 VT Vertical Tab
12 014 0C 00001100 FF Form Feed
13 015 0D 00001101 CR Carriage Return
14 016 0E 00001110 SO Shift Out / X-On
15 017 0F 00001111 SI Shift In / X-O
There are many more codes which are not included here.

EBCDIC code
The EBCDIC stands for Extended Binary Coded Decimal
Interchange Code. IBM invented this code to extend the Binary
Coded Decimal which existed at that time. All the IBM
computers and peripherals use this code. It is an 8 bit code and
therefore can accommodate 256 characters. Below is given
some characters of EBCDIC code to get familiar with it.
Char EBCDIC Char EBCDIC Char EBCDIC
A 1100 0001 P 1101 0111 4 1111 0100
B 1100 0010 Q 1101 1000 5 1111 0101
C 1100 0011 R 1101 1001 6 1111 0110
D 1100 0100 S 1110 0010 7 1111 0111
E 1100 0101 T 1110 0011 8 1111 1000
F 1100 0110 U 1110 0100 9 1111 1001
G 1100 0111 V 1110 0101 blank ...
H 1100 1000 W 1110 0110 . ...
I 1100 1001 X 1110 0111 ( ...
J 1101 0001 Y 1110 1000 + ...
K 1101 0010 Z 1110 1001 $ ...
L 1101 0011 0 1111 0000 * ...
M 1101 0100 1 1111 0001 ) ...
N 1101 0101 2 1111 0010 - ...
O 1101 0110 3 1111 0011 /
UNICODE
Unicode is the newest concept in digital coding. In Unicode
every number has a unique character. Leading technological
giants have adopted this code for its uniqueness.
Eugin Lopez. F, Asst. Prof in Computer, CAS, IHRD, Thodupuzha [email protected]

You might also like