Adders and Subtractors

Slides:



Advertisements
Similar presentations
Abdullah Said Alkalbani University of Buraimi
Advertisements

DISEÑO LÓGICO (DLO) Ejemplos de VHDL.
UNIT 8: Synthesis Basics
arquitectura – implementação
VHDL Introdução Paulo C. Centoducatte fevereiro de 2005
Cs 121 Ch 4-2 Combinational Logic
CWRU EECS 317 EECS 317 CAD Computer Aided Design LECTURE 2: Delay models, std_ulogic and with-select-when Instructor: Francis G. Wolff
ADDER, HALF ADDER & FULL ADDER
ASIC 121: Practical VHDL Digital Design for FPGAs Tutorial 2 October 4, 2006.
©2004 Brooks/Cole FIGURES FOR CHAPTER 20 VHDL FOR DIGITAL SYSTEM DESIGN Click the mouse to move to the next page. Use the ESC key to exit this chapter.
Adders Module M8.1 Section 6.2. Adders Half Adder Full Adder TTL Adder.
Kuliah Rangkaian Digital Kuliah 7: Unit Aritmatika
Introduction To VHDL for Combinational Logic
Cs 1110 Ch 4-1 Combinational Logic. ° Introduction Logic circuits for digital systems may be: °2°2 combinational sequential OR A combinational circuit.
Lecture #28 Page 1 ECE 4110– Sequential Logic Design Lecture #28 Agenda 1.Counters Announcements 1.HW #13 assigned 2.Next: Test #2 Review.
Multiplexers Section 3-7 Mano & Kime. Multiplexers & Demultiplexers Multiplexers (Selectors) Lab 1 – Behavioral VHDL -- Multiplexers MUX as a Universal.
Digital Logic with VHDL EE 230 Digital Systems Fall 2006 (10/17/2006)
LECTURE 4: The VHDL N-bit Adder
Combinational Circuits. Analysis Diagram Designing Combinational Circuits In general we have to do following steps: 1. Problem description 2. Input/output.
1 EE24C Digital Electronics Project Theory: Sequential Logic (part 2)
MO Prof. Paulo Cesar Centoducatte MC542 Organização de Computadores Teoria e Prática.
Adder Discussion D6.2 Example 17. s i = c i ^ (a i ^ b i ) c i+1 = a i * b i + c i * (a i ^ b i ) Full Adder (Appendix I)
Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design.
Subtractors Module M8.2 Section 6.2. Subtractors Half Subtractor Full Subtractor Adder/Subtractor - 1 Adder/Subtractor - 2.
Binary Subtraction Section 3-9 Mano & Kime. Binary Subtraction Review from CSE 171 Two’s Complement Negative Numbers Binary Adder-Subtractors 4-bit Adder/Subtractor.
Space vs. Speed: Binary Adders 11.3 Space vs. Speed.
Adders Lecture L7.1 Section 6.2 Section 10.4 (pp )
1 CS 140 Lecture 18 Sequential Modules: Serial Adders, Multipliers Professor CK Cheng CSE Dept. UC San Diego.
Overview Iterative combinational circuits Binary adders
ENGIN112 L14: Binary Adder Subtractor October 3, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 14 Binary Adders and Subtractors.
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 4 – Arithmetic Functions Logic and Computer.
Part 2: DESIGN CIRCUIT. LOGIC CIRCUIT DESIGN x y z F F = x + y’z x y z F Truth Table Boolean Function.
AND Gate: A Logic circuit whose output is logic ‘1’ if and only if all of its inputs are logic ‘1’.
CS 105 Digital Logic Design
Combinational and Sequential Logic Circuits.
Dr. Ahmed El-Bialy, Dr. Sahar Fawzy Combinational Circuits Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Combinational Logic. Outline 4.1 Introduction 4.2 Combinational Circuits 4.3 Analysis Procedure 4.4 Design Procedure 4.5 Binary Adder- Subtractor 4.6.
ECE 3110: Introduction to Digital Systems Chapter 6 Combinational Logic Design Practices Adders, subtractors, ALUs.
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.
ARITHMETIC MICRO OPERATIONS
1 Ethics of Computing MONT 113G, Spring 2012 Session 5 Binary Addition.
ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN Lecture 7 Dr. Shi Dept. of Electrical and Computer Engineering.
1 KU College of Engineering Elec 204: Digital Systems Design Lecture 10 Multiplexers MUX: –Selects binary information from one of many input lines and.
Digital Logic Structures: Chapter 3 COMP 2610 Dr. James Money COMP
ECE 331 – Digital System Design Multi-bit Adder Circuits, Adder/Subtractor Circuit, and Multiplier Circuit (Lecture #12)
ECE 320 Homework #4 1. Using 8 data input selector logic (MUX), implement the following two functions: a) F(A,B,C)=S 0 S 2 S 3 S 5 b) F(A,B,C,D)=P 0 +P.
May 9, 2001Systems Architecture I1 Systems Architecture I (CS ) Lab 5: Introduction to VHDL Jeremy R. Johnson May 9, 2001.
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Schematics adapted from those provided by the authors Hennessey and Patterson.
1 Lecture 14 Binary Adders and Subtractors. 2 Overview °Addition and subtraction of binary data is fundamental Need to determine hardware implementation.
Logic Design (CE1111 ) Lecture 4 (Chapter 4) Combinational Logic Prepared by Dr. Lamiaa Elshenawy 1.
1 Computer Architecture & Assembly Language Spring 2009 Dr. Richard Spillman Lecture 11 – ALU Design.
Systems Architecture Lab: Introduction to VHDL
Combinational Circuits
ENG6530 Reconfigurable Computing Systems
Reference: Moris Mano 4th Edition Chapter 4
Summary Half-Adder Basic rules of binary addition are performed by a half adder, which has two binary inputs (A and B) and two binary outputs (Carry out.
Digital System Design Review.
ECE 331 – Digital System Design
FIGURE 4.1 Block diagram of combinational circuit
ECE 301 – Digital Electronics
Week 7: Gates and Circuits: PART II
Chapter 5 – Number Representation and Arithmetic Circuits
DIGITAL ELECTRONICS B.SC FY
XOR Function Logic Symbol  Description  Truth Table 
LOGIC Circuits.
Half & Full Subtractor Half Subtractor Full Subtractor.
Four Bit Adder Sum A Cin B Cout 10/9/2007 DSD,USIT,GGSIPU.
Half & Full Subtractor Half Subtractor Full Subtractor.
Digital Logic with VHDL
Presentation transcript:

Adders and Subtractors Discussion D4.1

Adders and Subtractors Carry and Overflow Subtractors Adder-Subtractor

Half Adder 1 1 +1 +1 2 10 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 Dec Binary A B S C 1 A B S C 1 0 0 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 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 Ci+1 Ci+1 = AiBi + CiAi'Bi + CiAiBi'

Full Adder Recall: Ci+1 = AiBi + CiAi'Bi + CiAiBi' Ci+1 = AiBi + Ci(Ai'Bi + AiBi') Ci+1 = AiBi + Ci(Ai Bi) Recall: Si = Ci (Ai Bi) Ci+1 = AiBi + Ci(Ai Bi)

Full Adder Si = Ci (Ai Bi) Ci+1 = AiBi + Ci(Ai Bi) Half-adder

Full Adder A full adder can be made from two half adders (plus an OR gate).

Full Adder Block Diagram

4-Bit Adder C 1 1 1 0 A 0 1 0 1 B 0 1 1 1 S 1 1 0 0

Full Adder Truth table Behavior Ci+1:Si = Ci + Ai + Bi Ci Si Ai Ci+1

Full Adder Block Diagram

4-Bit Adder C 1 1 1 0 0:A 0 1 1 0 1 0:B 0 0 1 1 1 C4:S 1 0 1 0 0

library IEEE; use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_unsigned.all; entity adder4 is port( A : in STD_LOGIC_VECTOR(3 downto 0); B : in STD_LOGIC_VECTOR(3 downto 0); carry : out STD_LOGIC; S : out STD_LOGIC_VECTOR(3 downto 0) ); end adder4; architecture adder4 of adder4 is begin process(A,B) variable temp: STD_LOGIC_VECTOR(4 downto 0); temp := ('0' & A) + ('0' & B); S <= temp(3 downto 0); carry <= temp(4); end process;

4-Bit Adder

Adders and Subtractors Carry and Overflow Subtractors Adder-Subtractor

Carry and Overflow 0 0 1 1 0 1 0 1 0 0 0 1 1 0 0 1 1 1 1 C = 0 V = 0 1 Binary 0 0 1 1 0 1 0 1 0 0 0 1 1 0 0 1 Dec 1 1 1 Hex 53 +25 78 35 +19 4E C = 0 V = 0 1 1 1 1 Note no carry from bit 6 to bit 7 and no carry from bit 7 to C.

Carry and Overflow Binary 0 0 1 1 0 1 0 1 0 1 0 1 1 0 1 1 1 1 1 1 1 1 1 Dec Hex 53 +91 144 35 +5B 90 C = 0 V = 1 1 1 Note carry from bit 6 to bit 7 but no carry from bit 7 to C. Thinking SIGNED we added two positive numbers and got a negative result. This can’t be correct! Therefore, the OVERFLOW bit, V, is set to 1. Correct answer (144) is outside the range -128 to +127.

Carry and Overflow Binary 0 0 1 1 0 1 0 1 1 1 0 1 0 0 1 1 1 1 1 1 1 1 Dec Hex 53 - 45 8 35 +D3 108 C = 1 V = 0 1 Ignore carry Note carry from bit 6 to bit 7 and carry from bit 7 to C. Thinking SIGNED we added a positive number to a negative number and got the correct positive answer. Therefore, the OVERFLOW bit, V, is cleared to 0. Correct answer (8) is inside the range -128 to +127.

Carry and Overflow 1 0 0 1 1 1 1 0 1 1 0 1 0 0 1 1 1 1 1 1 C = 1 V = 1 Binary 1 0 0 1 1 1 1 0 1 1 0 1 0 0 1 1 1 1 1 1 Dec Hex - 98 - 45 - 143 9E +D3 171 C = 1 V = 1 1 1 1 1 Ignore carry Note no carry from bit 6 to bit 7 but there is a carry from bit 7 to C. Thinking SIGNED we added two negative numbers and got a positive answer. This must be wrong! Therefore, the OVERFLOW bit, V, is set to 1. Correct answer (-143) is outside the range -128 to +127.

Overflow Note that the overflow bit was set whenever we had a carry from bit 6 to bit 7, but no carry from bit 7 to C. It was also set when we had a carry from bit 7 to C, but no carry from bit 6 to bit 7. Upshot: The overflow bit is the EXCLUSIVE-OR of a carry from bit 6 to bit 7 and a carry from bit 7 to C.

Adders and Subtractors Carry and Overflow Subtractors Adder-Subtractor

Half Subtractor 2 1 -1 1 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 0 A D B C A B D B D C 1 1 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 0 2 1 -1 1

Multiple-bit Subtraction A3 A2 A1 A0 B3 B2 B1 B0 A 0 1 0 1 B 0 1 1 1 Ci+1 0 1 0 1 0 1 1 1 - Ci 1 1 A Ai - Bi B Di 1 1 1 1

Full Subtractor Di Same as Si in full adder Ci Ai Bi Di Ci+1 Ci AiBi 00 01 11 10 1 0 0 0 0 0 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0 0 1 1 1 0 1 0 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 Di Di = Ci (Ai Bi) Same as Si in full adder

Full Subtractor Ci+1 Ci AiBi 00 01 11 10 1 Ci Ai Bi Di Ci+1 0 0 0 0 0 1 Ci Ai Bi Di Ci+1 0 0 0 0 0 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0 0 1 1 1 0 1 0 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 Ci+1 Ci+1 = Ai'Bi + CiAi'Bi' + CiAiBi

Full Subtractor Recall: Ci+1 = Ai'Bi + CiAi'Bi' + CiAiBi Ci+1 = Ai'Bi + Ci(Ai'Bi' + AiBi) Ci+1 = Ai'Bi + Ci(Ai Bi)' Recall: Di = Ci (Ai Bi) Ci+1 = Ai'Bi + Ci(Ai Bi)'

Full Subtractor half subtractor Di = Ci (Ai Bi) Ci+1 = Ai'Bi + Ci(Ai Bi)' half subtractor

Adders and Subtractors Carry and Overflow Subtractors Adder-Subtractor

Reordered Full Adder Full Subtractor Full Adder 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 1 1 0 1 0 1 0 0 1 1 0 0 1 0 0 1 1 1 0 1 0 1 1 1 0 0 0 1 1 1 1 1 Ci Ai Bi Di Ci+1 Full Subtractor Full Adder Ci Ai Bi Si Ci+1 Ci Ai Bi Si Ci+1 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 1 1 0 0 1 0 0 1 1 0 0 0 0 0 0 0 1 1 0 1 0 1 0 1 0 NOT

Making a full subtractor from a full adder

Adder/Subtractor E = 0: 4-bit adder E = 1: 4-bit subtractor

4-bit Subtractor: E = 1 +1 Add A to !B (one’s complement) plus 1 That is, add A to two’s complement of B D = A - B