All right reserved. No part of this publication may be stored in any retrieval or transmitted in
any form or by any means electronic, mechanical, photocopying, recording or otherwise without
prior permission from the publisher.
Published by:
Politeknik Kota Kinabalu
No 4, Jalan Politeknik, KKIP Barat,
Kota Kinabalu Industrial Park,
88460, Kota Kinabalu, Sabah.
FOREWORD
Digital Electronics (DEE2034) has been developed and revised to fulfil the
requirements of Polytechnic Course Syllabus. This book is written by the lecturers from
Department of Electrical Engineering, Polytechnic Kota Kinabalu.
Digital Electronics is an introductory reference book for diploma students in the field of
electronics, especially in the engineering disciplines such as electrical engineering,
communication engineering, and computer engineering. This book is meant to be a self-study
aid, systematically organized to meet the requirements of polytechnics in Malaysia. It present
the basic theories of digital circuits and their application with detailed explanations, diagrams
and exercises.
This book is divided into 6 chapters covering major topics in digital electronics as
prescribed by JPP. The chapter that cover in this book are Number and Code Systems (Chapter
1), Boolean Operation (Chapter 2), Data Processing Circuits (Chapter 3), Flip Flop (Chapter 4),
Counters (Chapter 5) and Shift Register (Chapter 6). This book also provides worked out
examples for each chapter and self-practice questions for students to further test their
understanding of each topic. This also helps student to develop confidence and expand their
knowledge for each chapter.
While the book is intended for diploma and undergraduate students, it is also
envisioned to be a very useful reference book for postgraduate students, professionals and
researchers. We sincerely hope that this book will be beneficial for the readers. We welcome
any suggestions for further improvement in future editions.
NUR WAHIDA BINTI JANUDIN
NURAIN MOHD IZZUAN WONG
BENNY AZMI BIN DOIMIN
Department of Electrical Engineering
Polytechnic Kota Kinabalu
TABLE OF CONTENT PAGE
CONTENT 1
FOREWORD 1
TABLE OF CONTENT 3
CHAPTER 1: NUMBER AND CODE SYSTEMS 3
3
1.0 Introduction 3
1.1 Number Systems 4
4
1.1.1 Decimal System 5
1.1.2 Binary System 5
1.1.3 Octal System 6
1.1.4 Hexadecimal System 7
1.2 Conversion Number Systems 7
1.2.1 Decimal to Binary Conversion 8
1.2.2 Decimal to Octal Conversions 9
1.2.3 Decimal to Hexadecimal Conversions 10
1.2.4 Binary to Decimal Conversions 10
1.2.5 Octal to Decimal Conversions 13
1.2.6 Hexadecimal to Decimal Conversions 16
1.2.7 Binary to Octal Conversions 16
1.2.8 Binary to Hexadecimal Conversions 19
1.2.9 Hexadecimal to Binary Conversions 20
1.2.10 Hexadecimal to Octal Conversions 21
1.2.11 Octal to Hexadecimal Conversions 21
1.3 Arithmetic of Number Systems 21
1.3.1 Binary Arithmetic 22
1.3.2 Octal Arithmetic 23
1.3.3 Hexadecimal Arithmetic 25
1.4 Sign Numbers 25
1.5 2’s Complement Numbers 25
1.5.1 1’s Complement 28
1.5.2 2’s Complement 30
1.5.3 Arithmetic of 2’s Complement
1.5.4 Arithmetic Overflow 33
1.6 Code Number 34
1.6.1 BCD 8421 36
1.6.2 ASCII Code
Exercise 1
CHAPTER2: BOOLEAN OPERATION
2.1 Truth Table
2.2 Logic Gates
2.3 Universal Gates
2.4 Combinational Logic Gates 37
2.5 Boolean Algebra 38
2.6 Boolean Expression 40
2.7 Karnaugh Map (K-Map) 43
Exercise 2 47
CHAPTER 3: DATA PROCESSING CIRCUITS
3.1 Data Processing Circuit 50
3.2 Encoder 50
51
3.2.1 Encoder with 4-line inputs to 2-line outputs 52
3.2.2 Decimal to BCD Encoder 54
3.3 Decoder 54
3.3.1 Decoder with 2-line inputs to 4-line outputs 55
3.3.2 Decoder with 3-line inputs to 8-line outputs 56
3.3.3 Decoder 7 Segment Display 57
3.4 Multiplexer 58
3.4.1 Multiplexer with 4-line inputs to 1-line output 60
3.5 Demultiplexer 63
Exercise 3
CHAPTER 4: FLIP-FLOPS 64
64
4.0 Introduction 65
4.1 Latches 66
66
4.1.1 NAND Gate Latch 67
4.1.2 NOR Gate Latch 68
4.2 Flip-flops 68
4.3 Clock Signal 71
4.4 Clocked Flip-flops 73
4.5 SR Flip-flop 75
4.6 JK Flip-flop 77
4.7 Flip-flop with Asynchronous Input 81
4.8 D Flip-flop
4.9 T Flip-flop 83
Exercise 4 83
CHAPTER 5: COUNTERS 83
5.0 Introduction 84
5.1 Counters 86
5.1.1 Modulus (MOD) 88
5.2 Asynchronous Counter 90
5.2.1 Design an Asynchronous Counter (MOD = 2N) 90
5.2.2 Design an Asynchronous Counter (MOD ≠ 2N) 92
5.2.3 Asynchronous Up-Down Counter
5.2.4 Asynchronous Counter as Frequency Divider
5.3 Synchronous Counter
5.3.1 Design a Synchronous Counter 93
5.3.2 Design a Random Synchronous Counter 95
5.4 Asynchronous Cascade Counter 98
5.5 Synchronous Cascade Counter 98
5.6 Application of Counter in Digital Clock 99
Exercise 5 101
CHAPTER 6: REGISTERS 102
102
6.0 Introduction 104
6.1 Shift Register 104
6.2 Types of Shift Registers 105
106
6.2.1 Serial In / Serial Out (SISO) 107
6.2.2 Serial In / Parallel Out (SIPO) 107
6.2.3 Parallel In / Serial Out (PISO) 107
6.2.4 Parallel In / Parallel Out (PIPO) 108
6.3 Application of Shift Register 108
6.3.1 Shift Right Register as Divider Circuits 108
6.3.2 Shift Left Register as Multiplier Circuits 109
6.4 Shift Register Counter 110
6.4.1 Ring Counter
6.4.2 Johnson Counter
Exercise 6
References
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
CHAPTER 1
NUMBER AND CODE SYSTEMS
OUTCOMES:
Upon completion of this topic, students should be able to:
1. illustrate the knowledge of digital number systems: decimal, binary, octal and
hexadecimal
2. illustrate the knowledge of code systems: BCD 8421 and ASCII code
1. Introduction
Digital electronic concepts was the backbone for the modern day gadget such as
handphone, camera and many more. In digital system, the binary system is widely use
because some of its advantages. The discrete signals used for binary system has two
discrete values either 0 or 1. However, there will be a situation where we need to
convert the binary system into decimal number for represent quantities outside the
digital system. Decimal number is the numerical base most widely used by modern
civilizations.
Other than that, number systems also consists of octal and hexadecimal system.
This type of systems are convenient to represent binary numbers compactly so that it is
simple to convert between them. Hexadecimal system adds some Latin letters
meanwhile octal system uses only digits.
1.1 Number Systems
4 types of numbering system used in digital system: [decimal system, binary system, octal
system and hexadecimal system]
i. Decimal system (N10)
⇒ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
ii. Binary system (N2)
⇒ 0, 1
iii. Octal system (N8)
⇒ 0, 1, 2, 3, 4, 5, 6, 7
iv. Hexadecimal system (N16)
⇒ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 1
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
Example:
Table 1.1 Number system
Decimal Binary Octal Hexadecimal
System System System System
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 10 8
9 1001 11 9
10 1010 12 A
11 1011 13 B
12 1100 14 C
13 1101 15 D
14 1110 16 E
15 1111 17 F
** Binary Number System:
System Digits: 0 and 1
Bit (short for binary digit): A single binary digit
LSB (least significant bit): The right most bit
MSB (most significant bit): The left most bit
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 2
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.1.1 Decimal System
Power 105 104 Table 1.2 Decimal system . 10-1 10-2 10-3
of 10 100000 10000 Decimal System 0.01 0.001
LSD
Place MSD 103 102 101 100
value
Position 1000 100 10 1 . 0.1
value
Decimal
point
1.1.2 Binary System
Power 25 24 Table 1.3 Binary system . 2-1 2-2 2-3
of 2 32 16 Binary System 0.5 0.25 0.125
MSB .
Place 23 22 21 20 LSB
value Binary
Position 8 421 point
value
1.1.3 Octal System
Table 1.4 Octal system
Octal System
Power 85 84 83 82 81 80 . 8-1 8-2 8-3
of 8 32768 4096 0.001953
MSD 512 64 8 1 . 0.125 0.015625
Place LSD
value Octal
Position point
value
1.1.4 Hexadecimal System
Power 164 Table 1.5 Hexadecimal system 16-1 16-2 16-3
of 16 65536 Hexadecimal System
Place MSD 163 162 161 160 .
value
4096 256 16 1 . 0.0625 0.0039 0.00024
Position
value Hexa LSD
point
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 3
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.2 Conversion Number Systems
1.2.1 Decimal to Binary Conversions
The decimal number will divide by 2 until obtain minimum values. If the decimal
number have the decimal point, each of the decimal point value must be multiplied by 2.
Example:
Convert 12310 to it binary equivalent.
Answer:
Example:
Convert 97.5410 to it binary equivalent.
Answer:
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 4
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.2.2 Decimal to Octal Conversions
The decimal number will divide by 8 until minimum values. If the decimal number have
the decimal point, each of the decimal point value must be multiplied by 8.
Example:
Convert 39610 to it octal equivalent.
Answer:
Example:
Convert 172.3110 to it octal equivalent.
Answer:
1.2.3 Decimal to Hexadecimal Conversions
The decimal number will divide by 16 until minimum values. If the decimal number have
the decimal point, each of the decimal point value must be multiplied by 16.
Example:
Convert 698310 to it hexadecimal equivalent.
Answer:
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 5
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
Example:
Convert 5932.7610 to it binary equivalent.
Answer:
1.2.4 Binary to Decimal Conversions
Table 1.6 Binary system
Binary System
…….25 24 23 22 21 20 2-1 2-2 2-3…..
…….32 16 8 4 2 1 0.5 0.25 0.125….
Example:
Convert 1012 to it decimal equivalent.
Answer:
Example:
Convert 1011.012 to it decimal equivalent.
Answer:
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 6
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.2.5 Octal to Decimal Conversions
Table 1.7 Octal system
Octal System
.....83 82 81 80 8-1 8-2…..
…512
64 8 1 0.125 0.015625….
Example:
Convert 6258 to it decimal equivalent.
Answer:
Example:
Convert 31.78 to it decimal equivalent.
Answer:
1.2.6 Hexadecimal to Decimal Conversions
Table 1.8 Hexadecimal system
.....163 Hexadecimal System 16-2…..
…4096 0.0039….
162 161 160 16-1
256 16 1 0.0625
Example:
Convert 1D216 to it decimal equivalent.
Answer:
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 7
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
Example:
Convert A69.5C16 to it decimal equivalent.
Answer:
1.2.7 Binary to Octal Conversions
Assign each of bit binary numbers into 3 bit from LSB to MSB. It is because octal
value need 3 bit of binary value to complete the systems.
Table 1.9 Binary and Octal system
Binary Octal
System System
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7
Example:
Convert 110101002 to it octal equivalent.
Answer:
Example:
Convert 10110.01012 to it octal equivalent.
Answer:
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 8
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.2.8 Binary to Hexadecimal Conversions
Assign each of bit binary numbers into 4 bit from LSB to MSB. It is because hexadecimal
value need 4 bit of binary value to complete the systems.
Table 1.10 Binary and Hexadecimal system
Binary Hexadecimal
System System
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
Example:
Convert 10110110102 to it hexadecimal equivalent.
Answer:
Example:
Convert 11110001.0101112 to it hexadecimal equivalent.
Answer:
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 9
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.2.9 Hexadecimal to Binary Conversions
Example:
Convert 195D16 to it binary equivalent.
Answer:
Example:
Convert 8E2.A616 to it binary equivalent.
Answer:
1.2.10 Hexadecimal to Octal Conversions
There are two methods to convert the hexadecimal to octal systems. The conversion
methods are:
1. Hexadecimal ⇒ Binary ⇒ Octal ** This method is easier and it can
2. Hexadecimal ⇒ Decimal ⇒ Octal reduce calculation careless.
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 10
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
Example:
Convert 62E316 to it octal equivalent.
Answer:
Method 1: Hexadecimal ⇒ Binary ⇒ Octal
Hexadecimal 6 2E 3
Binary 0110 0011
0010 1110
Octal
000 110 001 011 100 011
06 1 3 4 3
Method 2: Hexadecimal ⇒ Decimal ⇒ Octal
Step 1: Hexadecimal ⇒ Decimal
Step 2: Decimal ⇒ Octal
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 11
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
Example:
Convert 2C.1916 to it octal equivalent.
Answer:
Method 1: Hexadecimal ⇒ Binary ⇒ Octal
Hexadecimal 2 C ⦁ 19
Binary 0010 1100 ⦁
000 101 0001 1001
Octal 05 100 ⦁
4 000 110 010
06 2
Method 2: Hexadecimal ⇒ Decimal ⇒ Octal
Step 1: Hexadecimal ⇒ Decimal
Step 2: Decimal ⇒ Octal
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 12
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.2.11 Octal to Hexadecimal Conversions
There are two methods to convert the hexadecimal to octal systems. The methods are:
1. Octal ⇒ Binary ⇒ Hexadecimal ** This method is easier and it can
2. Octal ⇒ Decimal ⇒ Hexadecimal reduce calculation careless.
Example:
Convert 42578 to it hexadecimal equivalent.
Answer:
Method 1: Octal ⇒ Binary ⇒ Hexadecimal
Octal 4 25 7
Binary 100 010 101 111
1111
Hexadecimal 1000 1010 F
8 A
Method 2: Octal ⇒ Decimal ⇒ Hexadecimal
Step 1: Octal ⇒ Decimal
Step 2: Decimal ⇒ Hexadecimal
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 13
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
Example:
Convert 74.258 to it hexadecimal equivalent.
Answer:
Method 1: Octal ⇒ Binary ⇒ Hexadecimal
Octal 7 4 ⦁ 2 5
Binary 111 100 ⦁ 010 101
0011 1100 ⦁ 0101 0100
Hexadecimal 3
C 5 4
Method 2: Octal ⇒ Decimal ⇒ Hexadecimal
Step 1: Octal ⇒ Decimal
Step 2: Decimal ⇒ Hexadecimal
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 14
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 15
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.3 Arithmetic of Number Systems
1.3.1 Binary Arithmetic
1.3.1.1 Addition
There are 4 rules should be followed in the process of addition in binary numbers:
Rules of Binary Addition:
SUM CARRY-OUT
0+0=0
Rule 1:
Rule 2: 0+1=1 carry 1 to the next more significant bit 12 + 12 = 102
Rule 3: 1+0=1 110 + 110 = 210
Rule 4: 1+1=0
** Note: The rules of binary addition (without carries) are the same as the truths of the XOR
gate.
Example:
1. 10102 + 1112 = 100012
2. 111102 + 100112 = 1100012
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 16
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.3.1.2 Subtraction
There are 4 rules should be followed in the process of subtraction in binary numbers:
Rules of Binary Subtraction:
Rule 1: SUM BORROW-OUT
Rule 2: 0‒0=0 borrow 1 from the next more significant
Rule 3: 0‒1=1
Rule 4: 1‒0=1
1‒1=0
** Note: The rules of binary subtraction (without borrow) are the same as the truths of the XOR
gate.
Example:
1. 101012 – 1102 = 11112
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 17
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.3.1.3 Multiplication
There are 4 rules should be followed in the process of multiplication in binary numbers:
Rules of Binary Multiplication:
Rule 1: SUM CARRY-OUT/BORROW-OUT
Rule 2: 0x0=0 no carry or borrow bits
Rule 3: 0x1=0
Rule 4: 1x0=0
1x1=1
** Note: The rules of binary multiplication are the same as the truths of the AND gate.
Example:
1. 1012× 112 = 11112
1.3.1.4 Division
Binary division is the repeated process of subtraction, just as in decimal division.
Example:
1. 1010102 ÷ 1102 = 1112
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 18
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.3.2 Octal Arithmetic
1.3.2.1 Addition
Example:
1. 6538 + 1228 = 7758
2. 7168 + 1548 = 10728
** Note:
6 + 4 = 10 – 8 = 2
7+1=9–8=1
1.3.2.2 Subtraction
Example:
1. 13648 ‒ 1238 = 12418
2. 36458 ‒ 7518 = 26748
** Note:
4 + 8 = 12 – 5 = 7
5 + 8 = 13 – 7 = 6
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 19
DIGITAL ELECTRONIC 20
NUMBER AND CODE SYSTEMS
1.3.3 Hexadecimal Arithmetic
1.3.3.1 Addition
Example:
1. 952116 + 1A616 = 96C716
2. 3F216 + 6E16 = 46016
** Note:
2 + 14 = 16 – 16 = 0
15 + 1 + 6= 22 – 16 = 6
1.3.3.2 Subtraction
Example:
1. 2B9916 – 39816 = 280116
2. 6EF316 – FF16 = 6DF416
** Note:
3 + 16 = 19 – 15 = 4
14 + 16 = 30 – 15 = F
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016]
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.4 Sign Numbers
In digital systems, the binary numbers are represented by a set of binary such as a
microprocessor register 8 bits. The most significant bit (MSB) is the sign bit. If this bit is 0, then
the number is (+) positive. However, if the sign bit is 1, then the number is (-) negative. The
other 7 bits in this 8-bit register represent the magnitude of the number.
Figure 1.1: Representation of signed numbers in sign-magnitude form.
1.5 2’s Complement Numbers
The 2’s complement method of representing numbers is widely used in microprocessor
based equipment. Until now, we have assumed that all numbers are positive. However,
microprocessors must process both positive and negative numbers. By using 2’s complement
representation, the sign as well as the magnitude of a number can be determined.
1.5.1 1’s Complement
The 1’s complement of a binary number is obtained by changing 0 to 1 and 1 to 0. In other
words, change each bit in the number to its complement.
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 21
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
Example:
Original binary number ⇒ 0 0 1 0 1 1 0 1
⬇⬇⬇⬇⬇⬇⬇⬇
1’s complement ⇒ 1 1 0 1 0 0 1 0
1.5.2 2’s Complement
The 2’s complement of a binary number is formed by taking the 1’s complement of the
number and adding 1 to the least-significant-bit position.
Example:
Original binary number ⇒ 00101101
⬇⬇⬇⬇⬇⬇⬇⬇
1’s complement ⇒ 11010010
Add 1 to form 2’s complement ⇒ + 1
2’s complement of original number ⇒ 11010011
Example:
Represent the signed decimal numbers below as a signed binary number in 2’s complement
system. Use a total of 5 bits including the sign bit.
1. + 13
2. ‒ 9
Answer:
1. + 13 = 01011 ⇐ sign bit (+)
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 22
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
Answer:
2. ‒ 9 = 10111 ⇐ sign bit (‒)
+ 9 ⇒ change to ‒9 by using 2’s complement
+9 ⇒ 01001
1’s complement ⇒ 1 0 1 1 0
Add 1 ⇒ + 1
2’s complement ⇒ 1 0 1 1 1
1.5.3 Arithmetic of 2’s Complement
Case I: Two Positive Numbers
The addition of two positive numbers is straight forward.
Example: + 9 + 4 = + 13
Case II: Positive Number and Smaller Negative Number
Consider the addition of +9 and – 4. Remember that the – 4 will be in its 2’s complement form.
Thus, +4 (00100) must be converted to – 4 (11100).
Example: + 9 – 4 = + 5
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 23
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
Case III: Positive Number and Larger Negative Number
Consider the addition of – 9 and + 4.
Example: - 9 + 4 = ‒ 5
Case IV: Two Negative Numbers
Consider the addition of – 9 and – 4.
Example: ‒ 9 – 4 = ‒ 13
Case V: Equal and Opposite Numbers
Example: ‒ 9 + 9 = + 0
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 24
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.5.4 Arithmetic Overflow
Example:
The answer has a negative sign bit, which is obviously incorrect since we are adding two
positive numbers. The answer should be +17, but the magnitude 17 requires more than four bits
and therefore overflows into the sign-bit position. This overflow condition can occur only when
two positive or two negative numbers are being added, and it always produces an incorrect
result. Overflow can be detected by checking to see that the sign bit of the result is the same as
the sign bits of the numbers being added.
1.6 Code Number
1.6.1 BCD 8421
DECIMAL Table 1.11 BCD 8421 system 1
BCD 8421 0
0 1
1 84 2 0
2 00 0 1
3 00 0 0
4 00 1 1
5 00 1 0
6 01 0 1
7 01 0 0
8 01 1 1
9 01 1
10 0
10 0
Example:
Convert the following decimal value to BCD code.
a) 593110
b) 28.9410
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 25
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
Answer:
a) 593110 = 101100100110001BCD
DECIMAL ⇒ 5 9 3 1
BCD ⇒ ⬇ ⬇ ⬇ ⬇
0101 1001 0011 0001
b) 28.9410 = 101000.100101BCD
DECIMAL ⇒ 2 8 ⦁9 4
BCD ⇒ ⬇ ⬇ ⬇ ⬇
0010 1000 0100
⦁ 1001
Example:
Convert the following BCD code to it decimal value equivalent.
a) 10101010101000101BCD
b) 101000011.1001011BCD
Answer:
a) 10101010101000101BCD = 1554510
BCD ⇒ 0 0 0 1 0101 0101 0100 0101
⬇ ⬇ ⬇ ⬇
⬇ 5 5 4 5
DECIMAL ⇒ 1
b) 101000011.1001011BCD = 143.9610
BCD ⇒ 0 0 0 1 0 1 0 0 0 0 1 1 ⦁ 1 0 0 1 0 1 1 0
⬇⬇⬇ ⬇⬇
DECIMAL ⇒ 1 4 3 ⦁ 9 6
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 26
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
1.6.1.1 Arithmetic of BCD code
BCD addition follows the same rules as binary addition. However, if the addition
produces a carry and/or creates an invalid BCD number, an adjustment is required to correct
the sum. The correction method is to add 6 to the sum in any digit position that has caused an
error.
Case I: Sum Equals 9 or Less
Example:
1.
2.
Case II: Sum Greater Than 9
Example:
1.
2.
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 27
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
BCD subtraction follows the same rules as binary subtraction. However, if the subtraction
causes borrow and/or creates an invalid BCD number, an adjustment is required to correct the
answer. The correction method is to subtract 6 from the difference in any digit position that has
caused an error.
1.6.2 ASCII Code
ASCII code is used to transmit the digital data through telephone line. ASCII code is
stands for American Standard Code for Information Interchange. Table 1 shows the sequential
of ASCII code table that have alphabets, numbers and some symbols. ASCII code has 7 bit code.
For example, if the data was transmitted is 100 0001, that means the data is A. So, 100 0001 = A.
Table 1.12 ASCII code
How to determine the ASCII code:
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 28
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
Example:
Determine the ASCII code of Y = 5916 in binary number.
Answer:
Y = 101 1001 (binary)
Example:
The following is a message encoded in ASCII code. What is the message?
1001000 1000101 1001100 1010000
Answer: ⇒ 48 45 4C 50
⇒ 100 1000 100 0101 100 1100 101 0000
Hexadecimal ⇒
Binary H E L P
ASCII
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 29
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
EXERCISE 1
1. Convert these binary numbers to decimal, octal and hexadecimal.
(a) 10110 (c) 01011011 (e) 111010111
(b) 10001101 (d) 11111111 (f) 10111111
2. Convert the following decimal values to binary, octal and hexadecimal.
(a) 37 (c) 1024 (e) 205
(b) 14 (d) 77 (f) 2313
3. What is the largest decimal value that can be represented by an eight-bit binary number? A
16-bit number?
4. Convert each octal number to its decimal, hexadecimal and binary equivalent.
(a) 743 (c) 2000 (g) 257
(b) 36 (d) 165 (h) 1204
5. Convert each of the following hexadecimal numbers to octal, decimal and binary.
(a) 59 (c) 1024 (g) 2C0
(b) 1A6 (d) 771 (h) 255
6. Convert the following numbers to its decimal equivalent.
(a) 00110012 (c) 236.78 (g) 7A8.916
(b) 111001.0112 (d) 67.58 (h) 469.CF16
7. Convert the following numbers to its binary equivalent.
(a) 53410 (c) 76.738 (g) 7A8.916
(b) 23.8210 (d) 2358 (h) 91.9F16
8. Convert the following numbers to its octal equivalent.
(a) 53.4610 (c) 1000102 (g) 2A1.716
(b) 89010 (d) 1101.1102 (h) FE.9616
9. Convert the following numbers to its hexadecimal equivalent.
(a) 789610 (c) 676.738 (g) 1111010112
(b) 123.5610 (d) 27358 (h) 1011101.00102
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 30
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
10. Convert the following numbers to its 2’s complement number.
(a) +14 (c) -79
(b) +101 (d) +25
11. Convert the following numbers to its signed number.
(a) 11011001 (c) 00100110 (g) 01010010
(b) 11011011 (d) 00011010 (h) 10010000
12. Convert the following numbers in BCD code to decimal.
(a) 011010010101 (c) 011101110111 (g) 01010010
(b) 1000101110101 (d) 010010010010 (h) 10000110
0010
13. Encode these decimal numbers in BCD.
(a) 96210 (c) 91.4210
(b) 13810 (d) 123.4210
14. By referring to ASCII code in Appendix, answer the question below.
a) The following is a message encoded in ASCII code. What is the message?
1001000 1000101 1001100 1010000
b) Convert each seven-bit code in question 14(a) to its hex equivalent.
c) Encode the following message using hex representation:
“COST = $72”
15. Add the following in binary. Check your results by doing the addition in decimal.
(a) 1010 + 1011 (c) 110.111 + 10001.11
(b) 1111 + 0011 (d) 10011011 + 10011101
16. Perform the following operation in the 2’s complement system. Use 8-bit for each number.
Check your results by converting the binary result back to decimal.
(a) 9 + 6 (c) - 40 - 80 (g) 17 - 16
(b) 14 - 17 (d) 37 - 95 (h) - 36 – 15
17. Multiply the following pairs of binary numbers and check your results by doing the
multiplication in decimal.
(a) 1011 x 1011 (c) 10.011 x 11
(b) 101.101 x 110.010 (d) 0.11011 x 0.1
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 31
DIGITAL ELECTRONIC
NUMBER AND CODE SYSTEMS
18. Perform the following division of binary numbers and check your results by doing the
division in decimal.
(a) 1100 100 (c) 110.11 10
(b) 111111 11 (d) 1010 110
19. Perform the following addition of hexadecimal numbers and check your results by doing
the addition in decimal.
(a) 3E91 + 2F93 (c) 125.4 + 2.5D
(b) 2FFE + 0002 (d) D191 + AAAB
20. Perform the following subtraction of hexadecimal numbers and check your results by doing
the subtraction in decimal.
(a) 3E91 - 2F93 (c) 56F.3 - F.2
(b) 2F00 - 4000 (d) 0200 - 0003
Prepared by: BENNY AZMI BIN DOIMIN [PKK\JKE\2016] 32
DIGITAL ELECTRONIC
BOOLEAN OPERATION
CHAPTER 2
BOOLEAN OPERATION
OUTCOMES:
Upon completion of this topic, students should be able to:
1. draw and identify the each symbol of the logic gates
2. understand the basic concepts of Boolean algebra
3. construct combination logic circuits from Boolean expressions
4. simplify the combination logic circuits using Boolean Laws and Karnaugh Map.
2.1 Truth Table
A truth table is used for describing how a logic circuit’s output depends on the logic levels
present at the circuit’s input. In other words, the output could be any value depends on the
operation circuit. The truth table can be construct by defining all possible combinations of
inputs and output for each combination. The number of input combinations will be equal to 2N
for N-input truth table. For more understanding, see the example of truth table for 2, 3 and 4
inputs below.
Table 2.1 N-input truth table Truth Table
Symbol
Two (2) Input Output
Inputs AB X
00 1
01 0
10 1
11 0
Three (3) Input Output
Inputs ABC X
000 0
001 0
010 1
011 1
100 0
101 0
110 1
111 0
Prepared by: NUR WAHIDA JANUDIN [PKK\JKE\2016] 33
DIGITAL ELECTRONIC
BOOLEAN OPERATION
Symbol Truth Table
Four (4) Input Output
Inputs
ABCD X
0000 0
0001 0
0010 1
0011 1
0100 0
0101 0
0110 1
0111 0
1000 1
1001 0
1010 0
1011 0
1100 1
1101 1
1110 1
1111 0
2.2 Logic Gates
A logic gate is an elementary building block of a digital circuit. Most logic gates have two
inputs and one output. At any given moment, every terminal is in one of the two binary
conditions low (0) or high, represented by different voltage levels.
Some of the more common ones used in electronic circuits are shown in Table 2.2.
Table 2.2 Logic 0 and Logic 1
Logic 0 Logic 1
Low High
False True
No Yes
Off On
Open switch Close switch
Prepared by: NUR WAHIDA JANUDIN [PKK\JKE\2016] 34
DIGITAL ELECTRONIC
BOOLEAN OPERATION
The logic state of a terminal can, and generally does, change often, as the circuit processes data.
In most logic gates, the low state is approximately zero volts (0 V), while the high state is
approximately five volts positive (+5 V). Sometimes, logic gates are called switches. Logic gates
may have one or more input, with only one output. The output is active only for certain input
combinations, depending on the type of the logic gates.
There are three famous types of logic are as follows:
Figure 2.1 Types of Logic Gates
The most popular logic gates are AND, OR, XOR, NOT, NAND, NOR, and XNOR.
Table 2.3 Logic gates
Logic Symbol Logic Truth table
gates
Expression
NOT YA AY
01
10
AND Y AB ABY
000
010
100
111
ABY
000
OR Y AB 011
101
111
Prepared by: NUR WAHIDA JANUDIN [PKK\JKE\2016] 35
DIGITAL ELECTRONIC
BOOLEAN OPERATION
Logic Symbol Logic Expression Truth table
gates
NAND ABY
NOR 001
EX-OR Y AB A B 0 1 1
EX-NOR 101
110
ABY
001
Y A B AB 0 1 0
100
110
Y AB ABY
Y AB AB 000
011
101
110
Y AB ABY
Y A.B A.B 001
010
100
111
2.3 Universal Gates
A universal gate is a gate which can implement any Boolean function without need to
use any other gate type. The NAND and NOR gates are universal gates. In practice, this is
advantageous since NAND and NOR gates are economical and easier to fabricate and are the
basic gates used in all IC digital logic families.
NAND gates Table 2.4 Universal gates NOR gates
Logic gates
Y A A A NOT
Y A A A
Prepared by: NUR WAHIDA JANUDIN [PKK\JKE\2016] 36
NAND gates DIGITAL ELECTRONIC NOR gates
BOOLEAN OPERATION
Logic gates
Y AB AB AB AND
Y A B AB
OR
Y AB AB AB
Y AB A B
2.4 Combinational Logic Gates
Combinational logic circuit are made up from basic logic NAND, NOR or NOT gates that
are “combined” or connected together to produce more complicated switching circuit. It can be
very simple or very complicated and any combinational circuit can be implemented with only
NAND or NOR gates.
Example:
Write the logic expression for the circuit given.
Logic diagram Logic Expression
X AB B
X AB B CBC
Prepared by: NUR WAHIDA JANUDIN [PKK\JKE\2016] 37
DIGITAL ELECTRONIC Logic Expression
BOOLEAN OPERATION
X AB A B
Logic diagram
X ABC A BAC
2.5 Boolean Algebra
Boolean Algebra can help to minimize Boolean expression and to simplify logic circuits. Boolean
Algebra supports the basic laws of ordinary algebra. The basic laws of Boolean Algebra are
given as:
Table 2.5 Basic Law of Boolean Algebra
A0 A
A 1 1
A A A
A A1 Boolean Identities / Basic Law
A0 0
A1 A
A A A
A A 0
A A Commutative Law
X Y Y X Associative Law
X Y Y X Distributive Law
De Morgan’s Law
ABC ABC
A B C A B C
X Y Z X Y Z X Y Z
W X Y Z WY WZ XY XZ
A B A B
A B A B
Prepared by: NUR WAHIDA JANUDIN [PKK\JKE\2016] 38
DIGITAL ELECTRONIC
BOOLEAN OPERATION
ABC ABC Associative Law
A B C A B C Distributive Law
X Y Z X Y Z X Y Z
W X Y Z WY WZ XY XZ Special Rules
A B A B Involution Law
A B A B
Use Basic Law:
A AB A
A A 0
A AB A B A A A
A A1
A (AB) A A A A
A A B AB Use Basic Law:
A A A
Example: A11
Simplify the expression by using Boolean operation. Use De Morgan’s Law:
A B A B AA AB AB BB A B A B
A B A B
0 AB AB B
BA A B
BB
B
A BA C AA AC AB BC
A AC AB BC
A1 C AB BC
A(1 B) BC
A BC
X YZ X Y Z
X Y Z
XY X Z
X Y Z
Prepared by: NUR WAHIDA JANUDIN [PKK\JKE\2016] 39
DIGITAL ELECTRONIC
BOOLEAN OPERATION
2.6 Boolean Expression
The concept of minterm and maxterm allows us to introduce very simple notations to express
any Boolean expression. Generally, a minterm represent a sum term of literals for output 1,
while the maxterm represents a sum term of literals for output 0.
Example of how minterm and maxterm can be generally produced from a truth table of 2-
variable expression:-
XY Minterm Maxterm
00 X Y
01 X Y
10 X Y X Y
11 X Y X Y
X Y X Y
Example of how minterm and maxterm can be generally produced from a truth table of 3-
variable expression:-
XY Z Minterm Maxterm
00 0 X Y Z X Y Z
00 1 X Y Z
01 0 X Y Z X Y Z
01 1 X Y Z X Y Z
10 0 X Y Z X Y Z
10 1 X Y Z X Y Z
11 0 X Y Z X Y Z
11 1 X Y Z X Y Z
X Y Z
Let’s produce a minterm and maxterm from the truth table below.
XY Z F Minterm Maxterm
0 X Y Z
00 0 0 X Y Z X Y Z
1
00 1 X Y Z X Y Z
1 X Y Z
01 0 X Y Z
0
01 1
0
10 0
0
1 Z0 1
1
11 0
11 1
Prepared by: NUR WAHIDA JANUDIN [PKK\JKE\2016] 40
DIGITAL ELECTRONIC
BOOLEAN OPERATION
The output of minterm (sometime called the Sum of product, SOP):
F X Y Z X Y Z X Y Z
The output of maxterm (sometime called the Product of sum, POS):
F X Y Z X Y Z X Y Z X Y Z X Y Z
Boolean expression are used to describe any Boolean function which contains Boolean constant
and variables. There are two types of expressions:
i. Sum of Product expression (SOP): is one or more product terms (AND gate) connected
by OR gate operator.
ii. Product of sums expression (POS): is one or more sum (OR) terms connected by AND
operator.
Types of Expression Example
Sum of Product (SOP)
FX ,Y, Z XY YZ XYZ
Product of Sum (POS)
FX ,Y, Z X Y Y Z Y Z
Converting SOP to Truth Table
Examine each of the products to determine where the product is equal to a 1.
Set the remaining row outputs to 0.
Prepared by: NUR WAHIDA JANUDIN [PKK\JKE\2016] 41
DIGITAL ELECTRONIC
BOOLEAN OPERATION
Converting POS to Truth Table
Opposite process from the SOP expressions.
Each sum term results in a 0.
Set the remaining row outputs to 1.
The standard SOP Expression
All variables appear in each product term.
Each of the product term in the expression is called as minterm.
Example:
FA, B,C ABC ABC ABC
Minterm Minterm Code Minterm Number
ABC
010 m2
ABC
ABC 110 m6
011 m3
In compact form, F (A, B, C) may be written as:
FA, B,C m2 m3 m6 m2,3,6
Prepared by: NUR WAHIDA JANUDIN [PKK\JKE\2016] 42
DIGITAL ELECTRONIC
BOOLEAN OPERATION
The standard POS Expression
All variables appear in each product term.
Each of the product term in the expression is called as maxterm.
Example:
FA, B,C A B C A B C A B C
Minterm Minterm Code Minterm Number
A B C 101 M5
A B C 001 M1
A B C 100 M4
In compact form, F (A, B, C) may be written as:
FA, B,C M1 M 4 M5 M 1,4,5
2.7 Karnaugh Map (K-Map)
K-Map is a method of mapping Boolean expression or truth table onto a special matrix
that provides a systematic method to obtain simplified Sum of Product (SOP) Boolean
expressions.
A K-map consists of a grid of squares/cells with variables will have 2 in one map. There a rules
that we have to follow to minimize/ looping a K-Map. The rules which are:
It must be grouped from maximum to minimum
Only focus to the square with logic 1
Draw a loop around the squares with logic 1 (may NO include any cell containing a zero)
Get the simplified equation from each loop (AND) and then total it (ORed the AND). This
is the SOP expression.
Group must content 1, 2, 4, 8 or in general 2n cells. That’s if:
o n = 1, a group will contain two 1’s since 21 = 2,
o n = 2, a group will contain four 1’s since 22 = 4, each group should be as large as
possible.
The map is made up of a table of every possible SOP using the number of variables that are
being used.
If 2 variables are used then a 2X2 map is used
If 3 variables are used then a 4X2 map is used
If 4 variables are used then a 4X4 map is used
Prepared by: NUR WAHIDA JANUDIN [PKK\JKE\2016] 43
DIGITAL ELECTRONIC
BOOLEAN OPERATION
2 - variables
3 - variables
4 - variables
K-Map Loping Elimination
Looping elimination in a K-map can eliminates the variable that appears in complemented and
un-complemented form.
Right Wrong
Prepared by: NUR WAHIDA JANUDIN [PKK\JKE\2016] 44