Binary Arithmetic Adding Binary numbers Overflow conditions

Slides:



Advertisements
Similar presentations
Lab 10 : Arithmetic Systems : Adder System Layout: Slide #2 Slide #3 Slide #4 Slide #5 Arithmetic Overflow: 2’s Complement Conversions: 8 Bit Adder/Subtractor.
Advertisements

Binary Addition. Binary Addition (1) Binary Addition (2)
Adders Lecture L7.1 Section 6.2 Section 10.4 (pp )
CK Cheng Tuesday 10/2/02 CS 140 Lecture 2. Part I. Combinational Logic I) Specification –a. Language –b. Truth Table –c. Boolean Algebra –d. Incompletely.
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
ECE 301 – Digital Electronics
ECE 301 – Digital Electronics
Lecture 3. Boolean Algebra, Logic Gates
CS 105 Digital Logic Design
Lecture 3. Boolean Algebra, Logic Gates Prof. Sin-Min Lee Department of Computer Science 2x.
CS 1308 – Computer Literacy and the Internet. It’s Not Magic  The goal of the next series of lectures is to show you exactly how a computer works. 
Binary Numbers.
Binary Addition CSC 103 September 17, 2007.
Binary Addition Section 4.5. Binary Addition Example.
ECE 3130 – Digital Electronics and Design
+ CS 325: CS Hardware and Software Organization and Architecture Combinational Circuits 1.
1 Adders & Subtractors Adders –An adder is a combinational logic circuit that performs the addition of 2 binary numbers (A & B) to generate the sum (S)
Digital Electronics Lecture 6 Combinational Logic Circuit Design.
Logic Gates Logic gates are electronic digital circuit perform logic functions. Commonly expected logic functions are already having the corresponding.
Logic Design CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Lecture 18: Hardware for Arithmetic Today’s topic –Intro to Boolean functions (Continued) –Designing an ALU 1.
Number Systems and Circuits for Addition Lecture 5 Section 1.5 Thu, Jan 26, 2006.
Universal college of engineering & technology. .By Harsh Patel)
Boolean Algebra and Logic Gates CSE-1108 Ahsanullah University of Science and Technology (AUST)
Computer Science 101 More Devices: Arithmetic. From 1-Bit Equality to N-Bit Equality = A B A = B Two bit strings.
Digital Logic Structures: Chapter 3 COMP 2610 Dr. James Money COMP
Outline Binary Addition 2’s complement Binary Subtraction Half Adder
Computer Architecture
Number Systems and Circuits for Addition – Binary Adders Lecture 6 Section 1.5 Fri, Jan 26, 2007.
Digital Electronics Tutorial: Number System & Arithmetic Circuits Solutions.
GCSE Computing#BristolMet Session Objectives#8 MUST add two 8-bit binary integers SHOULD explain overflow errors COULD provide solutions to limit overflow.
Chapter 3 Digital Logic Structures
Addition and multiplication Arithmetic is the most basic thing you can do with a computer, but it’s not as easy as you might expect! These next few lectures.
Gates AND, OR, NOT NAND, NOR Combinational logic No memory A set of inputs uniquely and unambiguously specifies.
Electrical Engineering Engineering the Future Digital Circuits Fundamentals Hands-on Full-Adder Simulation (afternoon)
LOGIC CIRCUITLOGIC CIRCUIT. Goal To understand how digital a computer can work, at the lowest level. To understand what is possible and the limitations.
ETE 204 – Digital Electronics Combinational Logic Design Single-bit and Multiple-bit Adder Circuits [Lecture: 9] Instructor: Sajib Roy Lecturer, ETE,ULAB.
L OGIC G ATES Computer Organization – week 3. W HAT ’ S ALU? 1. ALU stands for: Arithmetic Logic Unit 2. ALU is a digital circuit that performs Arithmetic.
ECEN 248 Lab 3: Study and Implementation of Adders Dept. of Electrical and Computer Engineering.
COMPUTER ORGANIZATION 4 TH LECTURE. ASCII Code  ASCII ( American Standard Code for Information Interchange).  Input and output devices that communicate.
1 CSE370, Lecture 4 Lecture 4 u Logistics n HW1 due now n HW2 posted now and is due one week from today n Lab1 going on this week n Feedback on lectures,
Combinational Circuits
ECE 3130 Digital Electronics and Design
Lecture 11: Hardware for Arithmetic
Boolean Algebra, Bitwise Operations
Combinational Circuits
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.
MIPS ALU.
An Introduction to Microprocessors
Combinational Circuits
CSE Winter 2001 – Arithmetic Unit - 1
Number Systems Decimal (base 10) { }
For OCR GCSE Computing Unit 1 - Theory
Boolean Algebra.
Week 7: Gates and Circuits: PART II
Digital Logic.
Lecture 11: Hardware for Arithmetic
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Number Systems and Circuits for Addition
Logic Gates.
Adders and Subtractors
Adders.
Digital Logic.
COMS 361 Computer Organization
XOR, XNOR, and Binary Adders
Lecture 4 Logistics Last lecture --- Boolean algebra Today’s lecture
Special Gates Combinational Logic Gates
Adder Circuits By: Asst Lec. Basma Nazar
Digital Circuits.
Carryout bit? Carryout bit is ‘1’ also on four cases. When a, b and carryin are 110, 101, 011, 111. Does it mean that we need a similar circuit as sum?
Presentation transcript:

Binary Arithmetic Adding Binary numbers Overflow conditions How does it all work? AND, OR and NOT

Decimal Addition You are probably already familiar with adding decimal numbers 7 +2 9 5 +1 6 2 +3 5 You also know that when the addition of two numbers exceeds the base, a value is “carried” over to the next column 1 Carry the “1” 7 + 5 1 2

Binary Addition Adding binary numbers employs the same procedures as adding decimal numbers: 00 +00 01 +00 00 +01 01 As with decimal addition, when the addition of two numbers exceeds the base value, the value is “carried” over to the next column 1 Carry the “1” 01 +01 10

11 +11 ??? Binary Addition Examples 01001100 01101010 10110110 11001100 00110011 11111111 01111111 00000001 10000000 What happens when we have the following case? 1 Carry the “1” 11 +11 ???

More Binary Addition Examples 01111111 01000001 11000000 10001100 00111011 11000111 01111111 01001001 11001000 What happens when we get the following case? (note: assume that we are limited to 8 bits) 11111111 00000001 ????????

Overflow In the following case, we have a condition called “overflow”. The result may be somewhat unexpected 1 Carry the “1” 11111111 00000001 00000000 When adding two numbers, it is possible that the result will not fit within the space we have provided. The addition completes, but part of the value is lost. Luckily, overflow is often considered to be an error condition, so the program “knows” that this has happened and can take appropriate action.

How does it all work? In the first week of lectures, we discussed vacuum tubes, relays, and transistors As we went through the discussion, I asked, “How could you add two numbers using switches?” I didn’t expect an answer, but I did show how switches could be set up to implement the AND function and the OR function.

AND, OR and NOT You may recall the “truth” tables for the AND and OR functions: A A A 0 1 0 0 0 1 0 1 0 1 0 0 1 1 1 1 0 1 1 0 B B AND OR NOT (~) The AND, OR and NOT functions are the basic functions for “Boolean” Algebra

Binary Arithmetic/AND and OR All binary arithmetic can be represented using boolean algebra Each 1-bit adder has 3 inputs: A, B and CarryIn Each 1-bit adder has 2 output: C and CarryOut CIN 0 0 0 0 1 1 1 1 A 0 0 1 1 0 0 1 1 B 0 1 0 1 0 1 0 1 C 0 1 1 0 1 0 0 1 COUT 0 0 0 1 0 1 1 1

Boolean Equations for Addition CIN 0 0 0 0 1 1 1 1 A 0 0 1 1 0 0 1 1 B 0 1 0 1 0 1 0 1 C 0 1 1 0 1 0 0 1 COUT 0 0 0 1 0 1 1 1 C = (~A and B and ~CIN) or (A and ~B and ~CIN) or (~A and ~B and CIN) or (A and B and CIN) COUT= (A and B) or (A and CIN) or (B and CIN)