COMP541 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

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.
Mohamed Younis CMCS 411, Computer Architecture 1 CMCS Computer Architecture Lecture 7 Arithmetic Logic Unit February 19,
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
1 CS 140 Lecture 14 Standard Combinational Modules Professor CK Cheng CSE Dept. UC San Diego Some slides from Harris and Harris.
ECE C03 Lecture 61 Lecture 6 Arithmetic Logic Circuits Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Lecture 8 Arithmetic Logic Circuits
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
1 COMP541 Arithmetic Circuits Montek Singh Mar 20, 2007.
ECE 301 – Digital Electronics
ECE 301 – Digital Electronics
Overview Iterative combinational circuits Binary adders
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
ENGIN112 L14: Binary Adder Subtractor October 3, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 14 Binary Adders and Subtractors.
9/15/09 - L15 Decoders, Multiplexers Copyright Joanne DeGroat, ECE, OSU1 Binary additon & subtraction.
Charles Kime & Thomas Kaminski © 2008 Pearson Education, Inc. (Hyperlinks are active in View Show mode) Chapter 4 – Arithmetic Functions Logic and Computer.
3-1 Chapter 3 - Arithmetic Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Binary Arithmetic Stephen Boyd March 14, Two's Complement Most significant bit represents sign. 0 = positive 1 = negative Positive numbers behave.
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.
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)
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Arithmetic Circuits II Anselmo Lastra.
IT253: Computer Organization
Digital Arithmetic and Arithmetic Circuits
IKI a-Combinatorial Components Bobby Nazief Semester-I The materials on these slides are adopted from those in CS231’s Lecture Notes.
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
Week #5 Arithmetic Circuits
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
Basic Arithmetic (adding and subtracting)
Csci 136 Computer Architecture II – Constructing An Arithmetic Logic Unit Xiuzhen Cheng
1 Arithmetic Logic Unit ALU. 2 The Bus Concept 3 CPU Building Blocks  Registers (IR, PC, ACC)  Control Unit (CU)  Arithmetic Logic Unit (ALU)
Arithmetic Logic Unit (ALU) Anna Kurek CS 147 Spring 2008.
CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013.
1 Arithmetic I Instructor: Mozafar Bag-Mohammadi Ilam University.
Lecture 4. Adder & Subtractor Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System Education & Research.
COMP541 Arithmetic Circuits
Computer Architecture Lecture 3 Combinational Circuits Ralph Grishman September 2015 NYU.
N, Z, C, V in CPSR with Adder & Subtractor Prof. Taeweon Suh Computer Science Education Korea University.
Sep 29, 2004Subtraction (lvk)1 Negative Numbers and Subtraction The adders we designed can add only non-negative numbers – If we can represent negative.
08 ARTH Page 1 ECEn/CS 224 Number Representation and Binary Arithmetic.
Topics covered: Arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Kavita Bala CS 3410, Spring 2014 Computer Science Cornell University.
MIPS ALU. Building from the adder to ALU ALU – Arithmetic Logic Unit, does the major calculations in the computer, including – Add – And – Or – Sub –
ECE 331 – Digital System Design Multi-bit Adder Circuits, Adder/Subtractor Circuit, and Multiplier Circuit (Lecture #12)
1 IKI20210 Pengantar Organisasi Komputer Kuliah No. 23: Aritmatika 18 Desember 2002 Bobby Nazief Johny Moningka
Addition, Subtraction, Logic Operations and ALU Design
1 Fundamentals of Computer Science Combinational Circuits.
Two’s and one’s complement arithmetic CLOCK ARITHMETIC.
ECE/CS 552: Arithmetic I Instructor:Mikko H Lipasti Fall 2010 University of Wisconsin-Madison Lecture notes partially based on set created by Mark Hill.
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.
1 Lecture 14 Binary Adders and Subtractors. 2 Overview °Addition and subtraction of binary data is fundamental Need to determine hardware implementation.
Lecture #23: Arithmetic Circuits-1 Arithmetic Circuits (Part I) Randy H. Katz University of California, Berkeley Fall 2005.
Computer Arthmetic Chapter Four P&H. Data Representation Why do we not encode numbers as strings of ASCII digits inside computers? What is overflow when.
ECE DIGITAL LOGIC LECTURE 15: COMBINATIONAL CIRCUITS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 10/20/2015.
MIPS ALU. Exercise – Design a selector? I need a circuit that takes two input bits, a and b, and a selector bit s. The function is that if s=0, f=a. if.
MicroProcessors Lec. 4 Dr. Tamer Samy Gaafar. Course Web Page —
EE204 L03-ALUHina Anwar Khan EE204 Computer Architecture Lecture 03- ALU.
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.
Addition and multiplication1 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.
ENG241 Digital Design Week #5 Arithmetic Circuits.
1 Arithmetic Building Blocks Today: Signed ArithmeticFirst Hour: Signed Arithmetic –Section 5.1 of Katz’s Textbook –In-class Activity #1 Second Hour: Adder.
Binary Arithmetic Binary arithmetic is essential in all digital computers and in many other types of digital systems. Addition, Subtraction, Multiplication,
EE207: Digital Systems I, Semester I 2003/2004
Overview Part 1 – Design Procedure Part 2 – Combinational Logic
Presentation transcript:

COMP541 Arithmetic Circuits Montek Singh Mar 26, 2012

Test #1: Take Home Will assign it Wednesday, 3/28 Give you five days to work on it (due 4/2) Covers topics up to Lecture 15 (Memories II)

Today’s Topics Adder circuits How to subtract Overflow Why complemented representation works out so well Overflow

Iterative Circuit Like a hierachy, except functional blocks per bit

Adders Great example of this type of design Design 1-bit circuit, then expand Let’s look at Half adder – 2-bit adder, no carry in Inputs are bits to be added Outputs: result and possible carry Full adder – includes carry in, really a 3-bit adder

Half Adder S = X  Y C = XY

Full Adder Three inputs. Third is Cin Two outputs: sum and carry

Two Half Adders (and an OR)

Ripple-Carry Adder Straightforward – connect full adders Carry-out to carry-in chain C0 in case this is part of larger chain, or just ‘0’

Hierarchical 4-Bit Adder We can easily use hierarchy here Design half adder Use in full adder Use full adder in 4-bit adder

Behavioral Verilog // 4-bit Adder: Behavioral Verilog module adder_4_b_v(A, B, C0, S, C4); input[3:0] A, B; input C0; output[3:0] S; output C4; assign {C4, S} = A + B + C0; endmodule Addition (unsigned) Concatenation operation

What’s the Problem with this Design? Delay Approx how much? Imagine a 64-bit adder Look at carry chain

Delays (Post Place and Route) Odd delays caused by placement

Multibit Adders Several types of carry propagate adders (CPAs) are: Ripple-carry adders (slow) Carry-lookahead adders (fast) Prefix adders (faster) Carry-lookahead and prefix adders are faster for large adders but require more hardware. Adder symbol (right)

Carry Lookahead Adder Note that add itself just 2 level Idea is to separate carry from adder function Then make carry approx 2-level all way across larger adder

Four-bit Ripple Carry Reference Adder function separated from carry Notice adder has A, B, C in and S out, as well as G,P out.

Propagate The P signal is called propagate P = A  B Means to propagate incoming carry

Generate The G is generate So it’s ORed with incoming carry G = AB, so new carry created So it’s ORed with incoming carry

Said Differently If A  B and there’s incoming carry, carry will be propagated And S will be 0, of course If AB, then will create carry Incoming will determine whether S is 0 or 1

Ripple Carry Delay: 8 Gates

Turn Into Two Gate Delays Design changed from deep (in delay) to wide

C1 Just Like Ripple Carry

C2 Circuit Two Levels G from before and P to pass on This checks two propagates and a carry in

C3 Circuit Two Levels Generate from level 0 and two propagates G from before and P to pass on This checks three propagates and a carry in

What Happens as Scale Up? Can I realistically make 64-bit adder like this? Have to AND 63 propagates and Cin! Compromise Hierarchical design More levels of gates

Making 4-Bit Adder Module Create propagate and generate signals for whole module

Group Propagate Make propagate of whole 4-bit block P0-3 = P3P2P1P0

Group Generate Does G created upstream pass on because of string of Ps (also G3)? Indicates carry generated in block

Hierarchical Carry Left lookahead block is exercise for you 4-bit adder A B S G P Cin C0 Look Ahead C8 C4 Left lookahead block is exercise for you

Practical Matters FPGAs like ours have limited inputs per block Instead they have special circuits to make adders So don’t expect to see same results as theory would suggest

Other Adder Circuits What if hierarchical lookahead too slow Other styles exist Prefix adder (explained in text) had a tree to computer generate and propagate Pipelined arithmetic units – multicycle but enable faster clock speed These are for self-study We might cover later in semester, time permitting

On to Subtraction First, look at unsigned numbers Motivates why we typically use complemented representation Then look at 2’s complement Imagine a subtractor circuit (next)

One-bit Subtractor Inputs: Borrow in, minuend and subtrahend Review: subtrahend is subtracted from minuend Outputs: Difference, borrow out Could use like adder One per bit 1-bit sub M S Bout D Bin

Example Borrow 1 Minuend Subtrahend Difference Correct Diff - If no borrow, then result is non-negative (minuend >= subtrahend). Borrow 1 Minuend Subtrahend Difference Correct Diff - Since there is borrow, result must be negative. The magnitude must be corrected. Next slide.

Correcting Result What, mathematically, does it mean to borrow? If borrowing at digit i-1 you are adding 2i Next Slide

Correcting Result 2 If M is minuend and N subtrahend of numbers length n, difference was 2n + M – N What we want is magnitude of N-M (with minus sign in front) Can get by subtracting previous result from 2n N - M = 2n – (M – N + 2n) This is called 2’s complement

Put Another Way This is equivalent to how we do subtraction in our heads Decide which is greater Swap if necessary Subtract Could build a circuit this way… Or just look at borrow bit

Algorithm Subtract N from M If no borrow, then M  N and result is OK Otherwise, N > M so result must be subtracted from 2n (and minus sign prepended)

Pretty Expensive Hardware!

That Complex Design not Used That’s why people use complemented interpretation for numbers 2’s complement 1’s complement

1’s Complement Given: binary number N with n digits 1’s complement defined as (2n – 1) - N 2n - 1 1 - N 1’s Compl.

2’s Complement Given: binary number N with n digits 2’s complement defined as 2n – N for N  0 0 for N = 0 Exception is so result will always have n bits 2’s complement is just a 1 added to 1’s complement

Observations 1’s C and Signed Mag have two zeros 2’s C has more negative than positive All negative numbers have 1 in high-order

Adder-Subtractor Need only adder and complementer for input to subtract Need selective complementer to make negative output back from 2’s complement Or go through adder again. See next slide

Advantages/Disadvantages Signed magnitude has problem that we need to correct after subtraction One’s complement has a positive and negative zero Two’s complement is most popular Arithmetic operations easy

Conclusion: 2’s Complement Addition easy on any combination of positive and negative numbers To subtract Take 2’s complement of subtrahend Add This performs A + ( -B), same as A – B

Design of Adder/Subtractor S low for add, high for subtract Inverts each bit of B if S is 1 Adds 1 to make 2’s complement Output is 2’s complement if B > A

Overflow Two cases of overflow for addition of signed numbers Two large positive numbers overflow into sign bit Not enough room for result Two large negative numbers added Same – not enough bits Carry out can be OK

Overflow Examples 4-bit signed numbers: Sometimes a leftmost carry is generated without overflow: -7 + 7 5 + (-3) Sometimes a leftmost carry is not generated, but overflow occurs: 4 + 4

Overflow Detection Basic condition: if two +ve numbers are added and sum is –ve if two -ve numbers are added and sum is +ve Can be simplified to the following check: either Cn-1 or Cn is high, but not both

Summary Today Next class: adders and subtractors overflow full processor datapath Test #1 released