Digital Logic Design - Module 1 PDF

Summary

This document provides lecture notes on digital logic design, specifically focusing on number systems (decimal, binary, octal, and hexadecimal), conversions between them, and basic arithmetic operations. The materials explain fundamental concepts and are likely part of a computer science course.

Full Transcript

Course Name: Digital Logic Design Course Code: CSCS-2522 Credit Hours: 3 Instructor: Prof. Mudassar Saleem (M.Phil. Computer Science) Module #: 1 Today Agenda Importance of Subject. What is number system Commonly used number systems Number system conversions Course Objectives Thi...

Course Name: Digital Logic Design Course Code: CSCS-2522 Credit Hours: 3 Instructor: Prof. Mudassar Saleem (M.Phil. Computer Science) Module #: 1 Today Agenda Importance of Subject. What is number system Commonly used number systems Number system conversions Course Objectives This course provides One of the main goals of this course is to teach students the fundamental concepts in classical digital design and to demonstrate clearly the way in which digital circuits are designed and analyzed today. The purpose is to make students familiar with modern hierarchy of digital hardware and enlighten them the state-of- the-art computer hardware design methodologies. Moreover, the contents of the course provide students the basic idea of how to design and simulate logic circuits. Number Systems A System for the representation of numbers and quantities is called Number system. It is the set of digits, symbols and rules to represent the quantities for counting, performing calculation and measurement. Most commonly used number systems: ▪ Decimal number system ▪ Binary number system ▪ Octal number system ▪ Hexadecimal number system Common Number Systems Used by Used in System Base Symbols humans? computers? Decimal 10 0, 1, … 9 Yes No Binary 2 0, 1 No Yes Octal 8 0, 1, … 7 No No Hexa- 16 0, 1, … 9, No No decimal A, B, … F Quantities/Counting (1 of 2) Hexa- Decimal Binary Octal decimal 1 1 1 1 0 0 0 0 1 1 1 1 2 10 2 2 8 4 2 1 3 11 3 3 4 100 4 4 Example 5 101 5 5 1 0 1 0 6 110 6 6 7 111 7 7 8 0 2 0 10 Quantities/Counting (2 of 2) Hexa- Decimal Binary Octal decimal 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 Conversion Among Bases The possibilities: Decimal Octal Binary Hexadecimal Quick Example 2510 = 110012 = 318 = 1916 Base Decimal number system The decimal number system consist of ten digits from 0 to 9 these digits can be represent quantities. The base of decimal number system is 10 because this number system consists of ten digits. The base of binary number system is 2. Digital computer use binary 10n-1…..103 102 101 100.10-1 10-2 10-3 10-4 105 …….. 10-n 2 1 0 Position 2 1 -1 -2 -3 Position 102 101 100 Weight 101 100 10-1 10-2 10-3 Weight 3 2 7 Digits Digits 6 5. 3 2 7 Example 1: Example 1: Consider the decimal number 892. Consider the decimal number 139.78. 8 8 x 102 = 800 1 1x102=100 9 9 x 101=90 3 3x101=30 10 2 X 100=2 9 9x100=9 7 7x10-1=0.7 8 8x10-2=0.08 Decimal to Decimal (just for fun) Decimal Octal Binary Hexadecimal Next slide… Weight 12510 =>5 x 100 = 5 2 x 101 = 20 1 x 102 = 100 125 Base Decimal to Binary Decimal Octal Binary Hexadecimal Decimal to Binary Technique Divide by two, keep track of the remainder First remainder is bit 0 (LSB, least-significant bit) Second remainder is bit 1 Etc. Binary Number system The binary number system consists of only two digits 0 and 1. the digits are called Binary digits. The base of binary number system is 2. Digital computer use binary Number system to represent data. 2n-1…..23 22 21 20 Binary to decimal conversion Position (1011.11)2 3 2 1 0 Weight 1 0 1 1 1 0 1 23 22 21 20 3 22 1 20 -1 -2 2-3 Digits 2 2 2 2 1 0 1 1 Sum of weight 2 3 + 21 + 20 + 2-1 + 2-3 Suppose the binary fraction number is 0.1101 8+2+1+0. 5+0.125 -1 -2 -3 -4 Position 11.625 2-1 2-2 2-3 2-4 Weight 25 24 23 2-2 21 20 Weights 1 1 0 1 Digits 1 0 1 0 1 1 Binary numbers Binary to Decimal Technique Multiply each bit by 2n, where n is the “weight” of the bit The weight is the position of the bit, starting from 0 on the right Add the results Example Bit “0” 1010112 => 1 x 20 = 1 1 x 21 = 2 0 x 22 = 0 1 x 23 = 8 0 x 24 = 0 1 x 25 = 32 4310 Exercise Convert the binary numbers into decimal (1000)2, (10011)2 , (111001)2 , (110010)2, (10001)2 , (110011)2, (110000)2 Convert the binary number (101011)2 to the decimal ans (43)10 Convert the binary (11.011)2 to the decimal ans (3.375)10 Convert the decimal numbers into binary (17)10, ( 20)10, (44)10, (97)10, (103)10 Octal number system Octal number system consists of 8 digits from 0 to 7. the base of octal number system Is 8.any digit in octal number system is always less than 8.the number (777)8 is valid. The number (778)8 is not valid because the digit 8 is not a number of this number system. Octal Binary Formula > 4 2 1 0 000 1 001 Position 3 2 1 0 Weight 83 82 81 80 2 010 Digit 7 6 2 1 3 011 4 100 5 101 6 110 7 111 Octal to Decimal Conversion Example 1: (236)8 Octal to binary (236)8=(2x82)+(3x81)+(6x80) (236)8 =128+24+6=158 2=010 3=011 6=110 (236)8=(010011110)2 Binary to octal Decimal to octal (100111001101)2 (185)10 Group of three binary digits 8 185 100 111 001 101 8 23 – 1 100=4 111=7 8 2-7 001=1 101=5 (4715)8 (271)8 Quotient Remainder 8 185 Convert (185)10 into an octal number 8 23 1 (185)10= ? (271)8 8 2 7 0 2 Exercise: Convert (160)10 into in to octal Convert (210)8 into binary (0110111001101)2 into octal Hexadecimal Number system The hexadecimal number system consists of 16 digits from 0 to 9 and A to F. the decimal value of A,B,C and F are 10, 11,12,13,14 and 15 respectively. The base of hexadecimal number system is 16.the hexadecimal number (723)16 is different than (723)10 Position 6 5 4 3 2 1 0 Weight 166 165 164 163 162 161 160 Convert the hexadecimal number (5C7)16 to a decimal number 162 162 162 Weight (5C7)16= (5x162)+(Cx161)+(7x160) 5C7)16= (5x162)+(12x161)+(7x160) 5 C 7 Position 1280+192+7=(1479)10 Hexadecimal Binary Convert between hexadecimal and binary 0 0000 Convert (10A8)16 to a binary number 1=0001 1 0001 0=0000 2 0010 A=1010 3 0011 8=1000 (0001000010101000)2 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 A 1010 B 1011 C 1100 D 1101 E 1110 F 1111 Binary arithmetic Binary addition 0+1=0 0+1=1 1+0=1 1+1=10 however 1 is carry if the next higher column exist and 0 is the answer: Add the binary number (1101)2 and (101)2 Example: 1101 101 _____ 10010 Example: Add the binary numbers (1111)2 and (111)2 1111 111 ________ 10110 Binary subtraction 0-0=0 1-0=1 1-1=0 0-1=1 (with borrow of 2 (as the base of a binary system is 2 from the next higher column Example: Subtract (1110)2 from (10010)2 10010 1110 ________ 0100 Subtract (10001)2 from (11010)2 11010 10001 ___________ 01001 1110 1100 11000 11000 - 0101 - 0101 - 00001 - 01111 Binary Multiplication 0x0=0 0x1=0 1x0=0 1x1=1 Multiply (1101)2 by (101)2 1101 101 ______ 1101 0000x 1101xx ________ 1000001 Binary Division Divide (1001110)2 by (100)2 10011 100 1001110 100 ________ 000111 100 _________ 0110 100 _________ 010 Divide (101101)2 by (101)2 1’s Complement of binary number The 1’s complement of number is obtained by changing all 1’s to 0’s and all 0’s to 1’s This is called taking complement or 1’s complement 1 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 2’s Complement of binary number The 2’s complement of a binary number is obtained by taking 1.s complement Of the given binary number and then adding 1 to the LSB(least significant bit) of the 1’s complement 0 1 1 0 0 0 0 1 By taking 1’s complement 0 1 1 0 0 0 0 1 1 _________________ 0 11 00 0 1 0 Gray code. The gray code is non-weighted.it means that the gray code does not have any weights assigned to its bit Position. The important feature of gray code is that it show only single bit change from one code word to the next in sequence. Also the first and last gray code has a single bit change this is why the gray code is called cyclic code or unit distance code. Example Binary to gray code 1 0 1 1 Binary number 1 1 1 0 gray code Gray code to binary 1 1 0 1 Gray code 1 0 0 1 Binary number Encoding Schemes Binary Coded Decimal (BCD): In this code each decimal digit is represented by a 4-bit binary number. BCD is a way to express each of the decimal digits with a binary code. In the BCD, with four bits we can represent sixteen numbers (0000 to 1111). But in BCD code only first ten of these are used (0000 to 1001). The remaining six code combinations i.e. 1010 to 1111 are invalid in BCD. EBCDIC: Extended binary coded decimal interchange code (EBCDIC) is an 8-bit binary code for numeric and alphanumeric characters. It was developed and used by IBM. It is a coding representation in which symbols, letters and numbers are presented in binary language. ASCII: ASCII is the acronym for the American Standard Code for Information Interchange. Most computers use ASCII codes to represent text, which makes it possible to transfer data from one computer to another. ANSI(American National Standard Institute) invented this code. ASCII two types- ASCII-7 ASCII-8 ASCII-7: It is a code for representing 128 English characters as numbers, with each letter assigned a number from 0 to 127. For example, the ASCII code for uppercase M is 77. ASCII-8: It is a code for representing 256 English characters as numbers. Unicode: A standard for representing characters as integers. Unlike ASCII, which uses 7 or 8 bits for each character, Unicode uses 16 bits, which means that it can represent more than 65,000 unique characters. This is a bit of overkill for English and Western-European languages, but it is necessary for some other languages, such as Greek, Chinese and Japanese. Many analysts believe that as the software industry becomes increasingly global, Unicode will eventually supplant ASCII as the standard character coding format. BCD addition Binary Coded Decimal (BCD) addition involves adding two BCD numbers together, just like regular binary addition, but with some adjustments to handle carry operations when the result exceeds the decimal range (0 to 9) for each digit. Add 6 if we want to represent number more than 9 4 0100 3 0011 +8 + 1000 +4 + 0100 ____ _____ ____ ______ 12 1100 7 0111 +0110 (it a 12 in binary but not in BCD) BCD support only upto 9 _________ we will add 6 in the ans 00010010 ans is 10010

Use Quizgecko on...
Browser
Browser