Unit - 3 NUMBER SYSTEM AND CODES

Slides:



Advertisements
Similar presentations
Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
Advertisements

EE1A2 Microprocessor Systems & Digital Logic Part I Digital Electronic System Design Dr. T. Collins.
A digital system is a system that manipulates discrete elements of information represented internally in binary form. Digital computers –general purposes.
CHAPTER 2 Number Systems, Operations, and Codes
Arithmetic Operations and Circuits
Chapter 1 Binary Systems 1-1. Digital Systems
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Level ISA3: Information Representation
Number Systems Decimal (Base 10) Binary (Base 2) Hexadecimal (Base 16)
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
1 CSE-221 Digital Logic Design (DLD) Lecture-1: Digital Systems & Number Systems.
Digital Fundamentals Floyd Chapter 2 Tenth Edition
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Number System and Codes
EE 261 – Introduction to Logic Circuits
1.6 Signed Binary Numbers.
Digital Logic Chapter 2 Number Conversions Digital Systems by Tocci.
Chapter 1 Number Systems and Codes 1. Outline 1. NUMBER SYSTEMS AND CODES 2. DIGITAL ELECTRONIC SIGNALS AND SWITCHES 3. BASIC LOGIC GATES 4. PROGRAMMABLE.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Number Systems and Codes
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Programmable Logic Controllers
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Copyright © Cengage Learning. All rights reserved. CHAPTER 2 THE LOGIC OF COMPOUND STATEMENTS THE LOGIC OF COMPOUND STATEMENTS.
Numeral Systems Subjects: Numeral System Positional systems Decimal
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
Digital Systems and Logic Design
Chapter 3 Data Representation
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
Digital Arithmetic and Arithmetic Circuits
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
Number systems & Binary codes MODULE 1 Digital Logic Design Ch1-2 Outline of Chapter 1  1.1 Digital Systems  1.2 Binary Numbers  1.3 Number-base Conversions.
Number Systems and Codes. CS2100 Number Systems and Codes 2 NUMBER SYSTEMS & CODES Information Representations Number Systems Base Conversion Negative.
1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19.
Number systems, Operations, and Codes
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
EEL 3801C EEL 3801 Part I Computing Basics. EEL 3801C Data Representation Digital computers are binary in nature. They operate only on 0’s and 1’s. Everything.
Data Representation, Number Systems and Base Conversions
Computer Math CPS120 Introduction to Computer Science Lecture 4.
AEEE2031 Data Representation and Numbering Systems.
Number Systems & Operations
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
MECH1500 Chapter 3.
Introduction To Number Systems Binary System M. AL-Towaileb1.
Chapter 1: Binary Systems
Chapter 1 Number Systems Digital Electronics. Topics discussed in last lecture Digital systems Advantages of using digital signals over analog. Disadvantages.
Introduction to Digital Electronics Lecture 2: Number Systems.
©2010 Cengage Learning SLIDES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION Click the mouse to move to the next page. Use the ESC key to exit.
Computer Math CPS120 Introduction to Computer Science Lecture 7.
CHAPTER 3 BINARY NUMBER SYSTEM. Computers are electronic machines which operate using binary logic. These devices use two different values to represent.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Chapter 6. Digital Arithmetic: Operations and Circuits
Unit 1 Introduction Number Systems and Conversion.
Chapter 1 Digital Systems and Binary Numbers
Lecture No. 4 Number Systems
Digital Systems and Number Systems
Introduction The term digital is derived from the way computers perform operation, by counting digits. Application of digital technology: television, communication.
Chapter 3 Data Representation
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Data Structures Mohammed Thajeel To the second year students
BEE1244 Digital System and Electronics BEE1244 Digital System and Electronic Chapter 2 Number Systems.
Numbering System TODAY AND TOMORROW 11th Edition
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
Copyright © Cengage Learning. All rights reserved.
CHAPTER 69 NUMBER SYSTEMS AND CODES
Presentation transcript:

Unit - 3 NUMBER SYSTEM AND CODES

Binary Number System Is a system that uses only the digits 0 and 1 as codes. To represent decimal numbers and letters of the alphabet with the binary code, we have to use different strings of binary digits for each number of letter. Ex: Morse code – dots and dashes Decimal binary counting: Decimal Odometer, Reset-and-Carry, Binary Odometer

Why binary numbers are used ? Almost all digital computers and systems are based on binary (two-state) operation. For instance, the switch shown in figure can be open or closed; therefore, a switch is one example of a natural binary device. Transistor ckt switch Tape rec. Disk drive

Table 5.1 - 4-digit Binary numbers Bit – is the abbreviation for binary digit. Nibble – binary number with 4 bits Byte – binary number with 8 bits So, bit = X Nibble = XXXX Byte=XXXXXXXX Where X may be 0 or 1

Binary-to-Decimal Conversion Positional notations and weights Binary Weights Streamlined Method Fractions Mixed Numbers

1. Positional Notations and Weights The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal numbers is ten, because only ten symbols (0 through 9) are used to represent any number. The column weights of decimal numbers are powers of ten that increase from right to left beginning with 100 =1: …105 104 103 102 101 100.

We can express any decimal integer (a whole number) in units, tens, hundreds, thousands, so on. Ex: Decimal number 2495 may written as 2495 = 2000+400+90+5 In power of 10, this becomes, 2495 = 2(103) + 4(102)+9(101)+5(100) The decimal number system is an example of positional notation, each digit position has a weight or value. With decimal number the weights are units, tens, hundreds, thousands so on.

The sum of all the digits multiplied by their weights gives the total amount being represented. Ex: 2 X 1000+4X100+9X10+5X1 = 2945 Binary weights: In a similar way, we can write any binary number in terms of weights. Ex: binary number 111 becomes 111 = 100 + 10 + 1 In decimal numbers, this may be rewritten as 7 = 4 + 2 +1

Each digit position in binary number has a weight. The least significant digit (right) has a weight of 1. second position from the right has a weight of 2; next 4; and then 8,16,32 so on. These weights are in ascending powers of 2; Therefore, we can write 7 =1(22) + 1(21) + 1(20) Refer table 5.2 Binary system

2. Streamlined method: We can streamline binary-to-decimal by the following procedure: Write the binary number Directly under the binary number write 1,2,4,8,16…… working from right to left If a zero appears in a digit position, cross out the decimal weight for that position. Add the remaining weights to obtain the decimal equivalent.

3. Fractions: For fractional decimal numbers, the column weights are negative powers of ten that decrease from left to right: . 10-1 10-2 10-3…. For fractional binary numbers, the column weights are negative powers of two that decrease from left to right: . 2-1 2-2 2-3 2-4 … Or decimal equivalence . 0.5 0.25 0.125….

4. Mixed numbers: For mixed numbers ( numbers with an integer and a fractional part), handle each part according to the rules. For decimal numbers: 104 103 102 101 100. 10-1 10-2 10-3…. For binary numbers: 22 21 20. 2-1 2-2 2-3 2-4 … Refer table 5.3 Powers of 2

Hexadecimal Numbers Are used extensively in microprocessor work, They are much shorter than binary numbers, so easy to write and remember. Has a base of 16. Although any 16 digits may be used, everyone uses 0 to 9 and A to F. After reaching 9 in the hexadecimal system, we can continue counting as A, B, C, D,E,F Hexadecimal Odometer:

Hexadecimal-to-Binary Conversion To convert a hexadecimal number to a binary number, convert each hexadecimal digit to its 4-bit equivalent. Ex: 9AF to Binary number Binary-to-Hexadecimal Conversion Ex: 1000 1100 to Hexadecimal Hexadecimal-to-Decimal Conversion In hexadecimal number system each digit position corresponds to a power of 16. The weights of the digit positions in a hexadecimal numbers are as follows: 163 162 161 160 . 16-1 16-2 16-3 Decimal-to-Hexadecimal Conversion hex dabble – Divide decimal number successively by 16

BCD-8421 and BCD-2421code The usual method is to follow 8421 encoding which employs conventional route of weight placements like 8 representing the weight of the 4th place (as 24-1=8), 4 i.e. 23-1 of the 3rd place, 2 i.e. 22-1 of the 2nd place and 1 i.e. 21-1 of the 1st place. The 2421 code is similar to 8421 code except for the fact that the weight assigned to 4th place is 2 and not 8.

The ASCII Code Alphanumeric code to get information into and out of computer. Known as American Standard Code for Information Interchange Pronounced as ask’-ee Using the code The ASCII code is a 7 bit code whose format is X6 X5 X4 X3 X2 X1 X0

The ASCII Code

Parity bit The ASCII code is used for sending digital data over telephone line. To catch these error, a parity bit is usually transmitted along with the original bits. Then a parity checker at the receiver end an test for even or odd parity, whichever parity has been prearranged between the sender and the receiver. Since ASCII code uses 7 bits, the addition of a parity bit to the transmitted data produces an 8-bit number in this format: X7X6 X5 X4 X3 X2 X1 X0 - Ideal length

Excess-3 Code Is an important 4-bit code sometimes used with Binary – Coded Decimal (BCD) numbers. To convert any decimal numbers into its excess-3 form, add 3 to each decimal digit, and then convert the sum to a BCD number. Ex: convert 12 to Excess-3 code Useful for BCD arithmetic 9’s Complement of any Excess-3 coded number can be obtained by complementing each bit.

Excess-3 Code

Gray Code Gray code is a code that has a single bit change between one code word and the next in a sequence. Gray code is used to avoid problems in systems where an error can occur if more than one bit changes at a time. The disadvantage with gray code is that it is not good for arithmetic operation. Object moving along a track with sensors (a) binary coded and (b) gray coded.

(a) Binary to Gray converter and (b) Gray to Binary converter

Decimal Binary Gray code 0 1 2 3 4 5 6 7 8 9 10 11 12 13 1415 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101 1111 1110 1010 1011 1001 1000 Gray Code

ARITHMETIC CIRCUITS

Binary Addition Four cases to remember 0+0=0 0+1=1 1+0=1 1+1=10 Subscripts 2binary 8octal 10decemal 16hexadecimal Larger binary numbers 11100 +11010 ------------ 110110 In last column 1+1+1=10+1=11

Binary Subtraction Four basic cases 0-0=0 1-0=1 1-1=0 10-1=1

2’s Complement Representation Inverters produce the 1’s complement. 1’s complement of 1011 is 0100 2’s Complement 2’s complement = 1’s complement + 1. 2’s complement of 1011 is 0100+1=0101.

Sign-magnitude number In signed magnitude number (–) is represented by 1 and (+) as 0. +101=0101 - 001=1001 Range of sign magnitude number 0 to 255 becomes -127 to +127

2’s Complement Representation Things to remember: Positive numbers always have a sign bit 0, and negative number always have a sign bit 1. Positive numbers are stored in sign-magnitude form. Negative numbers are stored as 2’s complements Taking the 2’s complement is equivalent to a sign change.

2’s Complement Arithmetic 2’s Complement representation has become a universal code for processing positive and negative numbers. Addition: Four possible cases: 1. both numbers positive 2. a positive number and a smaller negative number 3. a negative number and a smaller positive 4. both numbers are negative

Conclusion In every case, 2’s complement addition works. In other words, as long as positive and negative numbers are expressed in 2’s complement representation, an adding circuit will automatically produce the correct answer.( Assumption: the decimal sum is within the -128 to +127)

Subtraction: Format for subtraction is: Minuend - Subtrahend ----------------- Difference Four possible cases: 1. both numbers positive 2. a positive number and a smaller negative number 3. a negative number and a smaller positive 4. both numbers are negative

Arithmetic building blocks Half Adder Full Adder

Controlled Inverter When the INVERT is low, it transmits the 8-bit input to the output; When the INVERT is high, it transmits the 1’s complement. Ex: If the input number is A7….A0 = 0110 1110

The Adder-Subtracter We can connect full-adders to add or subtract binary numbers. The circuit is laid out from right to left, similar to the way we add binary numbers.

ARITHMETIC LOGIC UNIT Arithmetic Logic Unit, popularly called ALU is multifunctional device that can perform both arithmetic and logic function. A mode selector input (M) decides whether ALU performs a logic operation or an arithmetic operation IC 74181 is a 4-bit ALU that can generate 16 different kinds of outputs in each mode selected by four selection inputs S3, S2, S1 and S0.

Functional representation of ALU IC 74181 and Truth Table

Binary Multiplication and Division Multiplication is done with addition instructions and division with subtraction instruction. Therefore, an adder-subtracter is all that is needed for addition, subtraction, multiplication, and division. Ex: Multiplication is equivalent to repeated addition 8 X 4 = ? The first number is called the multiplicand and second no is multiplier. Multiplying 8 by 4 is the same as adding 8 four times This approach is known as programmed multiplication by repeated addition. Division – equivalent to repeated subtraction

Arithmetic circuits using HDL We describe a full adder circuit and create a test bench to test it output Sum and Carry (represented by sm and cr in following Verilog code) is expressed by equations Sum: sm = AB+BC+CA Carry: cr = ABC module testFullAdder; reg A,B,C; wire sm, cr; fulladder fa1(A,B,C,sm,cr);// Circuit instantiated with fa1 initial // simulation begins begin {A,B,C} = 3’b000; //Initialization A=0,B=0,C=0 repeat (7) //repeats following statement seven times #20 {A,B,C}={A,B,C} + 3’b001; //delay of 20 ns and then increment by 1 #20 $finish; // simulation ends after generating 8 combinations of ABC end //total time of simulation 7x20+20=160 ns endmodule module fulladder(A,B,C,sm,cr); // Description of fulladder Circuit input A,B,C; output sm,cr; assign sm = (A&B)|(B&C)|(C&A); assign cr = A^B^C;