Digital Systems and Binary Numbers

Similar documents
Chap 1. Digital Computers and Information

Logic and Computer Design Fundamentals. Chapter 1 Digital Computers and Information

DIGITAL SYSTEM DESIGN

Korea University of Technology and Education

ECE 20B, Winter Purpose of Course. Introduction to Electrical Engineering, II. Administration

Digital Systems and Binary Numbers

Chapter 1. Digital Systems and Binary Numbers

Lecture (02) Operations on numbering systems

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom.

Digital Systems and Binary Numbers

CS 121 Digital Logic Design. Chapter 1. Teacher Assistant. Hadeel Al-Ateeq

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

BINARY SYSTEM. Binary system is used in digital systems because it is:

Lecture (03) Binary Codes Registers and Logic Gates

Digital Fundamentals

SE311: Design of Digital Systems

CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER

Computer Organization

Lecture 2: Number Systems

EEM 232 Digital System I

MC1601 Computer Organization

CHW 261: Logic Design

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

Review of Number Systems

Number System. Introduction. Decimal Numbers

D I G I T A L C I R C U I T S E E

Fundamentals of Programming (C)

Electronic Data and Instructions

Numbering systems. Dr Abu Arqoub

Lecture (01) Digital Systems and Binary Numbers By: Dr. Ahmed ElShafee

Binary Systems and Codes

Number Systems Base r

CHAPTER 2 (b) : AND CODES

UNIT 7A Data Representation: Numbers and Text. Digital Data

DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) COURSE / CODE NUMBER SYSTEM

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc.

Positional Number System

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

Electronics Engineering ECE / E & T

Lecture (01) Introduction Number Systems and Conversion (1)

LOGIC DESIGN. Dr. Mahmoud Abo_elfetouh

MACHINE LEVEL REPRESENTATION OF DATA

DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes. Error Detection Codes

CS & IT Conversions. Magnitude 10,000 1,

Digital Fundamentals

Digital Fundamentals

Number System (Different Ways To Say How Many) Fall 2016

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

UNIT 2 NUMBER SYSTEM AND PROGRAMMING LANGUAGES

Data Representation and Binary Arithmetic. Lecture 2

Chapter 1 Review of Number Systems

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Chapter 2. Data Representation in Computer Systems

MYcsvtu Notes DATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Number Systems CHAPTER Positional Number Systems

3.1. Unit 3. Binary Representation

UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

Chapter 2 Bits, Data Types, and Operations

CHAPTER 2 Data Representation in Computer Systems

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

CHAPTER 2 Data Representation in Computer Systems

Binary Codes. Dr. Mudathir A. Fagiri

in this web service Cambridge University Press

Fundamentals of Programming

Level ISA3: Information Representation

Chapter 2 Bits, Data Types, and Operations

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System


Introduction to Numbering Systems

EE 109 Unit 2. Binary Representation Systems

Microcomputers. Outline. Number Systems and Digital Logic Review

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

Chapter 4 Arithmetic Functions

Ms Sandhya Rani Dash UNIT 2: NUMBER SYSTEM AND CODES. 1.1 Introduction

Chapter 3 Part 2 Combinational Logic Design

Binary. Hexadecimal BINARY CODED DECIMAL

Final Labs and Tutors

Unit 3. Analog vs. Digital. Analog vs. Digital ANALOG VS. DIGITAL. Binary Representation

Chapter 2 Bits, Data Types, and Operations

Hybrid Electronics Laboratory

NUMBER SYSTEMS AND CODES

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Chapter 2 Bits, Data Types, and Operations

Chapter 3: part 3 Binary Subtraction

Number Systems. Dr. Tarek A. Tutunji Philadelphia University, Jordan

World Inside a Computer is Binary

Digital Logic Lecture 2 Number Systems

Chapter 2 Number Systems and Codes Dr. Xu

(+A) + ( B) + (A B) (B A) + (A B) ( A) + (+ B) (A B) + (B A) + (A B) (+ A) (+ B) + (A - B) (B A) + (A B) ( A) ( B) (A B) + (B A) + (A B)

EE 109 Unit 3. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

Computer Organization

COMPUTER ORGANIZATION AND ARCHITECTURE

Transcription:

Digital Systems and Binary Numbers ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C. Spring, 2018 ldvan@cs.nctu.edu.tw http://www.cs.nctu.edu.tw/~ldvan/

Outline Digital Systems Binary Numbers Number-Base Conversion Octal and Hexadecimal Number Signed Binary Numbers Binary Codes Binary Storage and Registers Binary Logic DCD-01-2

Digital age and information age Digital computers general purposes many scientific, industrial and commercial applications Digital systems smartphone digital camera electronic calculators, PDA's digital TV Digital System Discrete information-processing systems manipulate discrete elements of information DCD-01-3

A Digital Computer Example Memory CPU Control unit Datapath Inputs: keyboard, mouse, modem, microphone, posture Input/Output Synchronous or Asynchronous? Outputs: LCD, modem, speakers DCD-01-4

Signal An information variable represented by physical quantity For digital systems, the variable takes on digital values Two level, or binary values are the most prevalent values Binary values are represented abstractly by: digits 0 and 1 words (symbols) False (F) and True (T) words (symbols) Low (L) and High (H) words On and Off. Binary values are represented by values or ranges of values of physical quantities. DCD-01-5

Signal Analog signal t->y: y=f(t), y:c, n:c Discrete-time signal n->y: y=f(nt), y:c, n:z Digital signal n->y: y=d{f(nt)}, y:z,n:z y y y ( 2) (1) (1) ( 3) (1011) 2 (1000) 2 (1000) 2 (1110) 2 t n n Analog Signal Discrete-Time Signal Digital Signal DCD-01-6

Decimal number a 5 a 4 a 3 a 2 a 1 a 0.a 1 a 2 a 3 Binary Numbers a j Base or radix L Decimal point Power 10 a 10 a 10 a 10 a 10 a 10 a 10 a 10 a 10 a L 5 4 3 2 1 0 1 2 3 5 4 3 2 1 0 1 2 3 Example: 3 2 1 0 7,329 7 10 3 10 2 10 9 10 General form of base-r system a r a r L a r a r a a r a r L a r n n 1 2 1 1 2 m n n 1 2 1 0 1 2 m Coefficient: a j = 0 to r 1 DCD-01-7

Example: Base-2 number (11010.11) (26.75) 2 10 Binary Numbers 1 2 1 2 0 2 1 2 0 2 1 2 1 2 4 3 2 1 0 1 2 Example: Base-5 number (4021.2) 5 3 2 1 0 1 4 5 0 5 2 5 1 5 2 5 (511.5) 4 10 Example: Base-8 number (127.4) 1 8 2 8 1 2 8 7 8 0 4 8 1 (87.5) 10 Example: Base-16 number (B65F) 11 16 6 16 5 16 15 16 (46,687) 3 2 1 0 16 10 DCD-01-8

Example: Base-2 number (110101) 2 32 16 4 1 (53) 10 Binary Numbers Special Powers of 2 2 10 (1024) is Kilo, denoted "K" 2 20 (1,048,576) is Mega, denoted "M" 2 30 (1,073, 741,824) is Giga, denoted "G" 2 40 (1.0995116e+12) is Tera, denoted T" 2 50 (1.1258999e+15) is Peta, denoted P" DCD-01-9

Binary Numbers Arithmetic operations with numbers in base r follow the same rules as decimal numbers. DCD-01-10

Addition Augend: 101101 Addend: +100111 Sum: 1010100 Binary Arithmetic Subtraction The binary multiplication table is simple: Minuend: 101101 Subtrahend: 100111 Difference: 000110 0 0 = 0 1 0 = 0 0 1 = 0 1 1 = 1 Extending multiplication to multiple digits: Multiplication Multiplicand 1011 Multiplier 101 Partial Products 1011 0000-1011 - - Product 110111 DCD-01-11

Octal and Hexadecimal Numbers Numbers with different bases: Table 1.2. DCD-01-12

Example1.1 Number-Base Conversions Convert decimal 41 to binary. The process is continued until the integer quotient becomes 0. Digital Circuit Design 10/2 5/2 2/2 1/2 5 2 1 0 DCD-01-13

Number-Base Conversions Digital Circuit Design The arithmetic process can be manipulated more conveniently as follows: Answer=(101001) 2 DCD-01-14

Example 1.2 Number-Base Conversions Convert decimal 153 to octal. The required base r is 8. Digital Circuit Design DCD-01-15

Example1.3 Convert (0.6875) 10 to binary. Number-Base Conversions Digital Circuit Design The process is continued until the fraction becomes 0 or until the number of digits has sufficient accuracy. To convert a decimal fraction to a number expressed in base r, a similar procedure is used. However, multiplication is by r instead of 2, and the coefficients found from the integers may range in value from 0 to r 1 instead of 0 and 1. DCD-01-16

Number-Base Conversions Example1.4 Convert (0.513) 10 to octal. From Examples 1.1 and 1.3: (41.6875) 10 = (101001.1011) 2 From Examples 1.2 and 1.4: (153.513) 10 = (231.406517) 8 DCD-01-17

Number-Base Conversions Conversion from binary to octal can be done by positioning the binary number into groups of three digits each, starting from the binary point and proceeding to the left and to the right. Digital Circuit Design (10 110 001 101 011. 111 100 000 110) 2 = (26153.7406) 8 2 6 1 5 3 7 4 0 6 Conversion from binary to hexadecimal is similar, except that the binary number is divided into groups of four digits: Conversion from octal or hexadecimal to binary is done by reversing the preceding procedure. DCD-01-18

Complements There are two types of complements for each base-r system: the radix complement and diminished radix complement. the r's complement and the second as the (r 1)'s complement. Diminished Radix Complement Example: For binary numbers, r = 2 and r 1 = 1, so the 1's complement of N is (2 n 1) N. Example: DCD-01-19

Complements Radix Complement The r's complement of an n-digit number N in base r is defined as r n N for N 0 and as 0 for N = 0. Comparing with the (r 1) 's complement, we note that the r's complement is obtained by adding 1 to the (r 1) 's complement, since r n N = [(r n 1) N] + 1. Example: Base-10 The 10's complement of 012398 is 987602 The 10's complement of 246700 is 753300 Example: Base-2 The 2's complement of 1101100 is 0010100 The 2's complement of 0110111 is 1001001 DCD-01-20

Complements Subtraction with Complements The subtraction of two n-digit unsigned numbers M N in base r can be done as follows: an DCD-01-21

Example 1.5 Complements Using 10's complement, subtract 72532 3250. Example 1.6 Using 10's complement, subtract 3250 72532 There is no end carry. Therefore, the answer is (10's complement of 30718) = 69282. DCD-01-22

Complements Example 1.7 Given the two binary numbers X = 1010100 and Y = 1000011, perform the subtraction (a) X Y and (b) Y X by using 2's complement. There is no end carry. Therefore, the answer is Y X = (2's complement of 1101111) = 0010001. DCD-01-23

Complements Subtraction of unsigned numbers can also be done by means of the (r 1)'s complement. Remember that the (r 1) 's complement is one less than the r's complement. Example 1.8 Repeat Example 1.7, but this time using 1's complement. There is no end carry, Therefore, the answer is Y X = (1's complement of 1101110) = 0010001. DCD-01-24

Signed Binary Numbers Digital Circuit Design To represent negative integers, we need a notation for negative values. It is customary to represent the sign with a bit placed in the leftmost position of the number. The convention is to make the sign bit 0 for positive and 1 for negative. Example: DCD-01-25

Signed Binary Numbers Digital Circuit Design Table 3 lists all possible four-bit signed binary numbers in the three representations. DCD-01-26

Arithmetic Addition Signed Binary Numbers The addition of two numbers in the signed-magnitude system follows the rules of ordinary arithmetic. If the signs are the same, we add the two magnitudes and give the sum the common sign. If the signs are different, we subtract the smaller magnitude from the larger and give the difference the sign if the larger magnitude. The addition of two signed binary numbers with negative numbers represented in signed-2's-complement form is obtained from the addition of the two numbers, including their sign bits. A carry out of the sign-bit position is discarded. Example: DCD-01-27

Signed Binary Numbers Arithmetic Subtraction In 2 s-complement form: 1. Take the 2 s complement of the subtrahend (including the sign bit) and add it to the minuend (including sign bit). 2. A carry out of sign-bit position is discarded. Example: ( A) ( B) ( A) ( B) ( A) ( B) ( A) ( B) ( 6) ( 13) (11111010 11110011) (11111010 + 00001101) 00000111 (+ 7) DCD-01-28

BCD Code Digital Circuit Design BCD Code A number with k decimal digits will require 4k bits in BCD. Decimal 396 is represented in BCD with 12bits as 0011 1001 0110, with each group of 4 bits representing one decimal digit. A decimal number in BCD is the same as its equivalent binary number only when the number is between 0 and 9. A BCD number greater than 10 looks different from its equivalent binary number, even though both contain 1's and 0's. Moreover, the binary combinations 1010 through 1111 are not used and have no meaning in BCD. DCD-01-29

BCD Code Example: Consider decimal 185 and its corresponding value in BCD and binary: BCD Addition DCD-01-30

BCD Code Example: Consider the addition of 184 + 576 = 760 in BCD: Decimal Arithmetic 1 DCD-01-31

Other Decimal Codes Other Decimal Codes Digital Circuit Design DCD-01-32

Gray Code Digital Circuit Design Gray Code DCD-01-33

Gray Code Does this special Gray code property have any value? An Example: Optical Shaft Encoder 111 000 100 000 B 0 110 B 1 B 2 001 101 001 101 010 111 G 0 G 1 G 2 011 100 011 (a) Binary Code for Positions 0 through 7 110 010 (b) Gray Code for Positions 0 through 7 DCD-01-34

ASCII Character Code Digital Circuit Design ASCII Character Code DCD-01-35

ASCII Character Code Digital Circuit Design ASCII Character Code DCD-01-36

ASCII Character Code American Standard Code for Information Interchange (Refer to Table 1.7) A popular code used to represent information sent as character-based data. It uses 7-bits to represent: 94 Graphic printing characters. 34 Non-printing characters Some non-printing characters are used for text format (e.g. BS = Backspace, CR = carriage return) Other non-printing characters are used for record marking and flow control (e.g. STX and ETX start and end text areas). DCD-01-37

ASCII Character Code ASCII has some interesting properties: Digits 0 to 9 span Hexadecimal values 30 16 to 39 16. Upper case A - Z span 41 16 to 5A 16. Lower case a - z span 61 16 to 7A 16. Lower to upper case translation (and vice versa) occurs by flipping bit 6. Delete (DEL) is all bits set,a carryover from when punched paper tape was used to store messages. Punching all holes in a row erased a mistake! DCD-01-38

Error Detection Code Digital Circuit Design Error-Detecting Code To detect errors in data communication and processing, an eighth bit is sometimes added to the ASCII character to indicate its parity. A parity bit is an extra bit included with a message to make the total number of 1's either even or odd. Example: Consider the following two characters and their even and odd parity: DCD-01-39

Error Detection Code Error-Detecting Code Redundancy (e.g. extra information), in the form of extra bits, can be incorporated into binary code words to detect and correct errors. A simple form of redundancy is parity, an extra bit appended onto the code word to make the number of 1 s odd or even. Parity can detect all single-bit errors and some multiple-bit errors. A code word has even parity if the number of 1 s in the code word is even. A code word has odd parity if the number of 1 s in the code word is odd. DCD-01-40

Conversion or Coding? Do NOT mix up conversion of a decimal number to a binary number with coding a decimal number with a BINARY CODE. 13 10 = 1101 2 (This is conversion) 13 0001 0011 (This is coding) DCD-01-41

Binary Storage and Registers Registers A binary cell is a device that possesses two stable states and is capable of storing one of the two states. A register is a group of binary cells. A register with n cells can store any discrete quantity of information that contains n bits. n cells 2 n possible states A binary cell two stable state store one bit of information examples: flip-flop circuits, ferrite cores, capacitor A register a group of binary cells AX in x86 CPU Register Transfer a transfer of the information stored in one register to another one of the major operations in digital system DCD-01-42

Transfer of Information DCD-01-43

Example of Binary Information Processing Digital Circuit Design DCD-01-44

Binary Logic Digital Circuit Design Binary logic consists of binary variables and a set of logical operations. The variables are designated by letters of the alphabet, such as A, B, C, x, y, z, etc, with each variable having two and only two distinct possible values: 1 and 0, There are three basic logical operations: AND, OR, and NOT. DCD-01-45

Binary Logic The truth tables for AND, OR, and NOT are given in Table 1.8. DCD-01-46

Binary Logic Logic gates Example of binary signals DCD-01-47

Logic gates Binary Logic Graphic Symbols and Input-Output Signals for Logic gates: Input-Output signals for gates DCD-01-48

Binary Logic Logic gates Graphic Symbols and Input-Output Signals for Logic gates: DCD-01-49

Conclusion You have learned the following terms: Binary number Number Conversion Complement Simple arithmetic Binary codes Storage and register Binary logic DCD-01-50