1 CS 140 Lecture 14 Standard Combinational Modules Professor CK Cheng CSE Dept. UC San Diego Some slides from Harris and Harris.

Slides:



Advertisements
Similar presentations
ECE2030 Introduction to Computer Engineering Lecture 13: Building Blocks for Combinational Logic (4) Shifters, Multipliers Prof. Hsien-Hsin Sean Lee School.
Advertisements

Introduction So far, we have studied the basic skills of designing combinational and sequential logic using schematic and Verilog-HDL Now, we are going.
Arithmetic for Computers
Datapath Functional Units. Outline  Comparators  Shifters  Multi-input Adders  Multipliers.
Lecture Adders Half adder.
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.
EECS Components and Design Techniques for Digital Systems Lec 18 – Arithmetic II (Multiplication) David Culler Electrical Engineering and Computer.
CS 140 Lecture 13 Combinational Standard Modules Professor CK Cheng CSE Dept. UC San Diego 1.
Chapter 6 Arithmetic. Addition Carry in Carry out
CS 140 Lecture 14 Professor CK Cheng 11/14/02. Part II. Standard Modules A.Interconnect B.Operators. Adders Multiplier Adders1. Representation of numbers.
ECE C03 Lecture 61 Lecture 6 Arithmetic Logic Circuits Hai Zhou ECE 303 Advanced Digital Design Spring 2002.
Chapter # 5: Arithmetic Circuits Contemporary Logic Design Randy H
Lecture 8 Arithmetic Logic Circuits
Arithmetic-Logic Units CPSC 321 Computer Architecture Andreas Klappenecker.
EE466: VLSI Design Lecture 14: Datapath Functional Units.
Introduction to CMOS VLSI Design Datapath Functional Units
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Spring 2002EECS150 - Lec10-cl1 Page 1 EECS150 - Digital Design Lecture 10 - Combinational Logic Circuits Part 1 Feburary 26, 2002 John Wawrzynek.
Datapath Functional Units Adapted from David Harris of Harvey Mudd College.
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.
3-1 Chapter 3 - Arithmetic Computer Architecture and Organization by M. Murdocca and V. Heuring © 2007 M. Murdocca and V. Heuring Computer Architecture.
Lecture 18: Datapath Functional Units
Chapter 6-2 Multiplier Multiplier Next Lecture Divider
Chapter 5 :: Digital Building Blocks
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.
Chapter # 5: Arithmetic Circuits
Chapter 6-1 ALU, Adder and Subtractor
Introduction to Computer Organization and Architecture Lecture 10 By Juthawut Chantharamalee wut_cha/home.htm.
5-1 Programmable and Steering Logic Chapter # 5: Arithmetic Circuits.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
55:035 Computer Architecture and Organization Lecture 5.
Advanced VLSI Design Unit 05: Datapath Units. Slide 2 Outline  Adders  Comparators  Shifters  Multi-input Adders  Multipliers.
Csci 136 Computer Architecture II – Constructing An Arithmetic Logic Unit Xiuzhen Cheng
EECS Components and Design Techniques for Digital Systems Lec 16 – Arithmetic II (Multiplication) David Culler Electrical Engineering and Computer.
1 CPSC3850 Adders and Simple ALUs Simple Adders Figures 10.1/10.2 Binary half-adder (HA) and full-adder (FA). Digit-set interpretation: {0, 1}
July 2005Computer Architecture, The Arithmetic/Logic UnitSlide 1 Part III The Arithmetic/Logic Unit.
FPGA-Based System Design: Chapter 4 Copyright  2003 Prentice Hall PTR Topics n Number representation. n Shifters. n Adders and ALUs.
Spring C:160/55:132 Page 1 Lecture 19 - Computer Arithmetic March 30, 2004 Sukumar Ghosh.
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 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
N, Z, C, V in CPSR with Adder & Subtractor Prof. Taeweon Suh Computer Science Education Korea University.
CSE 140 Lecture 12 Combinational Standard Modules CK Cheng CSE Dept. UC San Diego 1.
Topics covered: Arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
COMP541 Arithmetic Circuits
C-H1 Lecture Adders Half adder. C-H2 Full Adder si is the modulo- 2 sum of ci, xi, yi.
CPEN Digital System Design
Addition, Subtraction, Logic Operations and ALU Design
Chapter 5 Computer System Architectures Chapter 5 Based on Digital Design and Computer Architecture, 2 nd Edition David Money Harris and Sarah L. Harris.
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.
Arithmetic-Logic Units. Logic Gates AND gate OR gate NOT gate.
CSE 140 Lecture 13 Combinational Standard Modules Professor CK Cheng CSE Dept. UC San Diego 1.
Lecture #23: Arithmetic Circuits-1 Arithmetic Circuits (Part I) Randy H. Katz University of California, Berkeley Fall 2005.
Computer Organization and Design Arithmetic & Logic Circuits Montek Singh Nov 2, 2015 Lecture 11.
EE204 L03-ALUHina Anwar Khan EE204 Computer Architecture Lecture 03- ALU.
CSE 140 Lecture 12 Combinational Standard Modules CK Cheng CSE Dept. UC San Diego 1.
President UniversityErwin SitompulDigital Systems 7/1 Lecture 7 Digital Systems Dr.-Ing. Erwin Sitompul President University
1 The ALU l ALU includes combinational logic. –Combinational logic  a change in inputs directly causes a change in output, after a characteristic delay.
ETE 204 – Digital Electronics Combinational Logic Design Single-bit and Multiple-bit Adder Circuits [Lecture: 9] Instructor: Sajib Roy Lecturer, ETE,ULAB.
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.
CSE 140 Lecture 12 Combinational Standard Modules
CSE 140 Lecture 12 Combinational Standard Modules
CS 140 Lecture 14 Standard Combinational Modules
CSE 140 Lecture 14 Standard Combinational Modules
Instructor: Mozafar Bag-Mohammadi University of Ilam
Presentation transcript:

1 CS 140 Lecture 14 Standard Combinational Modules Professor CK Cheng CSE Dept. UC San Diego Some slides from Harris and Harris

2 Part III. Standard Modules A.Interconnect B.Operators. Adders Multiplier Adders1. Representation of numbers 2. Full Adder 3. Half Adder 4. Ripple-Carry Adder 5. Carry Look Ahead Adder 6. Prefix Adder ALU Multiplier Division

Operators Specification: Data Representations Arithmetic: Algorithms Logic: Synthesis Layout: Placement and Routing 3

4 1. Representation 2’s Complement -x: 2 n -x 1’s Complement -x: 2 n -x-1

5 1. Representation Id2’s comp. 1’s comp ’s Complement -x: 2 n -x e.g. 16-x 1’s Complement -x: 2 n -x-1 e.g. 16-x-1

6 1. Representation Id-Binarysign mag2’s comp1’s comp

7 Representation 1’s Complement For a negative number, we take the positive number and complement every bit. 2’s Complement For a negative number, we do 1s complement and plus one. (b n-1, b n-2, …, b 0 ): -b n-1 2 n-1 + sum i<n-1 b i 2 i

8 Representation 2’s Complement x+y x-y: x+2 n -y= 2 n +x-y -x+y: 2 n -x+y -x-y: 2 n -x+2 n -y = 2 n +2 n -x-y -(-x)=2 n -(2 n -x)=x 1’s Complement x+y x-y: x+2 n -y-1= 2 n -1+x-y -x+y: 2 n -x-1+y=2 n -1-x+y -x-y: 2 n -x-1+2 n -y-1 = 2 n -1+2 n -x-y-1 -(-x)=2 n -(2 n -x-1) -1=x

= = -1 (2’s) = -1 (1’s) Examples = -5 (2’s) = -5 (1’s) = C 4 C 3 Check for overflow (2’s) = C 4 C 3

10 Addition: 2’s Complement Overflow In 2’s complement: overflow = c n xor c n-1 Exercise: 1.Demonstrate the overflow with more examples. 2.Prove the condition.

11 Adder MUX Sum minus bb’ a C out overflow C4C4 C3C3 C in Addition and Subtraction using 2’s Complement

12 1-Bit Adders

13 a b C out S um S um = ab’ + a’b = a + b C out = ab C out S um abab HA a b S um C out Half Adder

14 Full Adder Composed of Half Adders HA a b c in x sum c out OR sum c out sum y z

15 Full Adder Composed of Half Adders HA a b c in x sum c out sum c out sum y z Idabc in xyzc out s um Idxzc out

16 Adder 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. Symbol

17 Chain 1-bit adders together Carry ripples through entire chain Disadvantage: slow Ripple-Carry Adder

18 The delay of an N-bit ripple-carry adder is: t ripple = Nt FA where t FA is the delay of a full adder Ripple-Carry Adder Delay

19 Compress the logic levels of C out Some definitions: –Generate (G i ) and propagate (P i ) signals for each column: A column will generate a carry out if A i AND B i are both 1. G i = A i B i A column will propagate a carry in to the carry out if A i OR B i is 1. P i = A i + B i The carry out of a column (C i ) is: C i+1 = A i B i + (A i + B i )C i = G i + P i C i Carry-Lookahead Adder

20 Carry Look Ahead Adder C 1 = a 0 b 0 + (a 0 +b 0 )c 0 = g 0 + p 0 c 0 C 2 = a 1 b 1 + (a 1 +b 1 )c 1 = g 1 + p 1 c 1 = g 1 + p 1 g 0 + p 1 p 0 c 0 C 3 = a 2 b 2 + (a 2 +b 2 )c 2 = g 2 + p 2 c 2 = g 2 + p 2 g 1 + p 2 p 1 g 0 + p 2 p 1 p 0 c 0 C 4 = a 3 b 3 + (a 3 +b 3 )c 3 = g 3 + p 3 c 3 = g 3 + p 3 g 2 + p 3 p 2 g 1 + p 3 p 2 p 1 g 0 + p 3 p 2 p 1 p 0 c 0 q i = a i b i p i = a i + b i a 3 b 3 g3g3 p 3 a 2 b 2 g2g2 p 2 a 1 b 1 g1g1 p 1 a 0 b 0 g0g0 p 0 c1c1 c2c2 c3c3 c4c4 c0c0

21 Step 1: compute generate (G) and propagate (P) signals for columns (single bits) Step 2: compute G and P for k-bit blocks Step 3: C in propagates through each k-bit propagate/generate block Carry-Lookahead Addition

22 32-bit CLA with 4-bit blocks

23 Delay of an N-bit carry-lookahead adder with k-bit blocks: t CLA = t pg + t pg_block + (N/k – 1)t AND_OR + kt FA where –t pg : delay of the column generate and propagate gates –t pg_block :delay of the block generate and propagate gates –t AND_OR :delay from C in to C out of the final AND/OR gate in the k-bit CLA block An N-bit carry-lookahead adder is generally much faster than a ripple-carry adder for N > 16 Carry-Lookahead Adder Delay

24 Prefix Adder Computes the carry in (C i-1 ) for each of the columns as fast as possible and then computes the sum: S i = (A i  B i )  C i Computes G and P for 1-bit, then 2-bit blocks, then 4-bit blocks, then 8-bit blocks, etc. until the carry in (generate signal) is known for each column Has log 2 N stages

25 Prefix Adder A carry in is produced by being either generated in a column or propagated from a previous column. Define column -1 to hold C in, so G -1 = C in, P -1 = 0 Then, the carry in to col. i = the carry out of col. i-1: C i-1 = G i-1:-1 G i-1:-1 is the generate signal spanning columns i-1 to -1. There will be a carry out of column i-1 (C i-1 ) if the block spanning columns i-1 through -1 generates a carry. Thus, we rewrite the sum equation:S i = (A i  B i )  G i-1:-1 Goal: Compute G 0:-1, G 1:-1, G 2:-1, G 3:-1, G 4:-1, G 5:-1, … (These are called the prefixes)

26 Prefix Adder The generate and propagate signals for a block spanning bits i:j are: G i:j = G i:k  P i:k G k-1:j P i:j = P i:k P k-1:j In words, these prefixes describe that: –A block will generate a carry if the upper part (i:k) generates a carry or if the upper part propagates a carry generated in the lower part (k-1:j) –A block will propagate a carry if both the upper and lower parts propagate the carry.

27 Prefix Adder Schematic

28 The delay of an N-bit prefix adder is: t PA = t pg + log 2 N(t pg_prefix ) + t XOR where –t pg is the delay of the column generate and propagate gates (AND or OR gate) –t pg_prefix is the delay of the black prefix cell (AND-OR gate) Prefix Adder Delay

29 Compare the delay of 32-bit ripple-carry, carry- lookahead, and prefix adders. The carry-lookahead adder has 4-bit blocks. Assume that each two-input gate delay is 100 ps and the full adder delay is 300 ps. Adder Delay Comparisons

30 Compare the delay of 32-bit ripple-carry, carry- lookahead, and prefix adders. The carry-lookahead adder has 4-bit blocks. Assume that each two-input gate delay is 100 ps and the full adder delay is 300 ps. t ripple = Nt FA = 32(300 ps) = 9.6 ns t CLA = t pg + t pg_block + (N/k – 1)t AND_OR + kt FA = [ (7) (300)] ps = 3.3 ns t PA = t pg + log 2 N(t pg_prefix ) + t XOR = [100 + log 2 32(200) + 100] ps = 1.2 ns Adder Delay Comparisons

31 Comparator: Equality

32 Comparator: Less Than For unsigned numbers

33 Arithmetic Logic Unit (ALU) F 2:0 Function 000A & B 001A | B 010A + B 011not used 100A & ~B 101A | ~B 110A - B 111SLT

34 ALU Design F 2:0 Function 000A & B 001A | B 010A + B 011not used 100A & ~B 101A | ~B 110A - B 111SLT

35 Set Less Than (SLT) Example Configure a 32-bit ALU for the set if less than (SLT) operation. Suppose A = 25 and B = 32.

36 Set Less Than (SLT) Example Configure a 32-bit ALU for the set if less than (SLT) operation. Suppose A = 25 and B = 32. –A is less than B, so we expect Y to be the 32-bit representation of 1 (0x ). –For SLT, F 2:0 = 111. –F 2 = 1 configures the adder unit as a subtracter. So = -7. –The two’s complement representation of -7 has a 1 in the most significant bit, so S 31 = 1. –With F 1:0 = 11, the final multiplexer selects Y = S 31 (zero extended) = 0x

37 Shifters Logical shifter: shifts value to left or right and fills empty spaces with 0’s –Ex: >> 2 = –Ex: << 2 = Arithmetic shifter: same as logical shifter, but on right shift, fills empty spaces with the old most significant bit (msb). –Ex: >>> 2 = –Ex: <<< 2 = Rotator: rotates bits in a circle, such that bits shifted off one end are shifted into the other end –Ex: ROR 2 = –Ex: ROL 2 = 00111

38 Shifter Design

Shifter Can be implemented with a mux s d yiyi En x i+1 x i-1 xixi s d xnxn x0x0 x -1 x n-1 y n -1 y0y0 En s / n l / r y i = x i-1 if En = 1, s = 1, and d = L = x i+1 if En = 1, s = 1, and d = R = x i if En = 1, s = 0 = 0 if En = 0

Barrel Shifter O or 1 shift O or 2 shift O or 4 shift x s0s0 s1s1 s2s2 y 0 1 shift

41 Shifters as Multipliers and Dividers A left shift by N bits multiplies a number by 2 N –Ex: << 2 = (1 × 2 2 = 4) –Ex: << 2 = (-3 × 2 2 = -12) The arithmetic right shift by N divides a number by 2 N –Ex: >>> 2 = (8 ÷ 2 2 = 2) –Ex: >>> 2 = (-16 ÷ 2 2 = -4)

42 Multipliers Steps of multiplication for both decimal and binary numbers: –Partial products are formed by multiplying a single digit of the multiplier with the entire multiplicand –Shifted partial products are summed to form the result

43 4 x 4 Multiplier

44 Division Algorithm Q = A/B R: remainder D: difference R = A for i = N-1 to 0 D = R - B if D < 0 then Q i = 0, R’ = R // R < B else Q i = 1, R’ = D // R  B R = 2R’

45 4 x 4 Divider