Arithmetic circuits  Binary addition  Binary Subtraction  Unsigned binary numbers  Sign-magnitude numbers  2 ’ S Complement representation  2 ’

Slides:



Advertisements
Similar presentations
Abdullah Said Alkalbani University of Buraimi
Advertisements

Date of Birth Design Problem
Boolean Algebra Variables: only 2 values (0,1)
Looking Inside the Black Box
ECE555 Lecture 10 Nam Sung Kim University of Wisconsin – Madison
CSE 370 Sample Final Exam Questions. 1) Logic Minimization CD AB F = Σm(0,6,7,8,9,11,15) + d(1,13)
ECE555 Lecture 8/9 Nam Sung Kim University of Wisconsin – Madison
- 1 - Using an SMT Solver and Craig Interpolation to Detect and Remove Redundant Linear Constraints in Representations of Non-Convex Polyhedra Christoph.
Register Transfer and Microoperations Part2
Worksheets.
Principles & Applications
Fast Algorithms for Finding Nearest Common Ancestors Dov Harel and Robert Endre Tarjan Fast Algorithms for Finding Nearest Common Ancestors SIAM J. COMPUT.
Binary Numbers.
Binary Numbers.
Binary Numbers.
8 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
15 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
1 Floating Point Representation and Arithmetic (see Patterson Chapter 4)
A Simple ALU Binary Logic.
B261 Systems Architecture
CSC 2510 Test 3 1. Give the names of the formula or rule that provides the answer for each of the following problems. Do not try to solve the problems!
Number Systems. Common Number Systems SystemBaseSymbols Used by humans? Used in computers? Decimal100, 1, … 9YesNo Binary20, 1NoYes Octal80, 1, … 7No.
Monika Gope Lecturer IICT, KUET
Princess Sumaya University
Truth Tables & Logic Expressions
Addition and multiplication
Discrete Mathematical Structures: Theory and Applications
Karnaugh Map Adjacent Squares
Digital Systems Introduction Binary Quantities and Variables
Digital Logical Structures
Logic Gates. Transistors as Switches ¡V BB voltage controls whether the transistor conducts in a common base configuration. ¡Logic circuits can be built.
Logic Gates Flip-Flops Registers Adders
Binary Values Chapter 2. Why Binary? Electrical devices are most reliable when they are built with 2 states that are hard to confuse: gate open / gate.
Chapter 4 Gates and Circuits.
Karnaugh Map Adjacent Squares
Number Systems (1)  Positional Notation N = (a n-1 a n-2... a 1 a 0. a -1 a a -m ) r (1.1) where. = radix point r = radix or base n = number of.
Rekenen en rekenschakelingen Ben Bruidegom AMSTEL Instituut FNWI UvA.
Binary Values and Number Systems
Prof. Dr. Nizamettin AYDIN edu. tr
Topics Adders Half Adder Full Adder Subtracter Half Subtracter
Number Systems  binary, octal, and hexadecimal numbers  why used  conversions, including to/from decimal  negative binary numbers  floating point.
Fixed-point and floating-point numbers CS370 Fall 2003.
UNIVERSITY OF MASSACHUSETTS Dept
Chapter 13 Numerical Issues
Binary Number Systems.
Number Systems Digital Logic By: Safwan Mawlood
CS1022 Computer Programming & Principles
Overview Digital Systems, Computers, and Beyond
Nat 4/5 Computing Science Lesson 1: Binary
Binary Lesson 4 Hexadecimal and Binary Practice. Counting to 15 Base Base Base 16 Base Base Base 16 Two Ten (Hex) Two Ten (Hex)
Binary Lesson 3 Hexadecimal. Counting to 15 Base Base Base 16 Base Base Base 16 Two Ten (Hex) Two Ten (Hex)
Binary Lesson 3 Hexadecimal. Counting to 15 Base Base Base 16 Base Base Base 16 Two Ten (Hex) Two Ten (Hex)
Princess Sumaya University
Combinational Circuits
Digital Logic & Design Lecture No. 3. Number System Conversion Conversion between binary and octal can be carried out by inspection.  Each octal digit.
Painting by Numbers: Visualisation of structured IPv6-Addressing.
Datorteknik IntegerAddSub bild 1 Integer arithmetic Depends what you mean by "integer" Assume at 3-bit string. –Then we define zero = 000 one = 001 Use.
Resistência dos Materiais, 5ª ed.
14-1 Bard, Gerstlauer, Valvano, Yerraballi EE 319K Introduction to Embedded Systems Lecture 14: Gaming Engines, Coding Style, Floating Point.
and M-ary Quadrature Amplitude Modulation (M-QAM)
NUMBER SYSTEMS The BASE of a number system Determines the number of digits available In our number system we use 10 digits: 0-9 The base in our system.
1/15/2015 Slide # 1 Binary, Octal and Hex Numbers Copyright Thaddeus Konar Introduction to Binary, Octal and Hexadecimal Numbers Thaddeus Konar.
Number Systems Decimal Binary Denary Octal Hexadecimal Click the mouse or Press the space bar to Continue.
Adders Module M8.1 Section 6.2. Adders Half Adder Full Adder TTL Adder.
GCSE Computing Theory © gcsecomputing.net 1 GCSE Computing 2.14 Data Representation Binary Arithmetic.
Combinatorial networks- II
The Logic of Compound Statements
Lecture 4 Last Lecture –Positional Numbering Systems –Converting Between Bases Today’s Topics –Signed Integer Representation Signed magnitude One’s complement.
Number System Submitted by: Submitted to: Devashish Bhardwaj Miss.Hina
Presentation transcript:

Arithmetic circuits  Binary addition  Binary Subtraction  Unsigned binary numbers  Sign-magnitude numbers  2 ’ S Complement representation  2 ’ S Complement arithmetic  Arithmetic building blocks

Number Systems (1)  Positional Notation N = (a n-1 a n-2... a 1 a 0. a -1 a a -m ) r (1.1) where. = radix point r = radix or base n = number of integer digits to the left of the radix point m = number of fractional digits to the right of the radix point a n-1 = most significant digit (MSD) a -m = least significant digit (LSD)  Polynomial Notation (Series Representation) N = a n-1 x r n-1 + a n-2 x r n a 0 x r 0 + a -1 x r a -m x r -m = (1.2)  N = (251.41) 10 = 2 x x x x x 10 -2

Number Systems (2)  Binary numbers  Digits = {0, 1}  ( ) 2 = 1 x x x x x x x 2 -2 = (26.75) 10  1 K (kilo) = 2 10 = 1,024, 1M (mega) = 2 20 = 1,048,576, 1G (giga) = 2 30 = 1,073,741,824  Octal numbers  Digits = {0, 1, 2, 3, 4, 5, 6, 7}  (127.4) 8 = 1 x x x x 8 -1 = (87.5) 10  Hexadecimal numbers  Digits = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}  (B65F) 16 = 11 x x x x 16 0 = (46,687) 10

Number Systems (3)  Important Number Systems (Table 1.1)

Powers of Decimal Equivalent ,024 2,048 4,096 8,192 16,384 32,768 65,536 Abbreviation 1K 2K 4K 8K 16K 32K 64K

Decimal-Binary Equivalences Decimal ,023 2,047 4,095 8,191 16,383 32,767 65,535 Binary Hexadecimal F 1F 3F 7F FF 1FF 3FF 7FF FFF 1FFF 3FFF 7FFF FFFF

Base Conversion (1)  Series Substitution Method  Expanded form of polynomial representation: N = a n-1 r n-1 + … + a 0 r 0 + a -1 r -1 + … + a -m r -m (1.3)  Conversation Procedure (base A to base B)  Represent the number in base A in the format of Eq  Evaluate the series using base B arithmetic.  Examples:  (11010) 2 ® ( ? ) 10 N = 1          0 = (16) 10 + (8) (2) = (26) 10  (627) 8 ® ( ? ) 10 N = 6       = (384) 10 + (16) 10 + (7) 10 = (407) 10

Base Conversion (2)  Radix Divide Method  Used to convert the integer in base A to the equivalent base B integer.  Underlying theory:  (N I ) A = b n-1 B n-1 + … + b 0 B 0 (1.4) Here, b i ’ s represents the digits of (N I ) B in base A.  N I  b n-1 B n-1 + … + b 1 B 1 + b 0 B 0 ) / B = (Quotient Q 1 : b n-1 B n-2 + … + b 1 B 0 ) + (Remainder R 0 : b 0 )  In general, (b i ) A is the remainder R i when Q i is divided by (B) A.  Conversion Procedure 1. Divide (N I ) B by (B) A, producing Q 1 and R 0. R 0 is the least significant digit, d 0, of the result. 2. Compute d i, for i = 1 … n - 1, by dividing Q i by (B) A, producing Q i+1 and R i, which represents d i. 3. Stop when Q i+1 = 0.

Base Conversion (3)  Examples  (315) 10 = (473) 8  (315) 10 = (13B) 16

Base Conversion (4)  Radix Multiply Method  Used to convert fractions.  Underlying theory:  (N F ) A = b -1 B -1 + b -2 B -2 + … + b -m B -m (1.5) Here, (N F ) A is a fraction in base A and b i ’ s are the digits of (N F ) B in base A.  B  N F = B  (b -1 B -1 + b -2 B -2 + … + b -m B -m ) = (Integer I -1 : b -1 ) + (Fraction F -2 : b -2 B -1 + … + b -m B -(m-1) )  In general, (b i ) A is the integer part I -i, of the product of F -(i+1)  (B A ).  Conversion Procedure 1. Let F -1 = (N F ) A. 2. Compute digits (b -i ) A, for i = 1 … m, by multiplying F i by (B) A, producing integer I -i, which represents (b -i ) A, and fraction F - (i+1). 3. Convert each digits (b -i ) A to base B.

Base Conversion (5)  Examples  (0.479) 10 = ( … ) 8 MSD ¬   ¬   ¬   8 LSD ¬   8 …  (0.479) 10 = ( … ) 2 MSD ¬   ¬   ¬   2 LSD ¬   2 …

Base Conversion (6)  General Conversion Algorithm  Algorithm 1.1 To convert a number N from base A to base B, use (a) the series substitution method with base B arithmetic, or (b) the radix divide or multiply method with base A arithmetic.  Algorithm 1.2 To convert a number N from base A to base B, use (a) the series substitution method with base 10 arithmetic to convert N from base A to base 10, and (b) the radix divide or multiply method with decimal arithmetic to convert N from base 10 to base B.  Algorithm 1.2 is longer, but easier and less error prone.

Base Conversion (7)  Example (18.6) 9 = ( ? ) 11 (a) Convert to base 10 using series substitution method: N 10 = 1    9 -1 = … = ( … ) 10 (b) Convert from base 10 to base 11 using radix divide and multiply method: ¬   ¬   ¬   11 N 11 = ( … ) 11

Base Conversion (8)  When B = A k  Algorithm 1.3 (a) To convert a number N from base A to base B when B = A k and k is a positive integer, group the digits of N in groups of k digits in both directions from the radix point and then replace each group with the equivalent digit in base B (b) To convert a number N from base B to base A when B = A k and k is a positive integer, replace each base B digit in N with the equivalent k digits in base A.  Examples  ( ) 2 = (127.4) 8 (group bits by 3)  ( ) 2 = (B65F) 16 (group bits by 4)

Binary addition = = = = 10 = 0 + carry of 1 into next position = 11 = 1 + carry of 1 into next position ABSUMCO HALF ADDER A B SUM CO Carry-Out = SUM =

Binary addition Carry-Out = SUM = 1-bit 8 Strings Full Adder with Carry-In and Carry-Out CIABSUMCO FULL ADDER A B SUM CO CI

1-bit 8 Strings Full Adder with Carry-In and Carry-Out Carry-Out = SUM = FULL ADDER A B SUM CO CI

Binary addition

Binary Subtraction = = = = 1 ต้องยืมจากหลักที่สูงกว่า มา 1 ABSUBBO HALF Subtractor A B SUB BO Borrow-Out = SUB =

Binary Subtraction Borrow-Out = SUB = 1-bit 8 Strings Full Subtractor with Borrow-In and Borrow -Out BIABSUBBO FULL Subtractor A B SUB BO BI

REPRESENTING UNSIGNED NUMBERS (Absolute value) A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 =00H B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 =FFH

REPRESENTING SIGNED NUMBERS in sign-magnitude form A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 = SIGN BIT Magnitude = B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 = SIGN BIT Magnitude = 52 10

REPRESENTING SIGNED NUMBERS in the 2 ’ S-complement system A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 = SIGN BIT True binary B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 = SIGN BIT 2 ’ s complement

Range of Sign-Magnitude Numbers A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 =+1 10 SIGN BIT B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 = A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 = B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 =-1 10

Range of Sign-Magnitude Numbers A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 =+1 10 SIGN BIT B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 = A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 = B7B7 B6B6 B5B5 B4B4 B3B3 B2B2 B1B1 B0B0 =-1 10

การคอมพลีเมนต์ เลขฐานสอง แบ่งออกเป็น  คอมพลีเมนต์ 1 (1 ’ s complement)  คอมพลีเมนต์ 2 (2 ’ s complement)  การคอมพลีเมนต์เลขฐานสองนี้นำไปใช้ เกี่ยวกับการคำนวณทางไมโครคอมพิวเตอร์ มาก เพราะว่าจะใช้ในลักษณะการลบด้วย วิธีการบวกด้วยคอมพลีเมนต์  สรุป การลบด้วยการบวกด้วยคอมพลีเมนต์ นั้นจะทำนองเดียวกับการคอมพลีเมนต์ เลขฐานสิบ

การคอมพลีเมนต์ เลขฐานสอง X 3 X 2 X 1 X 0 = ’s complement X 3 X 2 X 1 X 0 = ’s complement 2’s complement = 1’s complement + 1 X3X3 X3X3 X2X2 X2X2 X1X1 X1X1 X0X0 X0X0

Positive and Negative Numbers MagnitudePositiveNegative

2 ’ S-complement representation summary  Positive numbers always have a sign bit of 0, and negative numbers always have a sign bit of 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.

Example : Binary contentsHexadecimal contentsDecimal contents ____ ____ ___ ___ 14H DDH ___H BDH ___H 70H ___H 6EH _____H +20 ___ +47 ___ -125 ___ -19, F E B2DA

CASE 4 Both negative ADDITION CASE 1 Both positive ’s complement arithmetic CASE 2 Positive and smaller negative (-68) CASE 3 Positive and larger negative (- 115) (-78 )

SUBTRACTION CASE 1 Both positive ’s complement arithmetic CASE 2 Positive and smaller negative (- 16) (+27) CASE 3 Positive and larger negative (+ 108) CASE 4 Both negative (+78 )

INVERT A7A7 A6A6 A5A5 A4A4 A3A3 A2A2 A1A1 A0A0 Y7Y7 Y6Y6 Y5Y5 Y4Y4 Y3Y3 Y2Y2 Y1Y1 Y0Y A 7 -A Y 7 -Y Y 7 -Y INVLOGIC Controlled inverter

ADD/SUB A7A7 A 6 A5A5 A4A4 A 3 A 2 A 1 A0A0 S7S7 S 6 S5S5 S4S4 S 3 S2S2 S1S1 S0S0 B7B7 B 6 B5B5 B4B4 B 3 B 2 B 1 B 0 ADDITION A 7 A 6 A 5 A 4 A 3 A 2 A 1 A0A0 +B 7 B 6 B 5 B 4 B 3 B 2 B 1 B0B0 S 7 S 6 S 5 S 4 S 3 S 2 S 1 S0S0 SUBTRACTION A 7 A 6 A 5 A 4 A 3 A 2 A 1 A 0 +B 7 B 6 B 5 B 4 B 3 B 2 B 1 B 0 +1 S 7 S 6 S 5 S 4 S 3 S 2 S 1 S Binary adder-subtractor diagram S8S8

Binary adder-subtractor circuit ADD/