1 CHAPTER 4: PART I ARITHMETIC FOR COMPUTERS. 2 The MIPS ALU We’ll be working with the MIPS instruction set architecture –similar to other architectures.

Slides:



Advertisements
Similar presentations
Combinational Circuits
Advertisements

Cosc 2150: Computer Organization Chapter 3: Boolean Algebra and Digital Logic.
Arithmetic Operations and Circuits
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third Edition.
Chapter 4 Gates and Circuits.
Assembly Language and Computer Architecture Using C++ and Java
1 Lecture 11: Digital Design Today’s topics:  Evaluating a system  Intro to boolean functions.
1 Chapter 4: Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture Assembly Language and.
Major Numeric Data Types Unsigned Integers Signed Integers Alphanumeric Data – ASCII & UNICODE Floating Point Numbers.
Logic Gate Level Combinational Circuits, Part 1. Circuits Circuit: collection of devices physically connected by wires to form a network Net can be: –
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
Lecture 3. Boolean Algebra, Logic Gates
Chapter 3 Arithmetic for Computers. Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's.
Propositional Calculus Math Foundations of Computer Science.
Prof. Hakim Weatherspoon CS 3410, Spring 2015 Computer Science Cornell University See: P&H Chapter 2.4, 3.2, B.2, B.5, B.6.
+ CS 325: CS Hardware and Software Organization and Architecture Exam 1: Study Guide.
CS 105 Digital Logic Design
Lecture 3. Boolean Algebra, Logic Gates Prof. Sin-Min Lee Department of Computer Science 2x.
CS231 Fundamentals1 Fundamentals What kind of data do computers work with? – Deep down inside, it’s all 1s and 0s What can you do with 1s and 0s? – Boolean.
Chapter 4 Gates and Circuits. 4–2 Chapter Goals Identify the basic gates and describe the behavior of each Describe how gates are implemented using transistors.
Binary Numbers.
Systems Architecture I1 Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they.
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
1 Modified from  Modified from 1998 Morgan Kaufmann Publishers Chapter Three: Arithmetic for Computers citation and following credit line is included:
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
Lecture 17: Digital Design Today’s topic –Intro to Boolean functions Reminders –HW 4 due Wednesday 10/8/2014 (extended) –HW 5 due Wednesday 10/15/2014.
Basic Arithmetic (adding and subtracting)
Digital Logic Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 3-2 Roadmap Problems Algorithms.
1 The Chinese University of Hong Kong Faculty of Education Diploma in Education (Part-Time) Winter 1997 Educational Communications and Technology Assignment.
Chapter 6-1 ALU, Adder and Subtractor
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
Basic Arithmetic (adding and subtracting)
Digital Logic. 4 Why is 32-bit or 64-bit significant in terms of speed, efficiency? 4 Difference between OR and XOR 4 What is a mux for? PLA 4 Two kinds.
1 EGRE 426 Fall 08 Chapter Three. 2 Arithmetic What's up ahead: –Implementing the Architecture 32 operation result a b ALU.
Numbers and Arithmetic Hakim Weatherspoon CS 3410, Spring 2013 Computer Science Cornell University See: P&H Chapter , 3.2, C.5 – C.6.
Lecture 22: 11/19/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
IT253: Computer Organization Lecture 7: Logic and Gates: Digital Design Tonga Institute of Higher Education.
Logic Design CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
1 Lecture 6 BOOLEAN ALGEBRA and GATES Building a 32 bit processor PH 3: B.1-B.5.
The Karnaugh Map.
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell University.
1 ELEN 033 Lecture 4 Chapter 4 of Text (COD2E) Chapters 3 and 4 of Goodman and Miller book.
Chapter 3 Digital Logic Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 3-2 Transistor: Building.
1. Computing Systems Lecture 3 Binary Representation & Boolean Logic Binary and Logic 2.
Appendix C Basics of Digital Logic Part I. Florida A & M University - Department of Computer and Information Sciences Modern Computer Digital electronics.
1  2004 Morgan Kaufmann Publishers Lets Build a Processor Almost ready to move into chapter 5 and start building a processor First, let’s review Boolean.
1 ECE 545—Digital System Design with VHDL Lecture 1 Digital Logic Refresher Part A – Combinational Logic Building Blocks.
Introduction to Computing Systems and Programming Digital Logic Structures.
Chapter 3 Digital Logic Structures
LECTURE 4 Logic Design. LOGIC DESIGN We already know that the language of the machine is binary – that is, sequences of 1’s and 0’s. But why is this?
Gates AND, OR, NOT NAND, NOR Combinational logic No memory A set of inputs uniquely and unambiguously specifies.
1 Arithmetic Where we've been: –Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: –Implementing the Architecture.
1 Ethics of Computing MONT 113G, Spring 2012 Session 4 Binary Addition.
9/23/2004Comp 120 Fall September Chapter 4 – Arithmetic and its implementation Assignments 5,6 and 7 posted to the class web page.
1 CPTR 220 Computer Organization Computer Architecture Assembly Programming.
Computing Systems Lecture 3 Binary Representation & Boolean Logic Binary and Logic 1.
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.
Computer Architecture & Operations I
Invitation to Computer Science, C++ Version, Fourth Edition
Morgan Kaufmann Publishers
Lecture 11: Hardware for Arithmetic
Fundamentals & Ethics of Information Systems IS 201
University of Gujrat Department of Computer Science
Invitation to Computer Science, Java Version, Third Edition
Digital Logic.
Lecture 11: Hardware for Arithmetic
COSC 2021: Computer Organization Instructor: Dr. Amir Asif
Digital Logic.
COMS 361 Computer Organization
Presentation transcript:

1 CHAPTER 4: PART I ARITHMETIC FOR COMPUTERS

2 The MIPS ALU We’ll be working with the MIPS instruction set architecture –similar to other architectures developed since the 1980's –used by NEC, Nintendo, Silicon Graphics, Sony Below is the Interface Representation of an ALU 32 operation result a b ALU

3 Numbers Bits are just bits (no inherent meaning) –conventions define relationship between bits and numbers Binary numbers (base 2) For an n-bit representation: The decimals represented: n -1 Of course it gets more complicated: Numbers are finite (possibility of overflow) How can fractions and real numbers be represented? How can negative numbers be represented? We will consider the representation of negative numbers.

4 Possible Representations UnsignedSign MagnitudeOne’s Compliment signed Two’s Compliment signed 000 = 0000 = = 1001 = = 2010 = = 3011 = = 4100 = = = = 5101 = = = = 6110 = = = = 7111 = = = -1 Works on positives only Addition ComplicatedZero not uniqueZero unique Issues: balance, number of zeros, ease of operations Two’s compliment best to represent signed integers.

5 Converting between positive decimal and binary Convert decimal 49 to 8-bit binary: 49/2 = 24 r 1 24/2 = 12 r 0 12/2 = 6 r 0 6/2 = 3 r 0 3/2 = 1 r 1 1/2 = 0 r 1 Now read the remainders from bottom to top: the binary equivalent is In 8 bit form, it is: In 16 bit form it is: It is very easy to convert from a binary number to a decimal number. Just like the decimal system, we multiply each digit by its weighted position, and add each of the weighted values together. For example, the binary value represents:

6 Converting between negative decimal and binary Convert decimal -50 to 8-bit binary. –Convert 50 to binary: Now read the remainders from bottom upwards 50 = –Extend to 8 bits: –Invert bits: –Add 1: -50 = Answer is Convert to decimal. –Invert bits: –Add 1: –Convert to decimal: Final answer = -37. Get 2’s compliment

7 Two’s Complement Number System Take 8 bit binary: 0 = = = = = = = ? = ? = Largest positive = 2 8 /2 – 1 Smallest negative = /2

8 MIPS 32 bit signed numbers: two = 0 ten two = + 1 ten two = + 2 ten two = + 2,147,483,646 ten two = + 2,147,483,647 ten two = – 2,147,483,648 ten two = – 2,147,483,647 ten two = – 2,147,483,646 ten two = – 3 ten two = – 2 ten two = – 1 ten

9 Addition & Subtraction (4 bit word) Using the regular algorithm for binary addition, add (5+12), (-5+12), (-12+-5), and (12+-12) in Two's Complement system. Then convert back to decimal numbers

10 Examples Convert 37, -56, 2, -5 into 8 bit 2’s compliment: Convert the 8-bit signed binary to decimal: (a) (b) (c) Carryout the addition by first converting into 8 bits 2’s compliment numbers: (a) 89+23(b) 49-23(c) 5+56

11 Detecting Overflow No overflow when adding a positive and a negative number No overflow when signs are the same for subtraction Overflow occurs when the value affects the sign: –overflow when adding two positives yields a negative –or, adding two negatives gives a positive –or, subtract a negative from a positive and get a negative –or, subtract a positive from a negative and get a positive Consider the operations A + B, and A – B –Can overflow occur if B is 0 ? –Can overflow occur if A is 0 ? Detection of overflow in signed bit addition: Carry in into most significant bit ≠ carry out.

12 Boolean Algebra and logic gates Transistors inside a modern computer are digital with two values 1, 0 (high and low voltage: asserted or de-asserted). Boolean variable: Takes only two values - true (1), false (0). proposition : In formal logic, a proposition (statement) is a declarative sentence that is true or false. Boolean operators: Used to construct propositions out of other propositions. Gates: Hardware implementing basic Boolean operators. The basic gates are NOT (negation), AND (conjunction), OR (disjunction). Boolean algebra: Deals with Boolean (logical) variables and logic operations operating on those variables. A Boolean function can be expressed algebraically with: –Binary variables; –Logic operations symbols; –Parentheses; –Equal sign.

13 Boolean Algebra and logic gates Truth tables: All possible values of input determine various values of outputs. These values can be represented using a truth table. Logic diagram: Composed of graphic symbols for logic gates. Represents Boolean functions. To represent a function with n binary variables, we need a list of 2 n combinations. Logic blocks are physical components: –Combinational: Without memory. The output depends only on the current input. –Sequential: Have memory (state). The output and state depend on the input and state.

14 Truth tables of operators and Logical Gates Gates: AND, OR, NAND, NOR, XOR. a AND b = ab a OR b = a+ba NAND b = ab a NOR b = a+b a XOR b = a b

15 Truth table for expressions

16 Proving identities using truth tables

17 Basic Identities of Boolean Algebra

18 Proving Boolean identities using algebra Boolean identities can be used to simplify expressions and prove identities.

19 Sum of Products Given any Boolean expression, one can draw a truth table. Given any truth table with inputs and outputs, can one get a Boolean expression of each output in terms of the inputs corresponding to the truth table? Example: What is the formula of output A in terms of inputs x, y, and z? First answer: Sum of Products Formula xyzA

20 Sum of Products Consider inputs: x, y, z; outputs F, G The sum of products formulae for outputs F and G are: xyzFG

21 Programmable Logical Arrays, PLAs A PLA is a customizable AND matrix followed by a customizable OR matrix. It directly implements a sum of products formula.

22 Karnaugh-maps (K-maps) K-maps are used to simplify sum of products logical formulas (with 2, 3, or 4 inputs) using the truth table. K-map approach is to minimize the number of product terms Programs exists to simplify more complicated formulas A K-map for 2 inputs: x, y Why the need for simplified formulas? Smaller and thus cheaper logical components.

23 Example xyA

24 K-maps for 3-4 inputs

25 Examples: 3 input K-maps xyzFGHJ

26 Examples: 3 input K-maps The outputs simplify to:

27 Examples: 4 input K-maps

28 Combining Gates y Circuits for output functions: Output = x + yz, Output = x + yz and Output = (x +y)(x + z) z x Output = x + yz x z y x x y z Output = (x +y)(x + z)

29 Multiple Inputs We can construct a multiple-input gate consisting of many AND gates (or one with many OR gates). Due to the Associatively law, the order with which the gates are operated is not important. The output of a multiple-input AND gate is 1 only if all the inputs are. The output of a multiple-input OR gate is 1 if any of the inputs is 1. We can also place multiple inputs to other gates such as the NAND, NOR or XOR gates. The multiple gates XOR gates indicates 1 of the number of 1’s of odd and 0 if the number of 1’s is even. This feature can be used in error detection devices.

30 Multiple Inputs

31 Design of a computer component. Technology => Performance Transistor CMOS Logic Gate Wires Complex Cell

32 Basic Technology: CMOS CMOS: Complementary Metal Oxide Semiconductor –NMOS (N-Type Metal Oxide Semiconductor) transistors –PMOS (P-Type Metal Oxide Semiconductor) transistors NMOS Transistor –Apply a HIGH (Vdd) to its gate turns the transistor into a “conductor” –Apply a LOW (GND) to its gate shuts off the conduction path PMOS Transistor –Apply a HIGH (Vdd) to its gate shuts off the conduction path –Apply a LOW (GND) to its gate turns the transistor into a “conductor”

33 Basic Components: CMOS Inverter Inverter Operation OutIn NOT Symbol (Inverter) OutIn Vdd Out Open Discharge Open PMOS NMOS. Out

34 Basic Components: CMOS Logic Gates NAND Gate NOR Gate Vdd A B Out Vdd A B Out A B A B AB AB

35 Boolean Function Example Problem: Consider a logic function with three inputs: A, B, and C. Output D is true if at least one input is true Output E is true if exactly two inputs are true Output F is true only if all three inputs are true Show the truth table for these three functions. Show the Boolean equations for these three functions. Show an implementation consisting of inverters, AND, and OR gates.

36 Boolean Function Example Inputs: A, B. C; Outputs: D, E, F D is true if at least one input is true. E is true if exactly two inputs are true. F is true if all the inputs are true. The truth table will contain 2 3 = 8 entries

37 Boolean Function Example: PLA Abbreviated PLA

38 Boolean Function Example The Boolean Functions corresponding to the outputs above are: The equation for D: D = A + B + C The equation for F: F = ABC The equation for E:

39 The Multiplexor Selects one of the inputs to be the output, based on a control input If (S = = 0) C = A else C = B S C A B 0 1 note: we call this a 2-input mux even though it has 3 inputs! Or a 1-select multiplexor.

40 Implementing a 2-input multiplexor

41 The 1 bit Logical Unit for AND and OR b a 1 0 Result Operation

42 The Multiplexor with 2 selects if (S == 00) Out = A else if (S == 01) Out = B else if (S == 10) Out = C else if (S == 11) Out = D 2 A B C D Out S

43 Designing a Full Adder Binary addition is done with carries from right to left Input and output specification for a 1-bit adder

44 Designing a Full Adder From the sum of products formula, the Sum is: The sum of products formula for CarryOut can be simplified to give: One can design a Full Adder circuit with Inputs = a, b, CarryIn Outputs = Sum, CarryOut We will abstract this Full Adder circuit as  + b a CarryOut Sum CarryIn