Chapter 4 – Arithmetic Functions and HDLs Logic and Computer Design Fundamentals.

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

Arithmetic Functions and Circuits
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 4 – Arithmetic Functions Logic and Computer.
ELEC353 S. al Zahir UBC Sign-Magnitude Representation High order bit is sign: 0 = positive (or zero), 1 = negative Low order bits represent the magnitude:
Overview Iterative combinational circuits Binary adders
Arithmetic Operations and Circuits
Henry Hexmoor1 Chapter 5 Arithmetic Functions Arithmetic functions –Operate on binary vectors –Use the same subfunction in each bit position Can design.
Chapter 1 Binary Systems 1-1. Digital Systems
Overview Iterative combinational circuits Binary adders
Design of Arithmetic Circuits – Adders, Subtractors, BCD adders
Overview Iterative combinational circuits Binary adders
ECE 301 – Digital Electronics
Overview Iterative combinational circuits Binary adders
Chapter 5 Arithmetic Logic Functions. Page 2 This Chapter..  We will be looking at multi-valued arithmetic and logic functions  Bitwise AND, OR, EXOR,
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 4 – Arithmetic Functions Logic and Computer.
CS 105 Digital Logic Design
3-1 Chapter 3 - Arithmetic Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Outline Analysis of Combinational Circuits Signed Number Arithmetic
3-1 Chapter 3 - Arithmetic Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Principles of Computer Architecture.
Logical Circuit Design Week 8: Arithmetic Circuits Mentor Hamiti, MSc Office ,
Chap 3. Chap 3. Combinational Logic Design. Chap Combinational Circuits l logic circuits for digital systems: combinational vs sequential l Combinational.
Basic Arithmetic (adding and subtracting)
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
Digital Arithmetic and Arithmetic Circuits
Introduction to Chapter 6  Digital circuits are frequently used for arithmetic operations  Fundamental arithmetic operations on binary numbers and digital.
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 4 – Arithmetic Functions Logic and Computer.
Chapter 6-1 ALU, Adder and Subtractor
Figure 5.1. Conversion from decimal to binary.. Table 5.1. Numbers in different systems.
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 4 – Arithmetic Functions Logic and Computer.
Arithmetic Functions and Circuits
Number Systems. Why binary numbers? Digital systems process information in binary form. That is using 0s and 1s (LOW and HIGH, 0v and 5v). Digital designer.
Week #5 Arithmetic Circuits
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Logic and Computer Design.
Operations on Bits Arithmetic Operations Logic Operations
Arithmetic Functions BIL- 223 Logic Circuit Design Ege University Department of Computer Engineering.
CHAPTER 4 Combinational Logic Design- Arithmetic Operation (Section 4.6&4.9)
Charles Kime & Thomas Kaminski © 2004 Pearson Education, Inc. Terms of Use (Hyperlinks are active in View Show mode) Terms of Use Logic and Computer Design.
1 CS 151: Digital Design Chapter 4: Arithmetic Functions and Circuits 4-1,2: Iterative Combinational Circuits and Binary Adders.
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 8 Arithmetic.
Topics covered: Arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Digital Logic Lecture 3 Binary Arithmetic By Zyad Dwekat The Hashemite University Computer Engineering Department.
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 Design Module –II Adders Amit Kumar Assistant Professor SCSE, Galgotias University, Greater Noida.
CS/EE 3700 : Fundamentals of Digital System Design Chris J. Myers Lecture 5: Arithmetic Circuits Chapter 5 (minus 5.3.4)
CS 151: Digital Design Chapter 4: Arithmetic Functions and Circuits
CPEN Digital System Design
Addition, Subtraction, Logic Operations and ALU Design
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.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
Instructor: Alexander Stoytchev CprE 281: Digital Logic.
1 CS 151 : Digital Design Chapter 4: Arithmetic Functions and Circuits 4-3 : Binary Subtraction.
MicroProcessors Lec. 4 Dr. Tamer Samy Gaafar. Course Web Page —
CS151 Introduction to Digital Design Chapter 4: Arithmetic Functions and HDLs 4-1: Iterative Combinational Circuits 4-2: Binary Adders 1Created by: Ms.Amany.
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
Gunjeet Kaur Dronacharya Group of Institutions. Binary Adder-Subtractor A combinational circuit that performs the addition of two bits is called a half.
1 Arithmetic Building Blocks Today: Signed ArithmeticFirst Hour: Signed Arithmetic –Section 5.1 of Katz’s Textbook –In-class Activity #1 Second Hour: Adder.
Haifeng Liu 2014 Fall College of Computer Science and Technology, Zhejiang University Chapter 4 – Arithmetic Functions and Circuits.
King Fahd University of Petroleum and Minerals
Arithmetic Functions & Circuits
Instructor: Alexander Stoytchev
Chapter 3 – Combinational Logic Design
Overview Part 1 – Design Procedure Part 2 – Combinational Logic
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Overview Iterative combinational circuits Binary adders
ECE 352 Digital System Fundamentals
Instructor: Alexander Stoytchev
Presentation transcript:

Chapter 4 – Arithmetic Functions and HDLs Logic and Computer Design Fundamentals

Chapter 4 2 Overview  4-1 Iterative combinational circuits  4-2 Binary adders Half and full adders Ripple carry and carry lookahead adders  4-3 Binary subtraction  4-4 Binary adder-subtractors Signed binary numbers Signed binary addition and subtraction Overflow  4-5 Other arithmetic functions Design by contraction  4-6 Hardware Description language

Chapter Iterative Combinational Circuits  Arithmetic functions Operate on binary vectors Use the same subfunction in each bit position  Can design functional block for subfunction and repeat to obtain functional block for overall function  Cell - subfunction block  Iterative array - a array of interconnected cells  An iterative array can be in a single dimension (1D) or multiple dimensions

Chapter 4 4 Block Diagram of a 1D Iterative Array  Example (didn’t use iteration design): Design a n = 32 bits adder directly Number of inputs = ? Truth table rows = ? Equations with up to ? input variables Equations with huge number of terms Design impractical!  Iterative array takes advantage of the regularity to make design feasible

Chapter Binary Adders  Binary addition used frequently  Addition Development: Half-Adder (HA), a 2-input bit-wise addition functional block, Full-Adder (FA), a 3-input bit-wise addition functional block,  Ripple Carry Adder, an iterative array to perform binary addition, and  Carry-Look-Ahead Adder (CLA), a hierarchical structure to improve performance.

Chapter 4 6 Functional Block: Half-Adder  A 2-input, 1-bit width binary adder that performs the following computations:  A half adder adds two bits to produce a two-bit sum  The sum is expressed as a sum bit, S and a carry bit, C  The half adder can be specified as a truth table for S and C  X Y C S X Y C S

Chapter 4 7 Implementations: Half-Adder  The most common half adder implementation is: Y XC YXS   X Y C S

Chapter 4 8 Functional Block: Full-Adder  A full adder is similar to a half adder, but includes a carry-in bit from lower stages. Like the half-adder, it computes a sum bit, S and a carry bit, C. For a carry-in (Z) of 0, it is the same as the half-adder: For a carry- in (Z) of 1: Z0000 X Y C S Z1111 X Y C S

Chapter 4 9 Logic Optimization: Full-Adder  Full-Adder Truth Table:  Full-Adder K-Map:

Chapter 4 10 Equations: Full-Adder  From the K-Map, we get:  The S function is the three-bit XOR function (Odd Function):  The Carry bit C is 1 if both X and Y are 1 (the sum is 2), or if the sum is 1 and a carry-in (Z) occurs. Thus C can be re-written as:  The term X·Y is carry generate.  The term X  Y is carry propagate. ZYZXYXC ZYXZYXZYXZYXS   ZYXS  Z)YX(YXC 

Chapter 4 11 Full Adder Fig. 4-4

Chapter bit Ripple-Carry Binary Adder  A four-bit Ripple Carry Adder made from four 1-bit Full Adders:

Chapter 4 13 Binary Adders  To add multiple operands, we “bundle” logical signals together into vectors and use functional blocks that operate on the vectors  Example: 4-bit ripple carry adder: Adds input vectors A(3:0) and B(3:0) to get a sum vector S(3:0)  Note: carry out of cell i becomes carry in of cell i + 1

Chapter Binary Subtraction  Unsigned Subtraction  Algorithm: Subtract the subtrahend N from the minuend M If no end borrow occurs, then M  N, and the result is a non-negative number and correct. If an end borrow occurs, the N > M and the difference M  N + 2 n is subtracted from 2 n, and a minus sign is appended to the result.  Examples: See page 173 in textbook.

Chapter 4 15 Unsigned Subtraction (continued)  The subtraction, 2 n  N, is taking the 2’s complement of N  To do both unsigned addition and unsigned subtraction requires:  Quite complex!  Goal: Shared simpler logic for both addition and subtraction  Introduce complements as an approach

Chapter 4 16 Complements  Two complements: Diminished Radix Complement of N  (r  1)’s complement for radix r  1’s complement for radix 2  Defined as (r n     Radix Complement  r’s complement for radix r  2’s complement in binary  Defined as r n  N  Subtraction is done by adding the complement of the subtrahend  If the result is negative, takes its 2’s complement

Chapter 4 17 Binary 1's Complement  For r = 2, N = , n = 8 (8 digits): (r n – 1) = = or  The 1's complement of is then: –  Since the 2 n – 1 factor consists of all 1's and since 1 – 0 = 1 and 1 – 1 = 0, the one's complement is obtained by complementing each individual bit (bitwise NOT).

Chapter 4 18 Binary 2's Complement  For r = 2, N = , n = 8 (8 digits), we have: (r n ) = or  The 2's complement of is then: –  Note the result is the 1's complement plus 1, a fact that can be used in designing hardware

Chapter 4 19 Subtraction with 2’s Compleme nt  For n-digit, unsigned numbers M and N, find M  N in base 2: Add the 2's complement of the subtrahend N to the minuend M: M + (2 n  N) = M  N + 2 n If M  N, the sum produces end carry r n which is discarded; from above, M  N remains. If M < N, the sum does not produce an end carry and, from above, is equal to 2 n  ( N  M ), the 2's complement of ( N  M ). To obtain the result  (N – M), take the 2's complement of the sum and place a  to its left.

Chapter 4 20 Unsigned 2’s Complement Subtraction (Example 4-2)  Find – –  The carry of 1 indicates that no correction of the result is required. 1 2’s comp

Chapter 4 21 Unsigned 2’s Complement Subtraction (Example 4-2)  Find – – –  The carry of 0 indicates that a correction of the result is required.  Result = – ( ) 0 2’s comp

Chapter Binary Adder-Substractor Figure 4-7

Chapter 4 23 Signed Integers  Positive numbers and zero can be represented by unsigned n-digit, radix r numbers. We need a representation for negative numbers.  To represent a sign (+ or –) we need exactly one more bit of information (1 binary digit gives 2 1 = 2 elements which is exactly what is needed).  Since computers use binary numbers, by convention, the most significant bit is interpreted as a sign bit: s a n–2  a 2 a 1 a 0 where: s = 0 for Positive numbers s = 1 for Negative numbers and a i = 0 or 1 represent the magnitude in some form.

Chapter 4 24 Signed Integer Representations  Signed-Magnitude – here the n – 1 digits are interpreted as a positive magnitude.  Signed-Complement – here the digits are interpreted as the rest of the complement of the number. There are two possibilities here: Signed 1's Complement  Uses 1's Complement Arithmetic Signed 2's Complement  Uses 2's Complement Arithmetic

Chapter 4 25 Signed Integer Representation Example  r =2, n=3

Chapter 4 26 Signed 2s complement is mainly used 4-bits binary signed numbers

Chapter 4 27 Signed-Complement Arithmetic  Addition: 1. Add the numbers including the sign bits, discarding a carry out of the sign bits (2's Complement), or using an end-around carry (1's Complement). 2. If the sign bits were the same for both numbers and the sign of the result is different, an overflow has occurred. 3. The sign of the result is computed in step 1.  Subtraction: Form the complement of the number you are subtracting and follow the rules for addition.

Chapter 4 28  See Example 4-3 and 4-4 in Page 181 and 182 of textbook, respectively. Signed 2’s Complement Examples

Chapter 4 29 Overflow Detection (See P. 184, textbook)  Overflow occurs if n + 1 bits are required to contain the result from an n-bit addition or subtraction  Overflow can occur for: Addition of two operands with the same sign Subtraction of operands with different signs  Signed number overflow cases : Carries 0 1 Carries

Chapter 4 30 Overflow Detection  Simplest way to implement overflow V = C n + C n 

Chapter Other Arithmetic Functions  Convenient to design the functional blocks by contraction - removal of redundancy from circuit to which input fixing has been applied  Functions Incrementing Decrementing Multiplication by Constant Division by Constant Zero Fill and Extension

Chapter 4 32 Design by Contraction  Contraction is a technique for simplifying the logic in a functional block to implement a different function The new function must be realizable from the original function by applying rudimentary functions to its inputs After application of 0s and 1s, equations or the logic diagram are simplified by using rules given on pages 186 of the text.

Chapter 4 33 Design by Contraction Example  Contraction of a ripple carry adder to incrementer (A+1) for n = 3 Set B = 001 The middle cell can be repeated to make an incrementer with n > 3. Fig. 4-9

Chapter 4 34 Incrementing & Decrementing  Incrementing Adding a fixed value to an arithmetic variable Fixed value is often 1, called counting (up) Examples: A + 1, B + 4 Functional block is called incrementer  Decrementing Subtracting a fixed value from an arithmetic variable Fixed value is often 1, called counting (down) Examples: A  1, B  4 Functional block is called decrementer

Chapter 4 35 Example 4-6  Design a decrementer A-1. For single bit addition by using a FA with Perform

Chapter 4 36 Multiplication by a Constant (Multiplication of B(3:0) by 101)

Chapter 4 37 Multiplication/Division by 2 n  (a) Multiplication by 100 Shift left by 2  (b) Division by 100 Shift right by 2 Remainder preserved B 0 B 1 B 2 B 3 C 0 C 1 00 C 2 C 3 C 4 C 5 (a) B 0 B 1 B 2 B 3 C 0 C C -2 C 1 C 2 00 C 3 (b)

Chapter 4 38 Zero Fill  Zero fill - filling an m-bit operand with 0s to become an n-bit operand with n > m  Filling usually is applied to the MSB end of the operand, but can also be done on the LSB end  Example: filled to 16 bits MSB end: LSB end:

Chapter 4 39 Extension  Extension - increase in the number of bits at the MSB end of an operand by using a complement representation Copies the MSB of the operand into the new positions Positive operand example: extended to 16 bits: Negative operand example: extended to 16 bits:

Chapter Hardware Description language  We will learn HDL some days in the future. It is neglect at this moment.