Digital Arithmetic and Arithmetic Circuits

Slides:



Advertisements
Similar presentations
Combinational Circuits. Analysis Diagram Designing Combinational Circuits In general we have to do following steps: 1. Problem description 2. Input/output.
Advertisements

EET 1131 Unit 7 Arithmetic Operations and Circuits
Comparator.
DPSD This PPT Credits to : Ms. Elakya - AP / ECE.
Arithmetic Operations and Circuits
Parallel Adder Recap To add two n-bit numbers together, n full-adders should be cascaded. Each full-adder represents a column in the long addition. The.
Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design.
ECE 331 – Digital System Design
ECE C03 Lecture 61 Lecture 6 Arithmetic Logic Circuits Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Chapter # 5: Arithmetic Circuits Contemporary Logic Design Randy H
Lecture 8 Arithmetic Logic Circuits
Design of Arithmetic Circuits – Adders, Subtractors, BCD adders
1 COMP541 Arithmetic Circuits Montek Singh Mar 20, 2007.
Digital Arithmetic Wen-Hung Liao, Ph.D.. Objectives Perform binary addition, subtraction, multiplication, and division on two binary numbers. Add and.
ECE 301 – Digital Electronics
ECE 301 – Digital Electronics
ECE 331 – Digital System Design
Chapter 5 Arithmetic Logic Functions. Page 2 This Chapter..  We will be looking at multi-valued arithmetic and logic functions  Bitwise AND, OR, EXOR,
Chapter 7 Arithmetic Operations and Circuits Hexadecimal Arithmetic 4 binary bits represent a single hexadecimal digit Addition –Add the digits.
Logic Gates Combinational Circuits
CS 105 Digital Logic Design
Outline Analysis of Combinational Circuits Signed Number Arithmetic
Chapter 6 Digital Arithmetic: Operations and Circuits ECE 221 Intro
Logical Circuit Design Week 8: Arithmetic Circuits Mentor Hamiti, MSc Office ,
+ CS 325: CS Hardware and Software Organization and Architecture Combinational Circuits 1.
Introduction to Chapter 6  Digital circuits are frequently used for arithmetic operations  Fundamental arithmetic operations on binary numbers and digital.
Chapter 4 – Arithmetic Functions and HDLs Logic and Computer Design Fundamentals.
Fall 2004EE 3563 Digital Systems Design EE 3563 Comparators  Comparators determine if two binary inputs are equal  Some will signal greater than/less.
Chapter # 5: Arithmetic Circuits
Chapter 6-1 ALU, Adder and Subtractor
Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.
Figure 5.1 Conversion from decimal to binary. Table 5.1 Numbers in different systems.
Week #5 Arithmetic Circuits
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.
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Logic Gates Logic gates are electronic digital circuit perform logic functions. Commonly expected logic functions are already having the corresponding.
درس مدارهای منطقی دانشگاه قم مدارهای منطقی محاسباتی تهیه شده توسط حسین امیرخانی مبتنی بر اسلایدهای درس مدارهای منطقی دانشگاه.
COE 202: Digital Logic Design Combinational Circuits Part 2 KFUPM Courtesy of Dr. Ahmad Almulhem.
Half Adder & Full Adder Patrick Marshall. Intro Adding binary digits Half adder Full adder Parallel adder (ripple carry) Arithmetic overflow.
1 CS 151: Digital Design Chapter 4: Arithmetic Functions and Circuits 4-1,2: Iterative Combinational Circuits and Binary Adders.
Combinational Circuits
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell University.
ECE 331 – Digital System Design Multi-bit Adder Circuits, Adder/Subtractor Circuit, and Multiplier Circuit (Lecture #12)
CS/EE 3700 : Fundamentals of Digital System Design Chris J. Myers Lecture 5: Arithmetic Circuits Chapter 5 (minus 5.3.4)
1 Chapter 4 Combinational Logic Logic circuits for digital systems may be combinational or sequential. A combinational circuit consists of input variables,
CHAPTER 2 Digital Combinational Logic/Arithmetic Circuits
1 Fundamentals of Computer Science Combinational Circuits.
EENG 2710 Chapter 4 Modular Combinational Logic 1.
Number Representation and Arithmetic Circuits
1 Lecture 14 Binary Adders and Subtractors. 2 Overview °Addition and subtraction of binary data is fundamental Need to determine hardware implementation.
Number Representation (Part 2) Computer Architecture (Fall 2006)
Lecture #23: Arithmetic Circuits-1 Arithmetic Circuits (Part I) Randy H. Katz University of California, Berkeley Fall 2005.
ECE DIGITAL LOGIC LECTURE 15: COMBINATIONAL CIRCUITS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 10/20/2015.
CS151 Introduction to Digital Design Chapter 4: Arithmetic Functions and HDLs 4-1: Iterative Combinational Circuits 4-2: Binary Adders 1Created by: Ms.Amany.
Explain Half Adder and Full Adder with Truth Table.
Logic Design (CE1111 ) Lecture 4 (Chapter 4) Combinational Logic Prepared by Dr. Lamiaa Elshenawy 1.
ETE 204 – Digital Electronics Combinational Logic Design Single-bit and Multiple-bit Adder Circuits [Lecture: 9] Instructor: Sajib Roy Lecturer, ETE,ULAB.
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
Chapter 6. Digital Arithmetic: Operations and Circuits
Gunjeet Kaur Dronacharya Group of Institutions. Binary Adder-Subtractor A combinational circuit that performs the addition of two bits is called a half.
1 Computer Architecture & Assembly Language Spring 2009 Dr. Richard Spillman Lecture 11 – ALU Design.
Combinational Circuits
Digital Arithmetic Wen-Hung Liao, Ph.D..
FUNCTION OF COMBINATIONAL LOGIC CIRCUIT
ECE 331 – Digital System Design
King Fahd University of Petroleum and Minerals
Arithmetic Circuits (Part I) Randy H
Chapter 5 – Number Representation and Arithmetic Circuits
Overview Part 1 – Design Procedure Part 2 – Combinational Logic
ECE 331 – Digital System Design
Presentation transcript:

Digital Arithmetic and Arithmetic Circuits Chapter 7 Digital Arithmetic and Arithmetic Circuits

Signed/Unsigned Binary Numbers A binary number of fixed length whose sign (+/–) is represented by one bit (usually MSB) and its magnitude by the remaining bits. Unsigned Binary Number: A binary number of fixed length whose sign is not specified by a bit. All bits are magnitude and the sign is assumed +.

Unsigned Binary Arithmetic Sum: Result of an Addition Operation of two (or more) binary numbers (operands). Carry: A digit (or bit) that is carried over to the next most significant bit during an n-Bit addition operation. The carry bit is a 1 if the result was too large to be expressed in n bits.

Basic Rules (Unsigned) One-Bit Unsigned Addition

Binary Addition Examples

Basic Subtraction Basic Subtraction of x = a – b, with a = minuend, b = subtrahend, and x = difference or result. Requires a Borrow Bit if a < b. There are other forms of subtraction such as 2’s Complement Addition used by microprocessors (such as in a PC).

Basic Subtraction Rules

Binary Subtraction with Borrow Examples

Signed Binary Numbers – 1 Sign Bit: A bit (usually the MSB) that indicates whether a number is positive (= 0) or negative (= 1). Magnitude Bits: The bits of a signed binary number that tell how large it is in value.

Signed Binary Numbers – 2 True-Magnitude Form: A form of signed binary whose magnitude bits are the TRUE binary form (not complements).

Signed Binary Numbers – 3 1’s Complement: A form of signed binary in which negative numbers are created by complementing all bits. 2’s Complement: A form of signed binary in which the negative numbers are created by complementing all the bits and adding a 1 (1’s Complement + 1).

True-Magnitude Form 5-Bit Numbers Negative Sign (S = 1) +25 = 011001 (Note sign bit (MSB) Sign = 0) –25 = 111001 (Same as +25 with sign = 1) +12 = 001100 –12 = 101100

1’s Complement Form 8-Bit 1’s Complement Negative (S = 1) +57 = 00111001 –57 = 11000110 (All Bits Inverted) +72 = 01001000 –72 = 10110111

2’s Complement Form Used in MPU (PC) Arithmetic 57 = 0011 1001 -57 = 1100 0110 +1 1011 1000

Signed Binary Addition (8-Bit) Signed Addition Positive (S = 0) Similar to binary addition with a sign bit.

Subtraction with 1’s Complement Add the 1’s Complement and then Carry. Uses an End around carry addition method.

2’s Complement Subtraction Add 2’s Complement to Minuend.

Negative Results If the True-Magnitude Form is used for subtraction, the results are incorrect. If the result is from 1’s or 2’s Complement and the result is negative (S = 1), the magnitude is found by taking the complement of the result.

Negative Result Example 2’s Complement Negative Result (65 – 80)

Range of Signed Numbers Range of Positive Numbers is 0 to 2n – 1 for a number with n magnitude bits. Range of Negative Numbers is –1 to –2n for a number with n magnitude bits. 8-Bit Example: 8-Bit Number Range is –2n  x  +2n – 1 or –128 to +127

Sign Bit Overflow Overflow: An erroneous carry into the sign bit of a signed binary number Results from a sum or difference that is larger than can be represented by the magnitude bits. Results in a False Positive or False Negative Number.

False Negative Overflow Addition of two 8-Bit Positive Numbers: Two positive numbers added with a result greater than the range of +127 for 8-bit numbers causes an overflow.

False Positive Overflow Addition of two 8-Bit Negative Numbers: Two Negative numbers were added to produce a False Positive Result due to overflowing the negative range of 8-bit numbers (0 to –127).

Hexadecimal Addition Similar to decimal addition with a range of digits of 0 to 9 and A to F. Examples: F + 1 = 10 F + F = 1E F + F + 1 = 1F

Hexadecimal Addition For sums greater than 15, subtract 16 and carry 1 to the next position.

Hexadecimal Subtraction

BCD Codes BCD Code (Binary-Coded Decimal): A code used to represent each decimal digit of a number by a 4-Bit Binary Value. Valid Digits for 0 to 9 are 0000 to 1001. The binary codes 1010 to 1111 are invalid Called an 8421 Code due to the decimal weight of each bit position.

BCD Examples Each digit is a 4-Bit Binary group: (84)10 = 1000 0100

Excess-3 Code A BCD Code formed by adding 3 (0011) to its true 4-bit binary value. Excess-3 is a self-complementing code: A negative code equivalent can be found by inverting the binary bits of the positive code Inverting the bits of the Excess-3 digit yields 9’s Complement of the decimal equivalent.

Excess-3 Examples 3 = 0011 + 0011 = 0110 = 6 in E3. If we complement 1 = 1011 in E3, this is the code for an 8. 9’s Complement of 1 = (9 – 1) = 8 (Self- Complement)

Gray Code A binary code that progresses so that only one bit changes between two successive codes.

Gray Code and Binary Binary: b3b2b1b0 Gray: g3g2g1g0 Gray code bits can be defined as follows: g3 = b3 g2 = b3  b2 g1 = b2  b1 g0 = b1  b0

ASCII Code American Standard Code for Information Interchange. A seven-bit alphanumeric code used to represent text letters, numerals, punctuation, and special controls. An expanded 8-bit form is becoming more widespread.

Binary Adders Half Adder (HA): A circuit that will add two bits and produce a sum bit and a carry bit. Full Adder (FA): A circuit that will add a carry bit from another HA or FA and two operand bits to produce a sum bit and a carry bit.

Basic HA Addition Binary Two-Bit Addition Rules: 0 + 0 = 00 0 + 1 = 01 1 + 1 = 10

HA Circuit Basic Equations: S = A XOR B, C = A and B where S = Sum and C = Carry. Truth Table for HA Block:

HA Circuit

Full Adder Basics Adds a CIN input to the HA block. Equations are modified as follows: A FA can be made from two HA blocks and an OR Gate.

Full Adder Basics

Full Adder Basics

Full Adder Basics

Parallel Adders A circuit, consisting of n full adders, that will add n-bit binary numbers. The output consists of n sum bits and a carry bit. COUT of one full adder is connected to CIN of the next full adder.

Parallel Adders

Ripple Carry – 1 In the n-Bit Parallel Adder (FA Stages) the Carryout is generated by the last stage (FAN). This is called a Ripple Carry Adder because the final carryout (Last Stage) is based on a ripple through each stage by CIN at the LSB Stage.

Ripple Carry – 2 Each Stage will have a propagation delay on the CIN to COUT of one AND Gate and one OR Gate. A 4-Bit Ripple Carry Adder will then have a propagation delay on the final COUT of 4  2 = 8 Gates. A 32-Bit adder such as in an MPU in a PC could have a delay of 64 Gates.

Ripple Carry - 3

Look-Ahead Carry – 1 Fast Carry or Look-Ahead Carry: A combinational network that generates the final COUT directly from the operand bits (A1 to An, B1 to Bn). It is independent of the operations of each FA Stage (as the ripple carry is).

Look Ahead Carry – 2 Fast Carry has a small propagation delay compared to the ripple carry. The fast carry delay is 3 Gates for a 4-Bit Adder compared to 8 for the Ripple Carry.

Parallel Adder Created in VHDL by using multiple instances of a full adder component in the top-level file of a VHDL design hierarchy.

Parallel Adder

VHDL Full Adder ENTITY full_add IS PORT( a, b, c_in : IN STD_LOGIC; c_out, sum : OUT STD_LOGIC; END full_add; ARCHITECTURE adder OF full_add IS BEGIN c_out <= ((a xor b) and c_in) or (a and b); sum <= (a xor b) xor c_ini; END adder;

Parallel Adder VHDL Requires a separate component file for a full adder, saved in a folder where the compiler can find it. A component declaration statement in the top-level file of the design hierarchy. A component instantiation statement for each instance of the full adder component.

Parallel Adder VHDL Code – 1 ENTITY add4par IS PORT( c0 : IN STD_LOGIC; a,b : IN STD_LOGIC_VECTOR (4 downto 1); c4 : OUT STD_LOGIC; sum : OUT STD_LOGIC_VECTOR (4 downto 1); END add4par;

Parallel Adder VHDL Code – 2 ARCHITECTURE adder OF add4par IS -- Component declaration. COMPONENT full_add PORT( a, b, c_in : IN STD_LOGIC; c_out, sum : OUT STD_LOGIC; END COMPONENT; -- Define a signal for the internal carry bits SIGNAL c : STD_LOGIC_VECTOR (3 downto 1);

Parallel Adder VHDL Code – 3 BEGIN -- four component instantiation statements. adder1 : full_add PORT MAP (a => a(1), b => b(1), c_in => c0, c_out => c(1) -- connects to c_in of adder 2. sum => sum(1)); • • • END adder;

VHDL Generate Statement – 1 ENTITY add4gen IS PORT( c0 : IN STD_LOGIC; a,b : IN STD_LOGIC_VECTOR (4 downto 1); c4 : OUT STD_LOGIC; sum : OUT STD_LOGIC_VECTOR (4 downto 1)); END add4gen;

VHDL Generate Statement – 2 ARCHITECTURE adder OF add4gen IS -- Component declaration COMPONENT full_add PORT( a, b, c_in :IN STD_LOGIC; c_out, sum : OUT STD_LOGIC; END COMPONENT; - - Defining a signal for internal carry bits. SIGNAL c : STD_LOGIC_VECTOR (4 downto 0);

VHDL Generate Statement – 3 BEGIN c(0) <= c0; -- Input port c0 mapped to internal signal (c0) adders: FOR i IN 1 to 4 GENERATE -- Implicit port mapping. adder : full_add PORT MAP (a(i), b(i), c(i-1), c(i), sum (i)); END GENERATE; c4 <= c(4); -- Output port c4 mapped to internal signal c(4) END adder;

Subtractor (2’s Complement) – 1 The concept of Subtraction using 2’s Complement addition allows a Parallel FA to be used. This could be used in a MPU ALU (Arithmetic Logic Unit) for Subtraction. The subtract operation involves adding the inverse of the subtrahend to the minuend and then adding a 1.

Subtractor (2’s Complement) – 2 This operation can be done in a parallel n-Bit FA by inverting (B1 to Bn) and connecting CIN at the LSB Stage to +5 V. The circuit can be modified to allow either the ADD or SUBTRACT operation to be performed.

Subtractor (2’s Complement) 2

Parallel Binary Adder/Subtractor XOR gates are used as programmable inverters to pass binary numbers (e.g., B1B2B3B4) to the parallel adder in true or complemented form.

Parallel Binary Adder/Subtractor

Parallel Binary Adder/Subtractor

VHDL Parallel Binary Adder/Subtractor – 1 ENTITY addsub4g IS PORT( sub : IN BIT; a,b : IN BIT_VECTOR (4 downto 1); c4 : OUT BIT; sum : OUT BIT_VECTOR (4 downto 1)); END addsub4g;

VHDL Parallel Binary Adder/Subtractor – 2 ARCHITECTURE adder OF addsub4g IS COMPONENT full_add PORT( a, b, c_in : IN BIT; c_out : OUT BIT); END COMPONENT; - - Define a signal for internal carry bits SIGNAL c : BIT_VECTOR (4 downto 0); SIGNAL b_comp : BIT_VECTOR (4 downto 1); BEGIN

VHDL Parallel Binary Adder/Subtractor – 3 - - add/subtract select to carry input (sub = 1 for subtract) c(0) <= sub; adders: FOR i IN 1 to 4 GENERATE --invert b for subtract function (b(i) xor 1,) --do not invert b for add function (b(i) xor 0) b_comp(i) <= b(i) xor sub; adder: full_add PORT MAP (a(i), b_comp(i), c(I -1), c(i), sum (i)); END GENERATE; C4 <= C(4); END adder;

Overflow If the sign bits of both operands are the same and the sign bit of the sum is different from the operand sign bits, an overflow has occurred. Overflow is not possible if the sign bits of the operands are different from each other.

Overflow Examples Adding two 8-bit negative numbers: Adding two 8-bit positive numbers:

Overflow 8-bit Parallel Adder

Overflow Detector Truth Table SA SB S V 1

Overflow Detector Truth Table

BCD Adder A Parallel Adder whose output sum is in groups of 4 bits, each representing a BCD (8421) Digit. Basic design is a 4-Bit Binary Parallel Adder to generate a 4-Bit Sum of A + B. Sum is input to the four-bit input of a Binary-to-BCD Code Converter.

BCD Adder