0% found this document useful (0 votes)
2K views285 pages

DLD Book

Uploaded by

paakhipriya10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
2K views285 pages

DLD Book

Uploaded by

paakhipriya10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 285
; Digital | Electronics for MSc (Physics) and BE ( Electronics) ee Dictimer Scenes nd achsogy fields. New research and @3, oye S20 lematon oon 9 Mecha ben navng mmr Mean vile breparing the male ior hs bono hin, ail efor have been made to enon, Moun, ‘accuracy ofthe mater yet ny eau trom moh hove boon Buble, ir andthe cuore 21. hy fesponsible for any inadverteny inaccuracies. sHOn Digital Electronics ISBN: 978-81-239-2374-1 Copyright © Author and Publishers First Edition: 2014 Reprint: 2019 reserved No pat of his book may be reproduced otransmittedin any former by any means, electronic or aa ean goroocapyng fect o oy romaton #orage ardretievl stem wihout pemason In witeg fom the outhor and he publisher eked by Ssh Kiera Jon ond produced by Vorun Jain for (CBS Publishers & Disbutons Pvt Lic 14619/X)Pronioa Sree, 24 Arsor Rood, Daryagan, New Delhi 110002, India. Ph 23287059, Z3066861.23266867 West’ www.cbspc.com Fer O11-23209014 ‘e-mali deti@cbspd com: cbspubs@atelmal in. Corporate Office: 04 FI. ndusticl Area Patporganj. Defi 110072 Prmatarsd — Far AGL eal pushing @cbspd com: [email protected] Branches * ‘Bengalunt SeemaHouse 2975, 17th Cross KR Rood. SBoncxonkar’?nd Stage Bengaluru 540070. Kanata me sevaoaemnerane fax: 1-80 267680 ‘mot: pongolrw@cbupd com * Chennat: 7 Joberoyo Steet Snency Nagar, Chennai 600030, Tori Nadu anti ase aes for s-acos2iis mat [email protected] * Koch: 42/132, 1326 Power Howse Road, Opp KSEB Power House, Einakuiom 682018, Kochi, Kerola re aseannt 8 fox eects mol toch@cbspd com * olka: 6/8, Ground Foo, Rameswar Shaw Rood. Kolkata-700014, West Bengal Pr so sh.ze zane ‘emo Kotat08cbInd com * Mumbai 83-C,O'E Moses Rood Worl Mural 400018, Maharashtra Pr sh. eruore foe sma mol: mumbai@cbipd com Representatives 1 Mpa! 08319310552 + Bhubaneswar 09911037572 > Wyderabod 0.98851 75004 {shastand 09811541605 + Nagpur 09021734563 = Pome 0.9334189340 + Rne 09628451994 + Uoraknand 09716462469 + Dhaka (Bangladesh) 01912003485 Printed at India Binding House, Noida (UP), India r—sOsN Preface ‘The present book is aimed to serve as a textbook for MSe (physics) and engineering students of all the Indian colleges and Universities. The book has been divided into twelve chapters. ‘The first chapter begins with introductory concepts of digital electronics This is followed by number systems in Chapter 2. Chapter 3 describes various useful binary codes. Chapter 4 is on Boolean algebra and logic circuits based on various logic gates. Chapter 5 describes various logic families. Chapter 6 discusses combinational and arithmetic logic circuits such as adders and subtractors, comparator and parity generator and checker. Chapter 7 explains various types of flip-flops. Chapter 8 describes shift registers and their working. Chapter 9 deals with asynchronous and synchronous counters and their applications. Chapter 10 is on data processing circuits which include decoders, demultiplexers, multiplexers, encoders, read only memory (ROM), code converters, various types of ROMs, random access memory (RAM), programmable array logic and parity checker and generator. Chapter 11 explains analog to digital and digital to analog converters. Chapter 12 describes 8085 and 8086 microprocessors. The chronology of the contents has been so arranged as to render the readers an easy grasping of the subject. 1 am grateful to Prof ON Srivastava (Emeritus Professor, BHU, Varanasi) and Prof DP Tiwari (Head, Department of Physics, APS University, Rewa) for boosting my morale. | am also thankful to Prof SP Agrawal and Prof SK Nigam (Ex-VCs and Heads, Department of Physics, APS University) Prof AP Mishra and Prof SL Agrawal, Dr PK Rai (Computer Centre), Prof Navita Shrivastav and Prof RK Katare (Computer Science Department), Dr CM Tiwari and Dr VK Mishra (lecturers in physics, guest faculty) for providing moral encouragement Tam thankful to the authors and publishers of various books consulted by me, including those enlisted in the References. Further, I wish to thank Mr Dharmendra Kumar Saxena for preparing the typescript and Mr YN Arjuna (CBS) for bringing out the book in a short time Although utmost care has been taken to minimise errors, suggestions for further improvement and pointing out errors by the readers would be highly welcome. AK Saxena Preface 1, Introductory Concepts Contents 1 1.1 Introduction 7 oo ees 1.2 Analog and Digital Signals) 1.3 Analog and Digital Systems 1 1.4 Digital Signals 2 1.5 Elements of Digital Logic 2 1.6 Functions Performed by Digital Logic Systems 3 1.7 Data Transmission (Parallel and Serial Transmission) 5 1.8 Logic Gates for Digital Operations 1.9 Digital Integrated Circuits 1.10 Levels of Integration 8 1.11 Popular ICs for Logic Gates 9 1.12 Basic Blocks of a Microcomputer 10 1.13 Typical Microcomputer Architecture 1/ 1.14 The Computer 17 1.15 Basic Organization of a Computer System J2 1.16 Classification of Computers /4 Exercise 16 2. Number Systems 7 2.1 Introduction 17 2.2 Number Systems 17 2.3 Decimal Number System 18 2.4 Binary Number System 18 2.5 Octal Number System 19 2.6 Hexadecimal Number System /9 27 Converting from One Number System to Another 19 2.8 Signed Binary Numbers 23 2.9 One's Complement Representation 23 2.10 Two’s Complement Representation 2 211 Floating Point Representation 24 2.12 Counting in Binary 24 2.13 Two's Complement Arithmetic 24 2.14 One's Complement Arithmetic 25 Exercise 26 3. Binary Codes a ce 27 3.1 Weighted Binary Codes 27 3.2 Alphanumeric Characters in BCD 28 3.3 Reflective Codes 29 34 Sequential Codes 29 Dit viil Digital Electronics ie Code (EBCDIP) 37 35 Non-Weighted Ce + merchange 36 Coded Decima 3.6 Extended Binary a Error Detecting Code / 33 Comecting Code 32 3.9 The ASCII Code 32 Exercise 33 4, Boolean gore an ocr sels O08 DOS —_ , , saa | 41 Introduction M 42 Logic Operations 34 43 Boolean Expression 2. The Principle of Duality 35 415 Describing Logic Circuits Algebraically 35 s 4.6 Implementing Circuits from Boolean Expressions 4.7 Axioms and Laws of Boolean Algebra 36 48. De Morgan's Theorems 39 49. Implications of De Morgan's Theorems 39 4.10 Universality of NAND and NOR Gates 39 TIL Reducing Boolean Expressions 42 4.12 Sum of Products Method 43 4.13 Product-of-Sums Method 44 4.14 Boolean Functions 45 4.15 Canonical forms for Boolean Functions (Minterms and Maxterms) 45 4116 Sum-of:Products in terms of Minterms of a Truth Table 47 17 Productof-sumsin term of Maxterms for a Truth Table 47 4.18 Truth Tables to Kamaugh Maps 48 4.19 Pairs, Quads and Octets in Kamaugh map 49 4.20 Kamaugh Method of Simplification 50 4.21 Overlapping Groups 57 4.22 Eliminating Redundant Groups 51 4.23. Designing using NAND gates 55 4.24 Design using NOR Gates 56 4.25 Don't Care Conditions 58 4.26 Hybrid Logic 58 4.27 Enable and Inhibit Circuits 59 4.28 Wired-OR and Wired-AND Gates 59 oe Lei 7 Logical Functions or Karnaugh Map 60 linimization of Logic i i Fi ‘31 Barca Caine ies re in terms of Minterms/Maxterms 6! Five-anc = ae id Six-variable K-Maps 63 5. Logic Families 68 5.1 Introduction 68 5.2 Digital IC Specification Termi \n Terminol 53) Dialer . Contents ix 5.4 Diode Logic OR Circuit 7) 5.5 Diode Logic AND Circuit 72 .6 Emitter Follower Logic for an OR Circuit 73 .7 An Inverter Circuit using Transistors. 73 5.8 The NAND and NOR Diode Transistor Logic (DTL) Gates 73 5.9 Modified (Integrated-Circuit) DTL NAND Gate 74 5.10 Direct Coupled Transistor Logic (DCTL) 74 5.11 Resistor Transistor Logic (RTL) 75 5.12 AnRTL Buffer and Active Pull Up 76 5.13 High Threshold Logic (HTL) 76 5.14 Standard TTL NAND Gate 77 5.15 Device Numbers. 80 5.16 5400/7400 TTL Series 8/ 5.17 Emitter Coupled Logic 62 5.18 Interfacing ECL and TTL 83 5.19 TTLAND-OR-INVERT Gate 84 5.20 Tristate TTL 85 5.21 Integrated Injection Logic (IIL) 87 5.22 Unipolar Logic Families 87 5.23 PMOS and NMOS Circuits 88 5.24 CMOS Circuits 88 5.25 $4C00/74C00 CMOS Series 90 5.26 Interfacing CMOS and TTL 9/ 5.27 Interfacing CMOS and TTL ECL 93 Exercise 93 6. Combinational and Arithmetic Logic Circuits 94 6.1 Combinational and Sequential Circuits 94 6.2 Adders 94 6.3 The Half Subtractor 97 6.4 The Full Subtractor 98 6.5 A Parallel Binary Adder 100 6.6 Adder with Look-Ahead, Carry 10/ 6.7 — Serial Adder 102 68 BCD Adder 103 6.9 IC Adders 103 6.10 Cascading IC Parallel Adders 104 6.11 Two's Complement Addition and Subtraction using Parallel Adders 104 6.12 Digital Comparator 105 6.13 Parity Checker/Generator 106 Exercise 108 7. Flip-Flops 109 7.1 RS Latches 109 7.2 Clocked SR Flip-Flop 7.3 The Effect of Asynchronous Inputs ‘Preset’ and ‘Clear’ 112 es xii Digital Electronics 1 - Analog to Digital (A/D) and Digital to Analog (D/A) Converters 10.26 Commercially Available Lu 189 10.27 Programmable ROMs / 10.28 Erasable PROMs /90 129 ROM ICs 190 i. 30 Internal ROM Structure 190 1031 ROM Access Time 192, 10.32 Classification of Mens 2 . ed Device Memory : i934 Car. Memory (RAM) using Semiconductor Flip-Flops. 194 10.35 Content Addressable Memory 196 10.36 Programmable Array Logic (PAL) 197 10.37 Programmable Logic Device (PLD) 198 10.38 Parity Checkers and Generators 202 10.39 Even/Odd Parity Generators and Checkers 203 10.40 Four Bit Parity Checker/Generator 204 10.41 Applications of Parity Generation and Checking 206 10.42 Comparison of Various Types of ROMs 206 10.43 Static and Dynamic Random Access Memories 206 10.44 RAMIC 209 10.45 Memory Expansion 209 Exercise 2/2 214 11.1 Introduction 214 11.2. Digital to Analog Conversion 2/4 11.3 Weighted-Resistor D/A Converter 215 / 11.4 Implementation of the Switching Device (SPDT $ 11.5. Binary Ladder 220 ee 11.6 A DIA Converter using R-2R Ladder 222 11.7 4-Bit D/A converter 222 11.8 Specifications for D/A Converters 224 11.9 Sample and Hold Circuit 225 11.10 Analog-to-Digital Converters 227 Wi Parallel-Comparator A/D Converter 227 ie ie Converter using a Staircase Ramp 228 a 0 Conenion sing Successive Approximation Method 229 hod for A/D Conversion usi \PPrOXimati IIS A 3.Bit Successive Amon ee ADD Conmention sing a Programme, 250 verter eer Contents xiii 142. The Microprocessors : 12.1 Introduction 238 12.2 Computer Hardware 239 12.3. Definition of a Microprocessor 239 12.4 Computer Architecture 240 12.5 Bus Buffer 247 12.6 Bidirectional Bus Buffer 24/ 12.7. An-8-Bit Bidirectional Data Bus 242 12.8 Three-State Bus Control for Registers 243 12.9 Interfacing of Memory with Microprocessor (UP) 245 12.10 Read and Write Operations 246 12.11 Microprocessor Architecture 246 12.12 Microprocessor Organization 250 12.13 Internal Organization of a Typical Microprocessor 251 12.14 Input-Output Organization 252 12.15 Microprocessor Operation 255 12.16 The Memory 257 12.17 The 8085 (An Introduction) 260 12,18 Pin Configuration of Intel 8085 262 12.19 The 8086 Microprocessor (An Introduction) 264 12.20 Pin Configuration of 8086 266 12.21 Need for Programming Languages 267 12.22 High Level Languages 267 Exercise 267 References Index 269 271 ity Introductory Concepts 1.1 INTRODUCTION All of us are familiar with the impact of modern computers, communication systems, calculators. watches, etc. on the society. These are all based on the integrated circuits (ICs) whose advent became possible because of the tremendous progress in semiconductor technology in the recent past. The operation of these systems is based on the principles of digital techniques and digital electronics. Digital electronics involves circuits and systems in which there are only two possible states that are typically represented by (two) voltage levels. In digital systems, two states are used to represent numbers, symbols or characters. 1.2 ANALOG AND DIGITAL SIGNALS ‘There are basically two types of signals: analog and digital. (a) Analog signals: Analog signal is defined as a voltage or current whose size is proportional to the quantity it represents. Analog signal is continuous and has infinite set of possible values. (b) Digital signal: A digital signal is one which changes between two discrete levels of voltage. These changes are very sudden, Figure 1.1 illustrates the comparison between analog signal and digital signal. The most positive fixed voltage represents | state. Similarly, most negative voltage represents 0 state. Digital signals represent the real quantities by means of groups of 0 and 1 Group of Os and Is in some orderly format can represent unlimited information (a) Analog signal Voltage Time (b) Digital signal Fig. 1.1: Analog and digital signals 4.3 ANALOG AND DIGITAL SYSTEMS ‘The different electronic system can be classified as: (a) Analog systems: An analog system is one which contains devices that manipulate physical quantities which are represented in analog form. In such a system, the quantities can vary over a continuous range of values. Commonly used analog systems are TV receiver, telephone systems and tape recording, and play-back equipment. (b) Digital systems: Digital system consist of devices designed to handle physical quantities that Advantages of Digital systems Now-a-days, most ofthe applicators ere tse digital methods to perform Moethods. The main performed cartier by wing analog advantages of digital systems are: (]) They are easier to design y Gi) Information can be stored very €25"1° (iii) Greater accuracy and precision. Gv) Operation canbe programmedty asetof stored instructions. (v) Digital circuits are less affected by noise. (vi) Can be fabricated on IC chips of lesser area as ‘compared to analog circuitry. . Limitations of digital systems: Most physical ‘quantities are analog in nature and iti these quantities that are inputs and outputs that are being monitored, processed and controlled by a system. To take advan- tage of digital techniques, the analog inputs are required to be converted to digital form. These are then processed digitally and converted then back to analog form. The need for conversion between analog and digital forms of information is a drawback because of the added complexity and expense and it also Tequires extra time. However, in many applications, these factors are overweighed by the added advan- tages offered by digital circuits. Now-a-days, both digital and analog techniques are simultaneously of use in some systems. 1.4 DIGITAL SIGNALS As mentioned in section 1.2, a digital signal has t discrete levels or values. Two diferent me of digital signals are shown in Fig. 12 In each cae there are two discrete levels. These levels can he Tepresented using the tems LOW and HIGH, In Fig. 12a lower ofthe two levelshas been designted 4s LOW and the higher a high level. On the ether hand, in Fg 1.2b, higher ofthe wo levels has ben designated as LOW level andthe lovers HIGH lean Digital systems using the representation of signa shovn in Fig, 1.2a ae sid employ pone ene in electronics and those using representation of, Signy tem : al " 1.2bare said toemploy negative loi Shon, : ‘Viton inFig- Fig. 1.2: Digital signal representations: (a) positive log (b) negative logic 7 (Unless otherwise specified, we shall be dealing with positive logic system) The two discrete signal levels HIGH and Low can also be represented by the binary digits | and0 respectively. A binary digit (0 or 1) is referred toasa bit. Since a digital signal can have only one of te two possible levels 1 or 0, the binary number system can be used for the analysis and design of digit systems. The two levels (or states) can also be designated as ON and OFF respectively or TRUE and FALSE. The concept of binary number system was introduced by George Boole to study the mathematical theory of LOGIC which developed later as Boolean algebra. In digital circuits, two voltage levels represent the two binary digits | and 0 and are designed to produce Output voltages that fall within the prescribed 0 and | Voltage ranges such as those defined in Fig. 12. The digital circuits are designed to respond to te ‘put voltages within the defined 0 and I ranges- 1.5 ELEMENTS OF DIGITAL LOGIC The term logic refers to something which can b ‘easoned out. In many situations, the problems a Processes that we encounter, can be expressed i” ‘orm of logic functions, Since these functions af? false of yes/no statements digital circuits with their two slate characteristics are extremely useful. Several logic statements when combined, form logic functions. These logic functions can be formulated mathematically using Boolean algebra. There are four basic logic elements using which any digital-system can be built. They are the three basic gates-NOT, AND. and OR, and a flip-flop. In fact, a flip-flop can be constructed using gates. So, we can say that any digital circuit can be constructed using only gates. In addition to the three basic gates, there are two universal gates called NAND and NOR. They are called universal gates because any circuit can be constructed using only NAND gates or only NOR gates. There are two more gates called XOR and XNOR. Using logic gates and flip-flop, more complex logic circuits like counters, shift registers, arithmetic circuits, comparators, encoders, decoders, multi- plexers, demultiplexers, memories, etc. can be constructed. More complex logic functions, then, can be combined using these to form complete digital systems to perform specific tasks. 1.6 FUNCTIONS PERFORMED BY DIGITAL LOGIC SYSTEMS Many operations can be performed by combining logic gates and flip-flops. Some of these are arith- metic operations, comparison, code conversion, encoding, decoding, multiplexing, demultiplexing, shifting, counting and storing. These well be dis- cussed in detail in later chapters. The block diagram operations are given below. 1.6.1 Arithmetic Operations The basic arithmetic operations are addition, substraction, multiplication and division. The addition operation is performed by a digital logic circuit called adder. Its function is to add two numbers addend (A) and augend (B) with a carry input (CI) and generate a sum term ($) and a carry output term (CO). Figure 1 3a is a block diagram of an adder. It illustrates the addition of the binary equi- valents of 8 and 6 witha carry input of 1, which results in a binary sum term 5 and a carry output term |. ‘The arithmetic operation of subtraction can by performed by a digital logic circuit called the subtractor. Its function is to subtract subtrahend (A) Introductory Concepts 3 Binary{6 —> a S [=> Binary input | sum => 4 digits |? 8 Adder Corry 4; —»} co}—>1 input __“) 2) «JDL. Binary Binary) 3 —A A OL—> difference input | 5 Fig. 1.3 The adder (a) and the subtractor (b) from minuend (B) considering the borrow input (BI) and to generate a difference term (D) and a borrow output term (BO). Since subtraction is equivalent to addition of a negative number, subtraction can be performed by using an adder. Figure 1.3b is a block diagram of a subtractor. It illustrates the subtraction of the binary equivalent of 3 from the binary equi- valent of 8 with a borrow input of 1. which results in abinary difference term 5 and a borrow output term | The arithmetic operation of multiplication can be performed by a digital logic circuit called the multiplier Fig. 14a. Its function is to multiply ‘multiplicand (A) by multiplier (B) and generate the product term (P). Binary ( ®—>) A | Binary input Multiplier P[—> product digits 24 3 b | (a) Binary (29 [=> Binary ‘input quonent 9 digits 3 > Remainder 2 (b) Fig. 14: (a) the multiplier and (b) the divider Since multiplication is simply a series of additions with shifts in the positions of the partial products, it can be performed using an adder. 4 Digital Bectonics on of fr sedge a circuil cal diet 7 (Fig. 1.40). Division can also be pet ) ies of ved a series 0! adder itself, since division = 4 cio ibiractions, comparisons ane» ea saa didend (A) dior (B) a Eee quotient (Q) anda remainder (R) 1.6.2 Encoding Encoding is the proce: division can be ) yet Fig. 1.6: (a) the multiplexer and () the demult 1.6.5 Demultiplexing Demultiplexing operation is the inverse 0! plexing. Its the process of switching intr, from one input line onto several outp¥t side demultiplexer ig a digital circuit that OK input and distributes it over several OMY ys demultiplexer shown in Fig. 1.6b, if +B (ort connected to output a for time ty, 10 00 Pies 4,10 output C for time ty and to outPUt fig the output will be as shown in the figure illustrates a 1-to-4 demultiplexer. fl J Oe t—t— 1.6.6 Comparison ‘A logic circuit used to compare two quantities and give an output signal indicating whether the two input quantities are equal or not, and if not, which one is BCA Bt + High) Comparator Binary A=BL> Low} Outputs inputs 68 ABE > Low Fig. 1.7: Comparator HIGH level indicates that A is greater than B (8 > 6) Introductory Concepts § flop is shifted to the flip-flop to its right. Figure 1.86 sherws the shifting out of data from the register. The content of the last flip-flop is shifted out and lost 1.6.8 Counting A logic circuit used to count the number of pulses inputted to it is called a counter. The pulses may represent some events. In order to count. the counter must remember the present number, so that it can go to the next proper number in the sequence when the next pulse comes. So storage elements (i.e. flip-flops) are used to build counters too. Figure 1.9 shows the block diagram of a counter. 1011} 0} 0}0/0 wi-F 1/0 10/0 ee ce ee inital state After the first clock pulse After the second clock oulse 1—0/}1}/1}0 pete ee Afler the third clock pulse After the fourth clock pulse (2) Storage of data stols{sf > [olrjo}s fe: folo] sfo ben Initial state ‘After the rst clock pulse After the second clock pulse o}ofols Po [ofolo] ob ron ‘ter the third cock pulse Aer the fourth clock pulse (b) Transfer of data Fig. 18: Storage and transfer of data greater, is called a comparator. Figure 1.7 shows the block diagram of a comparator. The binary represent- ations of the quantities A and B to be compared are applied as inputs tothe comparator. One ofthe outputs AB goes HIGH depending on the ‘magnitudes of the input quantities. 1.6.7 Storage Storage and shifting of information is very essential in digital systems, Digital circuits used for temporary Storage and shifting of information (data), are called registers. Registers are made up of storage elements called flip-flops. Figure 1.84 shows the shifting or loading of data into a register made up of tour fip- flops. After each clock pulse, the input bit is shifted into the first flip-flop and the content of each flip- Coded output Indicates the umber of pulses inputted SUL | comm 3 | 1.7 DATATRANSMISSION (Parallel and serial Transmission) {Information (data) is frequently required to be trans- ‘mitted trom one place to another in any digital system, The information is in binary form and generally represented as voltages at the outputs ofthe sending Citcut that are connected tothe inputs ofa receiving itcuit, Two basic methods for transmission of digital ‘information are serial and parallel transmissions, ITI 8 ec 6 Dra Be er HUNT Figure 1.10 shows how wn le istran td from cicuitAOBUSREPT ted AG significant bit (MSB) rt Aas 4 seni of wastes all S bits of information are inp Tepes ne coe ie pert it be transmitted simultaneously Tse, Li, a | ne 8; Circuit A | ont Stee |, 8 | at 5 | si —_ ft Fig. 1.10: Parallel transmission Figure 1.11 shows how serial transmission is There is only one connection from circuit A to circuit B. Information is transmitted a bit at a time over the one connecting line. Me Circuit A ~ p, CrcutB Fig. 1.11 Serial transmission ‘The transmission using parallel scheme is fast as compared to serial method as all bits are transmitted simultaneously in parallel transmission. On the other hand, parallel scheme requires more connecting lines between transmitter and receiver. 1.8 LOGIC GATES FOR DIGITAL OPERATIONS A logic gates most fundamental digital circuit. Is simply a device that has two or more inputs and one output Is output willbe etherhigh orlow depending upon the combination of high and low inputs used and the type of gate used. Inputs to the gate are represented by Boolean variables A, B,C, ete. and the output by Boolean variable Y. The function of the fale is represented by Boolean expression and the working o operation ofthe logic gate is represented by a truth table. There ae sx types of lpi gate (ii) Nor (i Gi) AND (vii) XNOR ) OR \) NOR (vi) XOR Several logic gal network oF digital circuit. hy @oR Gate : If A, B and Y are B, Oolean then, for an OR gate Vig, Y=AorB means that Y is 0 only if inputs A and B else Y is ‘1’ This is denoted by Y=A+B The truth table is given in Table 1.1 Ae boyy v Table 1.1: Truth table for OR Operation Input Output A B Y r/o 0 0 0 0 1 1 1 0 I 1 1 1 Se {Atruth table shows how the logic circuits ouput respon, to various combinations of logic levels at inputs) For more than two input variables to an OR gi, the output is Y=A+B+C+D. Thus OR operation is implemented using OR gue OR gate is a circuit that has two or, more inputs and ‘whose output is equal to the OR sum of the inputs Figure 1.12 shows the symbol for two input OR gat. The inputs A and B are logic voltage levels and outpt Y is logic voltage es e Y=A+B Fig. 1.12: Logic symbol for an OR gate level whose value is the result of the OR operstst on A and B, ic. Y =A +B. (i) AND Gate: If A, B and Y are Boolean variables then Y=AANDB poet ‘means that Y is one (1) only if A and B are > oy otherwise Y is zero. This function is ls0' y Y=AB ios ‘AND operation can be implemented by Us". circuit known as AND gate. AND gate iS up More inputs and one output which is ea! ° J product of the inputs. The truth table and logic symbol for two input AND gate is shawn in Fig. 1.13. Input Output ascol> =o-cle Ao) (o) Fig. 1.13: AND gate (a) truth table and (b) logic symbol Itcan be seen from the truth table, AND gate output is high (1) only when all its inputs are high (1). For all other cases, the AND gate output is low (0) (iii) NOT Gate: The NOT operation applied to a Boolean variable A, generates its logical inverse denoted by A, i. : Y=A This operation is implemented using a logic circuit ‘known as inverter. It has one input and one output. ‘The output logic level of inverter’s output is always opposite to the logic level ofits input. The truth table and logic symbol are given in Fig. 1.14. Input Output A Y 0 | 1 1 ° (o) Fig. 1.14: NOT gate (a) truth table and (b) logic symbol (iv) NAND Gate: If A, B and are Boolean variables, then Y=AB ie. first the two variables are ANDed, and then inverted, as indicated by bar over the AND expression. Introductory Concepts 7 ‘The truth table for two input NAND gate and its symbol are given im Fig. 1.15 Input Output + ol@ Fig. 1.15: NAND gate (a) ruth table and (b) logie symbol From the truth table. it can be seen that NAND gate output is the exact inverse of AND gate for all possible input combinations (¥) NOR Gate: If A. B and Y are Boolean variables, then Y=A+B which means that the two variables are ORed, and then inverted, Thus this operation is equivalent to OR followed by inversion. The truth table and logic symbol are given in Fig. 1.16. Output io A a y o oO 1 0 1 ° 1 o 0 : 2 “ Ma => YAR (b) Fig. 1.16: NAND gate (a) uth table and (b) logic symbol From the truth table, it ean be seen that NOR gate Output is exact inverse of OR gate output for all possible input conditions, (vi) Exclusive OR Gate (XOR Gate): The XOR operation gives high output if one of the inputs is ee 8 Digtai Bectronics high. The Boolean operation for XOR operation ca be written as Y=a@B =AB+AB an This operation ao be implemented using van AND, OR and invert gates ‘The symbol and tru table for XOR gate is given in Fig. 1.17. Input Output a 8 ¥ 0 ° : 0 1 : 1 0 1 t 1 0 a @ sa ° y=AeB @) Fig. 1.17: XOR gate (a) truth table and (b) logic symbol (vii) Exclusive NOR Gate: The Ex-NOR operation gives high output for both inputs low or both inputs high. The Boolean expression is “Y =A@B=AB+AB This operation is implemented using basic AND, OR and invert gates. The basic truth table and symbol are shown in Fig. 1.18. Input Output wecsl< | I @) a Y=A@B == cel> (0) Fig. 1.18: Ex-NOR gate (a) truth table and (b) logic symbol 1.9 DIGITAL INTEGRATED CIRCUITS. All the logic functions described (above in section 1.6) and many more are available in the integrated circuit form (IC) form. Modem digital systems utilize ICs in their design. A monolithic Ici circuit that is constructed entirely ae 1M ele t of semiconductor material (usyatiy es Single substrate which is commonly referre wen) Gl ICs have the advantages of Joy, ai Sa sanallersizeand high reliability oye de” Pm, ICs are principally used to Petfoim ety circuit operations such as information prey. cannot handle very large voltages or unre heat generated in these tiny devices would ayy temperature rise beyond acceptable limits st in bumning out of ICs. Ut ICsmaybe classified as analog and digi ICsare complete functioning blocks as no adi components are required for their Operation, : output may be obtained by applying the inp : ‘output isa logic level 0 or 1. Te Foraralog ICs extemal component ae rng Digital ICs are a collection of resistors, diodes al transistors fabricated on a single chip. The Chip is enclosed in a protective plastic or ceramic package from which pins extend for connecting IC to city devices. There are two main types of packages: du. in-line package (DIP) and the flat package 1.10 LEVELS OF INTEGRATION Digital ICs are often categorized according to tht circuit complexity as measured by the number of equivalent logic gates on the substrate. There ae currently five standard levels of complexity Small Scale Integration (SSI): The least complex digital ICs with less than 12 gate circuits on a singe chip. Logic gates and flip-flops belong to ths category, Medium scale Integration (MSI): With 12 10% fate circuits on a single chip, the more complex logic circuit such as encoders, decoders, countes and registers, multiplexers, arithmetic circuits. ¢ belong to this category. Large Scale Integration (LSI): With 100 10 99 fate circuits on single chip, small memories small microprocessors fall in this category. Very Large Scale Integration (VLSI): complexities ranging from 10,000 to 99.9% circuits per chip fallin this category. Large M™" tis and large microprocessor systems, etc. belong" category. "hy ‘Sing | Ics wilh alle os Ultra Large Scale Integration (ULSI): With complenities of over 100,000 gate circuits per chip, very large memories and microprocessor systems and single chip computers come in this category Digital ICs can also be categorized according to the principal type of electronic component used in their circuitry. They are- (a) Bipolar ICs - which use BIT's (b) Unipolar ICs - which use MOSFET's Several integrated circuit fabrication technologies are used to produce digital ICs. Presently. digital ICs, are fabricated using TTL. ECL., IIL. MOS and CMOS technologies. Each differs from the other in the type of circuitry used to provide the desired logic, operation. While TTL, ECL, and IL use bipolar transistors as main circuit elements, MOS and CMOS use MOSFETS as main circuit elements. These technologies are also called logic families. Several of these main logic families are also 1.11, POPULAR ICS FOR LOGIC GATES Figures 1.19 to 1.25 show the pin diagrams for ICs employing respectively OR gates, AND gates, NOT gates, NAND gates, NOR gates, XOR gates, XNOR gates. ff ff a 7432 GG GIy GND Fig. 1.19: Pin diagram for IC 7432 V, Too tl GND Fig. 1.20: Pin diagram for 1C 7409 GND Fig. 1.25: Pin diagram for IC T4AS8810 10 Digtal Becton: 1.12 Basic BLOCKS MicROCOM! Some Explanation of Terms OFA 16 or 32. Typical operations Mca addition, subtract! ANDing. oe on, 4 two bit digit words The 82° defines the size of the micpocessor 8: TE ince Motorola 65000 is | aoe ALUis lobits wide. microproce oeproesati the CPU of and normally mst De a ices in onder t0 inction. with peripheral suppor dv Sse ALU contol unis er of peripheral devices d The numt and regis iculataplicason involved and depends on the particular appli even varies within one application. In general, a microcomputer’ consists of a cee and a processor (CPU). input and output means, memory to store programs and data. Read-only memory (ROM) isa storage medium for the groups of bits called words, and its contents cannot normally be altered once programmed. A typical ROM is fabricated on an LSI chip and can store, for example, 2048 8-bit words which can be individually accessed by presenting one of 2048 addresses to it. This ROMis referred to.as a 2K-word by 8-bit ROM. A ROM is a nonvolatile storage device, which ‘means that its contents are retained in the event of a loss of power to the ROM chip. Because of this characteristic, ROMs are used to store instructions (programs) or data tables that must always be available to the microprocessor. Random-Access Memory (RAM) is also a storage ‘medium for groups of bits or words whose contents can not only be read but also dynamically altered at specific addresses. A RAM normally provides volatile storage, which means that its contents are lost in the event of a power failure. RAMS are normally used as scratchpad memory forthe storage of temporary data and intermediate results as well as programs that can be reloaded from a backup non-volatile source. A register can then be Considey f ed storage fora number of bits, There bity i oy into the register simultaneously (in MY De 5 f Ch y (serially) from right to ten ale or 1 "hg sequentiall ‘ toright. ‘The term bus refers to a number of organized t0 provide a means of eo, Mey aes Mp: among different elements in a micro coy Mune. : mute ‘The conductors in the bus can be gro, * of their functions. A microprocessor nor, j Men, scares bus, adata bus and a contol bys 1, ly ha pits to memory or f0 an external device petty on the address bus. Instructions from me Ml gy thuatoand fom memory or extemal device? 8 travel on the data bus. Control signals for et uses and among system elements are trang on the control bus. ‘A microcomputer has three basic blocks: aQy memory unit and an input/output unit, Central Processing Unit (CPU): The CPU ereny, all the instructions and performs arithmetic and oy, operations on data. The CPU of the microconpy. is called the microprocessor. ‘The MOS microprocessor is typically asingleLg chip that contains all of the control, arithmetic xi logic circuits of the microcomputer. The bp microprocessors (TTL, Schottky TTL, ECL) dows provide the high densities of MOS devices ai therefore need more than one chip to implements microprocessor. Memory Unit: The memory unit stores both dae and instructions. The memory section typicily contains ROM and RAM chips. The ROM can only be read and is nonvolatile and is used 10 st" instructions and data that do not change. The RAY is volatile and one can read from and write intot RAM. A RAM js used to store programs and that are temporary and might change d course of executing a program. Input/Output Unit: An 1/0 w ‘ between the micro computer and the extern eS The tanser involved data, statusand com) er, Figure 1.26 shows the basic blocks of * ‘computer. Mtg uring nit transfers J Introductory Concepts 11 Micro- processor ft Microcomputer cPU vO unit Fig. 1.26: Basic blocks of a microcomputer 1.13 TYPICAL MICROCOMPUTER ARCHITECTURE Figure 1.27 illustrates the most simplified version of a typical microcomputer. The figure shows basic blocks. The various buses that connect these blocks are also shown. Although this figure looks very simple, it includes all the main elements of a typical microcomputer system. Address Bus: In this bus. information transfer takes place in only one direction, from the microprocessor to the memory or VO elements. Therefore. this is called a unidirectional bus Data Bas: In this bus, data can flow in both direc- tions, to or from the microprocessor. Therefore, this is a bidirectional bus. In some microprocessors, the data pins are used to send other information such as address bits in addition to data. This means that the Address bus dara pins are time-shared or multiplexed. Data bus Control Bus: This bus consists of a numberof signals Contr! that are used to synchronize the operation of the bus individual microcomputer elements. The micro- processor sends some of these control signals to the meee eel) Jel |e other elements to indicate the type of operation being i performed. 1.14 THE COMPUTER ‘The word computer has several different levels of Fig. 1.27: Simplified version of a typical microcomputer structure 1. The Microcomputer Bus: The microcomputer contains three buses, which carry all the address data. and control information involved in program exe- cution. These buses connect the microprocessor (CPU) to each of the ROM, RAM and V/O elements So that information transfer between the micro- processor and any of the other elements can take place, In the microcomputer, most information transfers are carried out with respect to the memory. When the memory is receiving data from another micro- computer element, it is called a WRITE operation and data is written into a selected memory location. ‘When the memory is sending data to another micro- Computer element, itis called a READ operation and data is being read from a selected memory location, ‘meaning: Level 1: In a very narrow sense, the computer is the part of hardware that performs the data processing, which is done by the central processing unit (CPU). Level 2: A broader view of the computer which includes all components that are interconnected with each other to perform data processing. The compo- nents include not only CPU but also other devices to handle the input data, the storage of data and results Devices connected to the CPU are sometimes called peripherals: Level 3: A still more comprehensive view is the one that defines the computer as a system which includes the hardware, the software and the people connected 10a computer's effective operation, BIRT TN TUN See 12. Digta’ Becroncs ve basic f five consists 0 Computer System can View. is ‘of computer which we ¢ i cre ee of pos UT are programs written by the users of oe Procedures are the rules, poici systems. red te pon of : 1 computers performed. Daa processing OAS are the people responsible for keeping the functioning in an effective, processing department convenient and efficient manner. — ‘A modem computer processes the following abilities (i) It can perform complex tasks and repe- titive calculations rapidly and accurately (ii) store large amount of data and information for suitable ‘manipulations (ii) able to make decision (iv) auto- matically correct or modify data by providing signals. Characteristics of Computers 1. Speed: Computer is a very fast and accurate device. Itcan process thousands of instructions within a few seconds, for which « human being can take several days or months 2, Accuracy: Computer results are accurate because it performs an operation according to given instruction. Errors can occur in computer system, but only when the programmer has made the error or hardware failure. Degree of accuracy is very high in ‘computer systems. 3. Memory: Computers have a large amount of memory to hold a huge amount of data. The infor. tation stored in memory is not forgettable by the computer but human beings can forget. Hence memory plays an important role in a computes and Stored information can be Fettieved later when Tequired for further use 4. No intelligence: Com, puters have no intel Intelligence is built ae in computer by the Programmer * Data means names, numbers, facts, ‘anything needed to work gy by building a program. Computers CANN Gy own decision. The various Operations re Nake rn computer is only on the basis of the inca provided by the user. ‘lhe? §, Diligence: Computer is free from Prob lack of concentration and Confusions, tte oe Ih s different tasks Without ae : Om i oe ANY mixin, PM can easily differentiate which ty, Xing d Pe of work My formed by it. It possesses lot of Concentra he never gets confused and never gets trey ah ay beings. ™ 6, Versatility: With the help of Computer. we perform much different tasks. It can be ys: . fy type of application like scientific, commergi my ay cational or business, etc. » ey 1.15 BASIC ORGANIZATION oF A COMPUTER SYSTEM Figure 1.28 shows the block diagram of th organization of a computer system. It ‘cons major building blocks (functional units) computer system. These blocks/units logic operations which are as follows: (0 Input Unit: It performs the following operat (a) It accepts (or reads) the instructions and dat from the outside word. (b) It converts these instructions and data in computer-acceptable form. (c) It supplies the converted instructions and day tothe computer system for further: processing” (i) Output Unit: The job of an output unit is 5 justthe Teverse of that of an input unit. The following functions are performed by an ‘output unit: (i) Ttaccepts the results produced by the computer which are in coded form and hence, cannot casily understood by us. (ii) It converts these coded results to human acceptable (readable) form. (iti) I supplies the converted results to the ousie world. Storage unit: The specific functions of the stole ‘Unit are to store: (0) The data and instructions required for essing (received from input devices) «bate ists of fg Of a digiy Perform fi Mut a problem, Storage unit | [ Secondary | storan | ron —f omen | LA and data | Preary | | storage unit Fig. 1.28: Block diagram of basic organization of 3 igptal computer (ii) Intermediate results of processing (ii) Final results of processing, before these results are released to an output device. ‘The storage unit of all computers is comprised of the following two types of storage: 1. Primary storage: This is also know as main memory and is used to hold pieces of program instructions and data, intermediate results of process- ing of jobs which the computer system is currently working on. While it remains in the memory. The central processing unit (CPU) can access it directly ata very fast speed. However the information in primary storage can retain as long as the computer system is on. As soon as the computer is switched off or reset the infor- mation in primary storage disappears. Moreover, the primary storage normally has limited storage capacity 2, Secondary storage: This is also known as auxt- liary storage, nd is used to take care of the limitations of the primary storage. It is much cheaper than primary storage and can retain information even when the computer is switched off or reset. This is normally used to hold program instructions, data and infor- mation on which the computer system is not working currently but needs to hold for processing later. The most commonly used secondary storage medium is the magnetic disk. ‘Arithmetic Logic Unit: The arithmetic logic unit (ALU) of a computer systemis the place where actual execution of the instructions takes place: The calculations are performed and comparisons (deci- sions) are made in the ALU The data and instructions stored in the primary storage before processing are transferred (as and when needed) to the ALU where processing takes place. Intermediate results generated in the ALU are temporarily transferred back to the primary storage until needed later, i.e. data may move from primary storage to ALU and back again to storage many times before the processing is over. The type and number of arithmetic and logic operations which a computer can perform, is determined by the engineering design of the ALU. Generally, all ALUs are designed to perform the four basic arithmetic operations (add, subtract, multiply and divide) and logie operations cor comparisons such as less than equal to and greater than. Control Unit: It does not perform any actual process- ing on the data, the control unit acts as a central controlling system, for the other components of the computer system. It manages and coordinates the entire computer system. It obtains instructions from the program stored in main memory, interprets the instructions and generates signals, which cause other units of the computer system to execute them. Central Processing Unit (CPU): The control unit and the ALU of a computer system are jointly known a the central processing unit (CPU). The CPU is the brain of a computer system. In a computer system all ‘major calculations and comparisons are made inside eC er ce» Sten mpg a s Special ty _ cPuis response es of the applications and research, ce wie he the CPU andthe CPU gate weather forecasting, medica a gh and See inna node special purpose computers, ~"°Stic, a ‘computer sys The! Vis " of Computer: by Al to technol voriLaea whch a TE ets OH According OGY Useg Sree length o i” (a) Analog computers: Analog called ae ofall within CPU computers that are made tg ers 4 ) ; n processing TON OF cOMPUTERS particular task only and not for aj hy 4.16 CLASSIFICA «based on the It works over a continuous data ap Ay se ctasifeation of oer communicate with numbers igy falling tree critei: made only for testing and analyzing Othe a wo ee ing systems or for new system deren technology ba According . soe and capt Features of Analog computers (ii) Accordin i j Based on this, the classification 1S shown In () It performs the job by measuring Taher capes counting. g. | i) It uses continuous signals rather than i Sere () According to purpose that orl) @ General Purpose Computers ree neral (il) Examples are thermometer, Speedomet ee accounting, invoicing, aes inventory, etc. are called general purpose computers. Generally, all computers used in offices, for educational, commercial appli- cation, etc. are general purpose computers, (b) Digital Computers: Digital Com, system that performs various computational i, Digital Computers use the binary number System, which has two digits; 0 and 1. A binary digit 4s cally puter is, Classification of computers Based Based on Based on cn purpose technology used sized and capacity — ‘Analog Super ‘computers computers | ema Digital Mainframe canes ‘computers al Hybrid ‘i Mini corpus computers —_| L] Micro- computers (PCs) Fie. 1.29 Classi ci ‘ation of computers a bit, Information is represented in digital computers in groups of bits. It performs several different tasks and is interactive in nature. If any error has been occurred, we can terminate it due to interactive feature, This feature is not available in hybrid and analog computers. Features of Digital Computer (a) Digital computer converts data into digits (b) It operates essentially on counting instead of measuring It accepts information in the form of discrete pulses. (d) It is used for business and scientific applications (e) Itis interactive in nature (f) These are most popular and widely used computers. (c) Hybrid Computer: Itis a combination of analog and digital computer. These computers are mostly used with process control equipment in continuous production plants like oil refineries, etc. and used at places where signals as well as data are to be entered into computers. Areas of application are nuclear power plants, mines, etc. (©) (ili) According to size and capacity (a) Microcomputer: The most common type of computers are microcomputers which are portable personal computers. It is a small computer which mainly consists of single chip. Average data transfer rate of a microcomputer is 5 lac bytes per second. It can hold from 8 to 32 bit word length. Micro- computers can be subdivided into two types: (i) Home Computer: These are basically meant for hobbies and games rather than. professional tasks, They consist of a keyboard integrated with CPU in one box and interfaced with ordinary television and multimedia system used for entertainment and training in various com- puter centers and homes. Personal Computers: These computers are designed for small business units and office ‘automation, PCs are used in various application ‘areas like: business and professional application and computer learning, word processing, accounting and telecommunication. (ii) Introductory Concepts 15 (b) Minicomputer: Minicomputers are larger in size than microcomputers and have very fast processing speed. It consists of a multiple processing unit in a single chip. It uses word length of usually 16, 24, 32, of 64 bits, The data transfer rate is about 4 million bytes per second. They can support upto 15 to 25 terminals simultaneously (c) Mainframe : These are very large machines with the capability of parallel processing. The data transfer rate of this machine is 8 million bytes per second. It uses the word length of usually 24, 32, 48 and 64 or 128 bits. Mainframe is used for centralized data processing like Train reservation system, Airline reservation. Mainframe computers can support over 500 terminals. Some important mainframe computers are FDM-3090. VAX 8842 and UNTVAC. Power of 2: Microprocessor design started with Abit devices. Then evolved to 8- and 16- bit devices. Thus powers of 2 keep coming up because of the binary nature of computers (Table 1.2). It lists the powers of 2 encountered in microcomputer analysis. ‘As shown the abbreviation K stands for 1024 (approximately 1000). Therefore 1K means 1024, 2K stands for 2048, 4K for 4096 and so on. Some personal microcomputers have 64 K memories that ccan store upto 65, 536 bytes. Table 1.2: Power of 2 Powers of2 Decimal equivalent __ Abbreviation x 1 2 4 2 8 x 16 2 32 2 6 r 128 2 256 = S12 20 1024 1K 2 2048 2K 2 4096 4K ae 8192 8K 2 16384 16K 2 32768 32K 2 65536 64k 16 Digital Electronics (d) Super Computers: Super computers are much faster and more powerful than mainframe computers. Their processing speed like in the range of 400 MIPS- 10,000 MIPS. word length 64-96 bit, memory capacity 256 MB and more and machine cycle time 4-6 nanoseconds. Super computers are specially designed to maximize the number of floating point instructions per second (FLOPS). Their FLOPS rating is usually more than 1 gigaflops. ‘Super computer contains a number of CPUs which operate in parallel to make it faster. They are used for massive data processing and solving very sophisticated problems. They are used for weather- forecasting, weapons, research and development, rocketing, in aerodynamics, seismology, atomic, nuclear and plasma physics. Examples are CRAY3 (developed by Control! Data Corporation) and SX-2 (developed by Nippon Electric Corporation, Japan), etc. We will discuss more about computers and micro- processor in Chapter 12, EXERCISE 1. List three examples of analog quantities. 2. What is the difference between analog and digital quantities? 3. What are the advantages of digital techniques over analog? 4. What are the main limitations tothe use of digital techniques? 5. What is the difference between analog and digital system? Discuss. 2 . Name different functional units of a Describe the advantages of Paralle) Coy nication over serial communication, °°" coy For each of the following statements MPU i the logic gate(s) AND, OR, NANT nitive which itis true: AND. Now iy (a) All LOW inputs produce a 4 (b) Output is HIGH if and only if HIGH. (c) Output is LOW if and onl HIGH. (d) Output is LOW if and ont LOW. Make truth table for a 3-input (a) AND gate (b) OR gate (c) NAND gate (4) NOR gate, TCH outpy allinpus ae Y if all inputs agg if all inputs ag . The voltage wave forms shown in Fig. 1.30 ye applied at the inputs of 2-input AND, oR NAND, NOR and X-OR gates. ‘ (ms) Oo 102 3 4 5 Kms) Fig, 1.30 Determine the output wave form in each case. Number Systems oe 21 INTRODUCTION We are familiar with the number system which is in common use in which an ordered set of ten symbols ‘0,1,2.3,4,5.6.7,8,9 (known as digits) are used to specify any number. This number system is known as the decimal number system. The radix or base of this number system is 10 (number of distinct digits). Any number (e.g. 1986.384) is a collection of these digits. It has an integer part (1986) and a fractional par (0.384) separated from an integer part by a radix point (,) also known as decimal. There are some other systems also to represent numbers, some of these are: binary, octal and hexadecimal number systems. These are widely used in digital systems like micro- processors, logic circuits, computers, etc. Therefore, the knowledge of these number systems is very essential for understanding and designing digital systems. We know that computers and digital circuits use binary signals but are also required to handle data which may be numeric, alphabets or special characters. Therefore the information available needs to be converted into suitable binary form before it can be Froeessed by digital circuits. This means that the ‘orton available in the form of numerals, ep ee special characters or any combination achieve ee be converted into binary format. To cach pa Lad of coding is employed where ina uno lbbabe or special characters coded cide toa code. There can be a variety of rent purposes such as arithmetic 7 operations, data entry, error detection and correction. etc. Selection of a particular code depends on its suitability for the purpose. In any digital systems different codes may be used for different operations and it may be necessary to convert data from one code to another. In this chapter, we will discuss how to make conversion from one system to another and study various codes commonly used in computers. 2.2 NUMBER SYSTEMS In general, in any number system, there is an ordered set of symbols known as digits. A collection of these digits makes a number which in general has two parts— integer and fractional separated by a radix point (decimal), ie. (N)y ; Radi point ds Frecoonl pa a number = radix or base of the number system number of digits in integer part number of digits in fractional part most significant digit least significant digit and 0<(dord,)$b-1 “The digits ina number are written side by side (to represent the number) and each position in| the number is assigned a weight or index of importance by some predesigned rule. Table 2.1 gives the details of commonly used number system. 18 Digital Electronics Table 2. Number system Base or radix (b) teristics of commonly used number Symbols used (d, or dy) Binary 2 Octal 8 Decimal 10 Hexadecimal 16 2.3 DECIMAL NUMBER SYSTEM The number system which we commonly use in our daily life is called the decimal number system. In this system, the base is equal to 10 (There are altogether ten digits- 0, 1, 2, 3, 4. 5,6, 7, 8. 9). In this system, for any number, the successive positions to the left of the decimal point represent units, tens, hundreds, thousands, i.e. each position represents a specific power of base 10. For example, the decimal number 3489 (written as 3489,,) can be written as (3 x 1000) + (4 x 100) + (8 x 10) +9 x 1) = 3000 + 400 + 80 + 9 = 3489 It may also be noted that the same digit signifies different values depending on the position it occupies in the number. For example In 3489,0 the digit 9 signifies 9 x 10° =9 In 3498,, the digit 9 signifies 9 x 10' = 90 In 3948, the digit 9 signifies 9 x 10? = 900 In 9348, the digit 9 signifies 9 x 10° = 9000 Hence any number can be represented by using the available digits and arranging them in various positions. ‘The principles which apply to the decimal number system, also apply to any other positional number system. In a positional number system, there are only a few symbols (e.g.0 to 9 in decimal number system), called digits and these symbols represent different values, depending on the position they occupy in the number, as described above. Thus for any (other) Positional number system, it is important to keep track Of the base of the number system in which we are working, Some of the positional number system, which are used in computer design and by computer pro- fessionals are describe subsequently, 24 BINARY NUMBER SYSTEM In the binary number system, the base in 2 (instead Of 10). We have only two symbols or digits, viz, 0 eee and 1 The largest sine digits 1 (on stn base). Each position in a binary number repent power ofthe base 2. In this system, the right positon isthe units (2°) postion, the second vm from the right is (2, the thi position fom thence is 2s postion, then 2 positon, 2 postion at on. For example, the decimal equivalent of the binary number 10101 (written as 10101,) is i (0101) = 1x24 023) + x2) 4x2) +(x 2%) =16+0+440+1=21 Thus 10101 = 215 Binary digit is often referred to by the common abbreviation “bit”. A “bit” in computer terminology means either 0 or a 1. Table 2.2 lists all the 3.1 numbers along with their decimal equivalent. Table 2.2: 3-bit numbers with their decimal values Binary Decimal equivalents 000, 0 001 1 010 2 ou 3 100 4 101 5 0 6 u 7 It may be noted that a 3-bit number can have . of the 8 values in the range 0 to 7. In fact it may seen that any decimal number in the range O10" can be represented in the binary form as an number. ons Binary numbers are after called binary wer Just words. Binary words with certain numbers © have also acquired special names. A4-bitbina) Ty, is called a nibble and an 8-bit binary wor Se byte. A 16-bit binary word is after refered iy. word. A 32-bit binary word is referred 104 oe perce x rightmost or least significant bit is usually ne he LSB, The leftmost or most significant eta er binary word is usually denoted as the MSB bit of 25 OCTAL NUMBER SYSTEM al number system, the base is 8. Hence there SS hn digits 0, 1, 3, 4, 5,6, 7, (8 and 9 do aa exist in this system). The largest ingle digit is 7 (one less than the base). Each position in an octal number represents a power of the base (8). Therefore the decimal equivalent of the octal number 3058 is (3 x8) + (0 x 8) + (5 x 8!) + (8 x 8°) 536 +0 + 40 + 8 = 1584 3058, = 1584, 2.6 HEXADECIMAL NUMBER SYSTEM The hexadecimal system is one with a base of 16, having 16 single character digits or symbols. The first ten digits are the digits of the decimal number system- 0,1,2,3,4, 5, 6, 7, 8, 9. The remaining six digits are denoted by the symbols A, B, C, D, E and F representing the decimal values 10, 11, 12, 13, 14 and 15 respectively. The largest single digit is F or 15, ie. one less than the base. Each position in a number of hexadecimal system represents a power of the base 16. Therefore, the decimal equivalent of the hexadecimal number 1AF is (1x 16?) + (A x 16!) + (F x 16° 1 x 256) + (10 x 16) + (15 x 1) 56 + 160 + 15 =431 Hence 1AF\¢ = 431,, 2.7 CONVERTING FROM ONE NUMBER SYSTEMTO ANOTHER Number expressed in much more meaning! expressed in any off ‘use we have bee day-to-day life. Ho can be represented ‘put and the final soften required System to, decimal ‘Method of conver ‘ind a method of base, decimal number system are ful to us than the numbers her number system. This is N using decimal numbers in our wever any number in one system in any other system. Because the output values are to be in decimal, ‘convert numbers in other number and vice-versa. We now describe ‘ting to base 10 from any other base Converting from base 10 to any other Number Systems 19 2.7.1 Converting to Decimal trom another Base Step 1: Determine the column (positional) value of each digit Step 2: Multiply the obtained colurnn values (in step 1) by the digits in the corresponding columns. Step 3: Sum the products calculated in step 2 The total is the equivalent value in decimal, Example 2.1: 11001; = ?,, Solution: Step 1: Determine column values Column Number (from right) Column value Bene Step 2: Multiply column values by corresponding digits. 16 8 4 2 1 x1 x1 x0 x0 xl 16 8 0 0 I Step 3: Sum the products 16+8+0+0+1=25 11001, = 25,0. Example 2.2: 4703, = 2, Solution: Step 1: Determine column values Column Number (irom right) Column value Step 2: Multiply column values by corresponding digits. 6 8 1 x7 x0 x3 Ty 0 3 Step 3: Sum the products 2048 + 448 +0 + 3 = 2499 a 4703y = 2499. Example 2.3: Determine the decimal number represented by the following binary number: 110101 eee 20 Digital Electronics Solution: (110101); = (1 x 2) + 1x 24) + 0x2) + (1x2) + (0x2) +(1 x2) +16+0+4+041 = (S30 Example 2.4: Determine the decimal number represented by the following binary number: 101101.10101 Solution: (101101.10101); = 1x 25+0x2¢+ 1x2 +1 x2 +0x 241 x241x2! +0x27 41K 2940x274 +1x25 =32+04+8+44041 +12+0+18+0+1/32 = (45.65625);0 2.7.2 Decimal to Binary Conversion Any decimal number can be converted into its equivalent binary number. For integers, the conversion is obtained by continuous division by 2 and keeping track of the remainders, while for fractional parts, the conversion is affected by continuous multi- plication by 2 and keeping track of the integers generated. This can be seen by the subsequent examples Example 2.5: Convert (13),o to an equivalent base- 2 number. Solution: Quotient Remainder 6 1 3 0 od (13) = (1101), 2 NS u Example 2.6: Convert (0,65625),y to an equivalent base-2 number. Solution: 0.65625 0.31250 0.62500 0.25000 Hinting ttiewd afin £50000 1.31250’ 0.62500 0.50000! are 1 0 1 0 = (0.65625), = (0.10101), Example 2.7: Express the following decimal n in the binary form : (a) 10.625 (b) 0.6875, Solution: (a) Integer part lumber Quotient Remainder 5 o——____ 2 1 rae fai 1 0 ee Ora 9, Integer part : (10)io = (1010), Fractional part: 0.625 = 0.250 0.500 x2 x2 x2 1.2507 0.5007 1.000 | 1 o 1 (0.625)i9 = (0.101), and (10.625) = (1010.101), (b) 0.6875 0.3750 0.7500 x2 x2 x2. x2 Pry | + (0.6875) 0 = (0.1011), 2.7.3 Binary to Octal Conversion The following steps are used in this method: Step 1: Divide the binary digits into groups (starting from the right). Nie wieNia nis yf ree os aS group of three binary digits to step 2: Convert each Foo ony 8 digits (007) 8 it (since U . one Ce ames system (Table 2.2), 3 bits are in aaa to represent any octal number in binary sul (=8) Example 2.8: (101110). = (2s ylution: ae = 1: Divide the binary digits into groups of 3 starting from LSD. ol 110 Step 2: Convert each group into one digits of octal (using binary to decimal conversion) (101), = 1x 2? + 0x2! +1% 2°, =4+041 =55 (110), = 1 x 2? + 1 x 2!+0x 2° =44+2+0 = 65 (101110), = (56), Example 2.9: (1101010), = ()5 Solution: (1101010), =001 101 010 (groups of 3 digits from right) (001). =Ox 2? +0x2!+1 x 2° =0+041 1 (10D, =1x 240% 2!+1x 2 =44041 =5 010). =0x 241% 240% 2° =0+24+0 =2 Hence (1101010), = (152), Hence 27.4 Octal to Binary Conversion a following Steps are used in this method: ne Convert each octal digit to a 3 digit binary forme (the octal digits may be treated as decimal {this conversion) Step 2: Combine all ing bi 7 dein Combine all the resulting binary groups (of cach) into a single binary number. Number Systems 21 Example 2.10: (562), = (2), Solution: Quotient Remainder 5 2 1 2 2 1 ° 2 4 aa o 1 2 104 ro 5, = (101), Similarly 6, (110); 2, = (010), 101 110 010 Combining (562), = se Sean Hence (362)3 = (101110010), Example 2.11: Find the decimal equivalent of the octal number 127.54 Solution: (127.54), = 1 x 8° +2 x 8'+7x 8945 x81 44x82 5.4 = + 4416+ 74545 = 87 + 0.625 + 0.0625 = (87.6875); 2.7.5 Octal to Decimal Number Conversion Example 2.12: (6327.4051)g = 6 x 8 + 3x 87 +2x 8! +7x 844 x S'+0x 87+5x 85+ 1x 84 5 1 = 3072 + 192 + 16+7+ soe +— 512 4096 = (3287.5100098),9 2.7.6 Decimal to Octal Conversion Example 2.13: (a) convert (247),o into octal () convert (0.6875)j9 into octal Solution: (a) Quotient Remainder 247 30 7 (247)10 = (367)s, (b) 0.6875 0.5000 x8 x8 5.5000 70000 4 L 5 4 + (0.6875); = (0.54). 2.7.7 Hexadecimal to Decimal Conversion Example 2.14: (AC)6 = Qo Solution: (IAC) ig = 1x 16° + Ax 16 + C x 16° = 1x 256+ 10x 16+12x1 2.7.8 Decimal to Hexadecimal Conversion Example 2.15: (428),9 = (?);5 Solution: 16 | 428 Remainders in Hexadecimal Hence (428),5 = (1AC) 16 2.7.9 Binary to Hexadecimal Conversion The following steps are used in this method: Step 1: Divide the binary digits into groups of 4, Starting from the right (LSD). Step 2: Convert each group to one hexadecimal digit. Remember that hexadecimal digits 0 to 9 are equal to decimal digits 0 to 9, and hexadecimal digits A to F are equal to decimal values 10 to 15 Tespectively, Hence, for this step, the binary to decimal conversion can be used but the decimal values 10 to 15 must be represented as hexadecimal A to F. (Table 2.3) Example 2.16: (11010011), = (2), Solution: Step 1: 1101 Step 2: (1101), oo = 1K? + 1x 240x241 x 0 =84+44041 eee (O01); = =Ox2+0x 24121 =0+0+241 =3i (11010011), = (D3), +1x20 Hence, 2.7.10 Hexadecimal to Binary Conversion Following steps are used in this method: Step 1: Convert the decimal equivale, hexadecimal digit to 4 binary digits, Step 2: Combine all the resulting binary groups (eh of 4 digits) into a single binary number. Example 2.17: QAB)ig = (2 Solution: Step 1: ‘Nt of each By = 10 = (1011), 0010 1010 1011 QAB)¢=—- —— — i A B Hence (1101), (2AB),, = (00101010101 1), Step 2: Table 2.3: Binary to hexadecimal conversion Hexadecimal Binary Hexadecimal __ Binary 0 0000 8 1000 1 0001 9 1001 2 0010 A 1010 3 0011 B 1011 4 0100 5 1100 5 101 D 1101 6 o110 E 1110 7 oll F uit 2.7.11 Octal to Hexadecimal Conversion Toconvertan octal number to hexadecimal fisteo Vert it to binary and then the binary to hexadeci Example 2.18: Convert 756,603, to hexadecimal Solution: (Octal) 7 Setettor ate G@iae 0) a (Binary) 111 101 110,10, (Group of 0001 1110 1110. 1100 000! 4 bits) 8 (Hex) 1 E C¢ 1 Hence (756.603), = (IEE.C18)\« eel 7A2 Hexadecimal to Octal Conversion aoe ahexadecimal number to octal, first con- ‘To convert exadecimal number to binary and then vert the given the binary to octal Example 2.19: Convert B9F, AEs to octal Solution: (Hex) B (Binary) 1011 (Group of 101 3 bits) ulti) 5 6 3 7. 5 Hence (B9F.AE) 6 = (5637-534), 28 SIGNED BINARY NUMBERS Inthe decimal number system, a plus (+) sign is used to denote a positive number and a minus (—) sign for denoting a negative number. The plus sign is usually dropped and the absence of any sign means that the number has positive value. This representation of numbers is known as signed number. As we know that digital circuits can understand only two symbols and 1, therefore, we must use the same symbols (0 and 1) to indicate the sign of the number also. Normally an additional bit is used as the sign-bit and itis placed as the most significant bit. A 0 is used to Tepresent a positive number and a 1 to represent a negative number. For example, an eight bit signed number 01000100 represents a positive number and its value (magnitude) is (01000100) = (68)o. The left most 0 (MSB) indicates that the number is positive o aie hand, in the signed binary form, eID Bese a negative number with magni- (MSE ing 2 = (68),o. The | in the left most position other iicates that the number is negative and the Seven bits give its magnitude. This kind of Heine for signed numbers is known as sign- nines’ ing with these Example 2.20; following binary representation of (@) 101100 Solution; 9 OF a &£ 1001 1111 . 1010 1110 10 oll 111. 101 O11 100 Sad Find the decimal equivalent of the Humbers assuming sign magnitude the binary numbers. (b) 001000 ( Sign bit i negave ts 1, which means the number is. ieee estima ntittat Number Systems 23 Magnitude = 01100 = (12),, (101100), = (-12),, (b) Sign bit is 0, which means the number is positive Magnitude = 01000 = 8 (001000), = (+8), 2.9 ONE’S COMPLEMENT REPRESENTATION Ina binary number, if each 1 is replaced by 0 and each 0 by I, the resulting number is known as the one’s complement of the first number. In fact, both the numbers are complement of each other. If one of these number is positive, the other will be negative with the same magnitude and vice versa. This method is widely used for representing signed numbers. In this representation, MSB is 0 for positive numbers and | for negative numbers Example 2.21: Find the one’s complement of the following binary numbers: (a) 0100111001 (b) 11011010 Solution: (a) 1011000110 (b) 00100101 Example 2.22: Represent the following numbers in one’s complement form: (a) +7 and-7 (b) +8 and-8 Solution: (a) (47) = (O11); and (7); = (1000); (B) (+8), = (01000); and (-8))9 = IOI)» 2.10 TWO'S COMPLEMENT REPRESENTATION If 1 is added to 1's complement of a binary number, the resulting number is known as the nvo's comple- ‘ment of the binary number. For example, 2's comple- ment of 0101 is 1011. Since 0101 represents (+5)o. ‘Therefore 1011 represents (-5)io in 2’s complement representation. In this representation also, if the MSB is 0, the number is positive, whereas if the MSB is 1, the number is negative. It may be observed that the 2's complement of the 2's complement of a number is the number itself. Example 2.23: Find the 2's complement of the number 01001110, 24 Digital Electronics Solution: Number 01001110 1's complement : 10110001 Add 1 : +1 10110010 (2's complement of the given number) 2.11 FLOATING POINT REPRESENTATION Consider the decimal number 128.466 which may be written as (i) 128.466 (ii) 0.128466 x 10° Suppose a register is capable of storing 6 digits and a sign bit and this register is divided into two Parts, first part containing the integral portion of the number and second part containing the fractional portion and the decimal point located between the two parts of the register. (Fig. 2.1) + | Sign 1} 2] 8] 4/6] 6 ‘Assumed decimal point Fig. 21 ‘This representation has two drawbacks. The first drawback of this scheme is the need of the user to remember and keep track of the decimal point location. The second drawback is that the range of numbers which can be represented using this scheme is limited to +999.999, In the second method, called floating point representation, the number is written as a fraction multiplied by a power of 10. The fraction part is known as mantissa and the power of 10 (which multiplies the fraction) is known as exponent. The register is divided into two parts the first part of 4 digits to contain the mantissa and the second part of 2 digits to hold the exponent. To store both positive and negative exponents, it is desired to split the range of 00 to 99 into two parts. Assuming 0 or origin at 50. all exponents greater than 50, are considered to be Positive and all exponents less than 50, as negative. The scheme is thus known as floating point Tepresentation with exponent in excess 50 form, the range of exponents will be from -50 to + 49. In this a scheme, the number 1384 x 10% can be register as in Fig, 2.2 Stored jy a Mantissa 5 | ‘ ‘Assumed decimal point Fig. 2.2 To store the number ~0.000128; number is first written as 0.1288 x | al he significant digits in the mantissa, the poe iscalled normalization. Tis numbercanthenteaee in the register as in Fig. 23 8 x 10-5 10°, thus kee ~ | Sign 1) 2) el]e|a Ey Mantissa Exponent ‘Assumed decimal point Fig 23 A floating point number is called as in the normalized form if the most significant bit of the mantissa contains a non-zero digit. A floating poi binary number is also represented in a similar way except that here, the base or radix is 2. 2.12 COUNTING IN BINARY Counting in binary is very much similar to decimal counting as shown in Table 2.4 2.13 TWO'S COMPLEMENT ARITHMETIC The 2’s complement system is used to a negative numbers using modulus arithmetic. 7° Word length of a computer is fixed. That means 4-bit number is added to another 4-bit numb * result will be only of 4-bits. Carry, if any, from oth bit will overflow. This is called the modulus metic. For example 1100 + 1111 = 1011 In the 2's complement subtraction, ad 17 complement ofthe subrahendtotheminvend I isa cary out, ignore it. Look at the sign bit. posit of the sum term. Ifthe MSB is a0, the results eg ——— Table 2.4: Counting in binary Decimal __Binary _ 0 0000 1 0001 2 0010 3 001! 4 0100 5 0101 6 0110 7 oul 8 1000 9 1001 10 1010 mn 1011 2 1100 13 1101 14 1110 15 ui and is in true binary form. If the MSB isa 1 (whether there is a carry or no carry at all), the result is negative and is in its 2's complement form. Take its 2's complement to find its magnitude in binary. Example 2.24: Add -75 to + 26, using the 8-bit 2's complement arithmetic. Solution: +75 = 01001011 -75 = 10110101 (In 2’s complement form) +26 = 00011010 S = 10110101 (-49) = 11001111 (No carry) There is no cary. The MSB is a 1, the result is ‘negative and is in 2's complement form. The required magnitude is 2’s complement of 11001111, i.e. 00110001 = 49, The result is therefore - 49. Example 2.25: Subtract 14 from 46 using the 8-bit 2's complement arithmetic Solution: +14 = 00001110 V's complement of + 14 = 11110001 2's complement of + 14 = 11110001 +1 = 11110010 ie essen tetaennee Number Systems 25 +46 00101110 -14 +11110010 +32 000100000 (Ignore the carry) The MSB is 0, so the result is positive and is in normal binary form. Therefore, the result is + 00100000 = + 32 2.14 ONE’S COMPLEMENT ARITHMETIC The 1’s complement of a number is obtained by simply complementing each bit of the number, ic. by changing all the Os to 1s and all the Is to Os. We can also say that the 1's complement of a number is obtained by subtracting each bit of the number from 1. This complemented value represents the negative of the original number. This is implemented in the hardware by simply feeding all bits through inverters. One of the difficulties of using 1's complement is its representation of zero. Both 00000000 and its 1's complement 11111111 represent zero. The 00000000 is called positive zero and the 11111111 is called negative zero. Example 2.26: Subtract 14 from 25 using the 8 bit I's complement arithmetic. Solution: 25 00011001 -14 11110001 +11 (00001010 zh seiscaraeita _ > __+1_ (Add the end around carry) 00001011 + Iho (In 1’s complement form) Example 2.27: Add -25 to +14, using the 8-bit I's complement method. Solution: +14 00001110 -25 +11100110 (In 1’s complement form) -ll 11110100 (No Carry) ‘There is no carry and MSB is 1. So the result is negative and is in I’s complement form. The 1's complement of 11110100 is 00001011. The result is therefore —1 1,9. Example 2.28: Add -25 to —14, using the 8-bit 1's complement method. 11100110 dn 1's complement form) =14_ +L1110001_ (In 1's complement form) 39 noon +1 (Add the end around carry) 11011000, The MSB is a I. So the result is negative and is in its 1's complement form. The I’s complement of 11011000 is 00100111. So. the result is -39 Example 2.29: Add +25 to + 14, using the 8-bit 1’s complement arithmetic Solution: +25. 00011001 +14 00001110 (In 1’s complement form) +39 00100111 There is no carry. The MSB is a 0. So the result is Positive and is in pure binary. The result is 001001 11 =+39. Example 2.30: Add +25 to -25, using the 8-bit 1's complement method. Solution: +25 00011001 =25_+11000110 (In 1’s complement form) 00 ‘There is no carry. The MSB is a |. So the result is negative and is in 1's complement form. The I's complement of 11111111 is 00000000. Therefore, the result is ~0. EXERCISE 1. Convert the following binary numbers to decimal fa) (b) HI (d) 1001 (e) 1011 2. Convert each binary number to decimal (c) WI (a) 1001.11 () 1011100.10101 (©) 1000 001.111 (4) 101110.1010 () WMA 3. Add the binary numbers (@) +1 (b) 1001 + 101 (©) 101+ 11 (@) 11+ 10 (e) 1101 +1011 + w 2 14, oF Use direct subtraction on the fol numbers "win bin (a) 11-1 (b) 101-100 (©) 1100-1001 (@) 1110-44) Determine the 1's complemer ae plement of each binary (a) 101 (b) 1010 (©) 11010111) 00001 Solve using 2's complement method: (a) 10,01, (b) 1101,-1001, (©) 1111000,-111 1111, (@) 111,-110, (©) 10101; -10111, Determine the binary numbers the following decimal numbers (a) 37 (b) 255 (©) 26.25 @ 1175 Convert the following numbers fro to octal and then to binary (a) 375 (b) 249 Tepresented by m decima} (©) 27.125 . Convert the following binary numbers to octal and then to decimal: (a) 11011100.10 10 10 (b) 01010011.010101 (©) 10110011 Convert the following numbers to hexadecimal and then to binary: (a) 375 (b) 249 (e) 27.125 - Convert the following binary numbers to hexa decimal and then to decimal (a) 11011100.101010 (b) 01010011.010101 (©) 10110011 How (-28.5)j9 will be represented using floating point representation. Solve using 2's complement method: (a) 1111000 — 11111113 (b) 10101, - 10111; () 1101, ~ 1001, d) 11, -11 , Bae ets complement of each bina) number (a) 101, (b) 1010, (c) 110111, (d) 00001, Binary Codes ‘The digital system works fine for transistors, relays, switches, and integrated circuits. When itis to be used tyypeople for their decimal system it must be custom- designed to fit their system. Here we shall discuss soine of the methods used to express both numbers and letters as binary codes, Though a number of codes are in use, but we shall discuss only a few most commonly used codes: 1. Weighted binary codes 2. Non-weighted binary codes 3.1 WEIGHTED BINARY CODES Weighted Binary Codes are those which follow the Positional weighting principles. Each position of the number denotes a specific weight. The straight binary counting sequence is an example, for each column has a weight 8, 4, 2 or 1, ie. 23, 22, 2!, 2° Several systems of codes are used to express the decimal digits 0 through 9 (Table 3.1). The 8421 and. XS3 are both weighted codes, each four-bit group epresenting one decimal digit, the left three being, Weighted. The number 761 jo for example, would be Fepresented in 8421 code as Olt = O11 oot 7 6 1 - be allows any decimal number to be represented con ts Of BCD codes. Using these codes, puter can add in what appears to be decimal and ie decimal answers. One application of an 8421 ie Ata nuclear rocket test site where BCD ated the time of day for observers two n 7 miles away. The time 6:32:40 was represented as nnn ee 0000 0110 O01! 0010 0100 0000 0 6 3 2 4 0 Table 3.1 ‘cimal 8421 xs 0 0000 ool! 1 0001 0100 2 0010 o101 3 0011 oul 4 0100 oul 5 o1ol 1000 6 ono 1001 7 oul 1010 8 1000 loll 9 1001 L100 Other codes may be different hardwares. y processed by employing 3.1.1 Binary Coded Decimal Numbers (BCD) Accode is collection of special group of symbols used to represent numbers, letters, ete. In the BCD code, each decimal digit of the number is represented by its binary equivalent as a nibble, ie. as a string of + bits each. The BCD code is not a number system, but it is a system with each digit encoded in its binary equivalent as a nibble. For example, decimal numbers 3429 and 9637 are expressed in BCD numbers as follows: 7 4 2 2 (Decimal) 0101 0100 0010 1001 (BCD) 9 6 3 - (Decimal) 1001 O10 O11 OIL! (BCD) 27 28 Digital Electronics The advantage of the BCD code is an easy mode of conversion from decimal to binary and binary to decimal. The main area of application of BCD numbers is where decimal data is transferred into or out of digital processes. BCD numbers are processed by circuits of calculator, digital clocks, digital voltmeter, etc. Example 3.1: Convert the following BCD number to its decimal equivalent: 0100 0010 O111 1000 Solution: 2100 9010 O11) 1000 4 2 7 8 Ams: 478 3.1.2 Converting a given Decimal Number to its BCD Equivalent Step 1: Write the decimal number Step 2: Convert each decimal digit to its 4-bit binary equivalent Step 3: Write the binary number as answer. Example 3.2: Convert the decimal number 35 into BCD: Solution: Step1: 3 5 Step2: 0011 101 Step3: 00110101 Ans: 35,9= 110101BCD 3.1.3 Comparison of Number ‘Systems with BCD Table 3.2 gives the representation of the decimal ‘number | through 15 in the binary, octal, hexadecimal and in BCD code for comparison. 3.2 ALPHANUMERIC CHARACTERS, INBCD Numeric data is not the only form of data to be handled by a computer. It is often Tequired to process alphanumeric data also. An alphanumeric data is a string of symbols where a symbol may be one of the letters A, B, C, D. -Z or one of the digits 0, 1, 2, ot 9 ora special character such a8 +, -,*,/,.,(),=, space (or blank), etc. An alphabetic data consists of only the letters A, B,....Z and the blank character, Similarly numeric data consists of only numbers 0, 1, 2......9. However, any data must be Tepresented imtemally by the bits 0 and 1. Hence binary coding schemes are used in computers to represent data internally. am Table 32: Comparison of number system, _Decimal Binary Octal Hexadecimaj~ cp 0 0 0 Ona 1 1 1 1 a 2 10 2 2 0019 3 uN 3 3 oon 4 10004 4 0109 5 101 5 5 101 6 m0 6 6 ono 7 M1 7 7 ont 8 1000 10 8 1000 9 1001 9 1001 0 1010 A coo10009 no wn 13 B 00010001 2 1004 C o0010019 13 1101 15 D 00010011 14 110 16 E 0010100 um ay F o0010101 In discussing BCD in the previous article, wehaw used a group of 4 bits to represent a digit (character) in BCD. 4-bit BCD coding system can be used to Tepresent only decimal numbers and 4 bits are insufi. cient to represent the various characters used by a computer. Hence, instead of using 4 bits with only 16 possible characters, computer designers com monly use 6 bits to represent characters in BCD codes, In the 6-bit BCD code, the four BCD numeric place Positions are retained, but two additional zero Positions are added (Table 3.3). With 6 bits, itis possible to represent 64 (=2) different character. ‘This is a sufficient number to code the decimal digit (10), alphabetic letters (26) and other special characters (28), Example 3.3: Show the binary digits used to record the word BASE in BCD. Solution: B= 110010 in BCD binary notation A= 110001 in BCD binary notation S = 010010 in BCD binary notation E= 110101 in BCD binary notation Hence the binary digits 110010 110001 010010 11010! B A s E will record the word BASE in BCD. ee i 3: Alphabetic and numeric characters in BCD, it their octal equivalents : BCD Code OctalEquivalent Caaree” Fane Digit i 0001 61 : u 0010 62 c "1 0011 63 . "1 0100 64 7 M1 0101 65 4 u 0110 66 u oul 67 H a 1000 70 1 u 1001 1 J 10 0001 41 K 10 0010 42 L 10 0011 43 M 10 0100 44 N 10 0101 45, ° 10 0110 46 P 10 oui 47 Q 10 1000 50 R 10 1001 31 s o1 0010 22 a o1 0011 23 a o1 0100 24 = o1 0101 25 aad ol 0110 26 x o1 oul 27 - o1 1000 30 - o1 1001 31 ; oO 0001 o1 A oo 0010 02 a 00 0011 03 : 00 0100 04 5 00 0101 0s 6 00 0110 06 i 00 oun 07 7 on 1000 10 : 00 1001 i oo eit i 3.3 REFLECTIVE CODES ered is said to be reflective when the code for 9 is Inverse for the code for 0, 8 for 1,7 for 2, 6 for 3 aa S for 4. Note that the XS3 code is reflective ‘able 3.1) whereas the 8421 code is not. 34 SEQUENTIAL CODES Nea ig on Said to be Sequential when each next code binary number greater than its preceding code. Binary Codes 29 This is mainly used in mathematical manipulation of data. The 8421 and XS3 codes are sequential but the 2421 and 5211 codes are not. 3.5 NON-WEIGHTED CODES Non weighted codes are codes that are not positionally weighted, i.e. each position within the binary number is not assigned a fixed value. Two such codes are Excess-3 and Gray codes 3.5.1 Excess-3 Code Excess-3 (also called XS3) is a non-weighted code used to express decimal numbers. In this code, 3 is added to each of the decimal digits and then each of the resulting digit is converted to equivalent binary number written as a nibble, as is done in BCD code. The code has some very interesting properties when used in addition. To add in XS3, we add the binary numbers. If there is no carry out from the four bit group, subtract 0011. If there is a carry out, we add 0011. The XS3 code derives its name from the fact that each binary code word is the corresponding 8421 code word plus 0011 (3). It is a sequential code and therefore, can be used for arithmetic operations. It is a self complementing code, i.e. reflective code (Table 3.1). 3.5.2 The Gray Code The Gray code is a non-weighted code and is not suitable for arithmetic operations. It is not a BCD code. This belongs to a class of codes called minimum- change codes in which only one bit in the code-group changes in going from one step to the next. Since successive code words in this code differ in one bit position only, therefore it is a unit distance or cyclic code. Itis also a reflective code: The n least significant bits for 2® through 2*!-1 are the mirror images of those for 0 through 2°-1, (Table 3.4), ie. forn=3 3 bits after the MSB) the (3) bits for 8 through 15 are the mirror images of those for 0 through 7. ‘The Gray code is often used in situations where other codes (such as binary) might produce erroneous or ambiguous results, where during successive transitions, more than one bit of the code is changing. For instance, using binary code, going from 0111 to 1000 requires that all four bits change simultaneously, a

You might also like