Single Bit ALU 3 R e s u l t O p r a i o n 1 C y I B v b 2 L S f w d O

Slides:



Advertisements
Similar presentations
Arithmetic for Computers
Advertisements

CMPT 334 Computer Organization Chapter 3 Arithmetic for Computers [Adapted from Computer Organization and Design 5 th Edition, Patterson & Hennessy, ©
Lecture 9 Sept 28 Chapter 3 Arithmetic for Computers.
331 W07.1Spring :332:331 Computer Architecture and Assembly Language Spring 2006 Week 7 ALU Design [Adapted from Dave Patterson’s UCB CS152 slides.
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
Chap 3.3~3.5 Construction an Arithmetic Logic Unit (ALU) Jen-Chang Liu, Spring 2006.
Computer Systems Organization: Lecture 3
Integer Multiplication and Division
1 Lecture 8: Binary Multiplication & Division Today’s topics:  Addition/Subtraction  Multiplication  Division Reminder: get started early on assignment.
Chapter Four Arithmetic and Logic Unit
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
Chapter 3 Arithmetic for Computers. Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's.
Lecture Objectives: 1)Explain the relationship between addition and subtraction with twos complement numbering systems 2)Explain the concept of numeric.
1 Bits are just bits (no inherent meaning) — conventions define relationship between bits and numbers Binary numbers (base 2)
Lec 13Systems Architecture1 Systems Architecture Lecture 13: Integer Multiplication and Division Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan.
Computer Architecture Chapter 3 Instructions: Arithmetic for Computer Yu-Lun Kuo 郭育倫 Department of Computer Science and Information Engineering Tunghai.
Chapter 3 Arithmetic for Computers (Integers). Florida A & M University - Department of Computer and Information Sciences Arithmetic for Computers Operations.
Conversion to Larger Number of Bits Ex: Immediate Field (signed 16 bit) to 32 bit Positive numbers have implied 0’s to the left. So, put 16 bit number.
05/03/2009CA&O Lecture 8,9,10 By Engr. Umbreen sabir1 Computer Arithmetic Computer Engineering Department.
Integer Multiplication and Division
CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013.
Fast Carry Algorithm a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15 c0.
Ch3b- 2 EE/CS/CPE Computer Organization  Seattle Pacific University There is logic to it andRd, Rs, RtRd
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
Orange Coast College Business Division Computer Science Department CS 116- Computer Architecture Arithmetic: Part II.
EI 209 Chapter 3.1CSE, 2015 EI 209 Computer Organization Fall 2015 Chapter 3: Arithmetic for Computers Haojin Zhu ( )
Division Check for 0 divisor Long division approach – If divisor ≤ dividend bits 1 bit in quotient, subtract – Otherwise 0 bit in quotient, bring down.
CDA 3101 Spring 2016 Introduction to Computer Organization
Integer Multiplication, Division Arithmetic shift Twice the number of places MIPS multiply unit. mult, multu Significant bits Mfhi, mflo, div, divu Arithmetic.
Integer Multiplication and Division COE 301 Computer Organization Dr. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University.
Integer Multiplication and Division ICS 233 Computer Architecture & Assembly Language Prof. Muhamed Mudawar College of Computer Sciences and Engineering.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
Computer System Design Lecture 3
Computer Architecture & Operations I
Computer Arthmetic Chapter Four P&H.
Integer Multiplication, Division Arithmetic shift
Somet things you should know about digital arithmetic:
Computer Architecture & Operations I
Lecture Adders Half adder.
Integer Multiplication and Division
COMPUTER ARCHITECTURE & OPERATIONS I
Arithmetic for Computers
CS 314 Computer Organization Fall Chapter 3: Arithmetic for Computers
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers
CDA 3101 Summer 2007 Introduction to Computer Organization
CDA 3101 Spring 2016 Introduction to Computer Organization
CS352H: Computer Systems Architecture
Lecture 8: Addition, Multiplication & Division
Lecture 8: Addition, Multiplication & Division
Topic 3b Computer Arithmetic: ALU Design
CDA 3101 Summer 2007 Introduction to Computer Organization
Systems Architecture I
Computer Architecture & Operations I
ECE232: Hardware Organization and Design
The University of Adelaide, School of Computer Science
Topic 3b Computer Arithmetic: ALU Design
CS 140 Lecture 14 Standard Combinational Modules
Addition & Subtraction
The University of Adelaide, School of Computer Science
CSE 140 Lecture 14 Standard Combinational Modules
Instructor: Mozafar Bag-Mohammadi University of Ilam
A 1-Bit Arithmetic Logic Unit
Computer Architecture EECS 361 Lecture 6: ALU Design
CSC3050 – Computer Architecture
MIPS Arithmetic and Logic Instructions
Number Representation
MIPS Arithmetic and Logic Instructions
Lecture 2 Adders Half adder.
Presentation transcript:

Single Bit ALU 3 R e s u l t O p r a i o n 1 C y I B v b 2 L S f w d O 3 R e s u l t O p r a i o n 1 C y I B v b 2 L S f w d O v e r f l o w c t i o n b .

CarryOut = ab + aCI + bCI a b CI + CarryOut

c0 a0 b0 a1 b1 a2 b2 a3 b3 a4 b4 a5 b5 2 gates c1 4 gates c2 c3 6 gates Ripple Carry c4 ci+1 = ai bi + ai ci + bi ci 8 gates 10 gates c5 c6 12 Gates

Carry Lookahead Adder ci is CarryIn i c1 = a0 b0 + (a0+b0)c0

Carry Lookahead Adder ci is CarryIn i c1 = a0 b0 + (a0+b0)c0 c2 = a1 b1 + (a1+b1)c1 = a1 b1 + (a1+b1)[a0 b0 + (a0+b0)c0] = a1b1+a1a0b0+a1a0c0+a1b0c0+b1a0b0+ b1a0c0+b1b0c0

c1 = a0 b0 + (a0+b0)c0 c2 = a1 b1 + (a1+b1)c1 c lah c2 c1 c1 = a0 b0 + (a0+b0)c0 c2 = a1 b1 + (a1+b1)c1 = a1 b1 + (a1+b1)[a0 b0 + (a0+b0)c0] = a1b1+a1a0b0+a1a0c0+a1b0c0+b1a0b0+b1a0c0+b1b0c0 + c2

Carry Lookahead Adder ci is CarryIn i c1 = a0 b0 + (a0+b0)c0 c2 = a1 b1 + (a1+b1)c1 = a1 b1 + (a1+b1)[a0 b0 + (a0+b0)c0] = a1b1+a1a0b0+a1a0c0+b1a0b0+b1a0c0+b1b0c0 One bit lookahead ci two gate delays from ci-2 for i even Reduces gate delays for 32 bits from 64 to 32

Carry Lookahead Adder ci is CarryIn i c1 = a0 b0 + (a0+b0)c0 c2 = a1 b1 + (a1+b1)c1 = a1 b1 + (a1+b1)[a0 b0 + (a0+b0)c0] c2 =a1b1+a1a0b0+a1a0c0+a1b0c0+b1a0b0+b1a0c0+b1b0c0 One bit lookahead ci two gate delays from ci-2 for i even Reduces gate delays for 32 bits from 64 to 32 c3 = a2b2+(a2+b2)c2 c4 = a3b3+(a3+b3)c3 c4 = a3b3+(a3+b3) [a2b2+(a2+b2)c2] c4 =a3b3+a3a2b2+a3a2c2+a3b2c2+b3a2b2+b3a2c2+b3b2c2

c0 a0 b0 a1 b1 One Bit Lookahead a2 b2 a3 b3 c1 c2 a4 b4 a5 b5 c3 c4 c lah a2 b2 a3 b3 c1 c c2 c lah a4 b4 a5 b5 c3 c4 c lah c 6 Gates c5 c6

Carry Lookahead Adder ci is CarryIn i c1 = a0 b0 + (a0+b0)c0 c2 = a1 b1 + (a1+b1)c1 = a1 b1 + (a1+b1)[a0 b0 + (a0+b0)c0] c3 = a2 b2 + (a2+b2)c2 = a2 b2 + (a2+b2){a1 b1+(a1+b1)[a0 b0+(a0+b0)c0]}

Carry Lookahead Adder ci is CarryIn i c1 = a0 b0 + (a0+b0)c0 c2 = a1 b1 + (a1+b1)c1 = a1 b1 + (a1+b1)[a0 b0 + (a0+b0)c0] c3 = a2 b2 + (a2+b2)c2 = a2 b2 + (a2+b2){a1 b1+(a1+b1)[a0 b0+(a0+b0)c0]} Note the patterns generate gi = ai bi propagate pi = ai + bi ci+1 = gi + pi ci if gi = 1, ci+1 = 1, if gi = 0 and pi = 1, ci+1 = ci

Carry Lookahead Adder ci is CarryIn i generate gi = ai bi propagate pi = ai + bi ci+1 = gi + pi ci c1 = g0+p0c0

Carry Lookahead Adder ci is CarryIn i generate gi = ai bi propagate pi = ai + bi ci+1 = gi + pi ci c1 = g0+p0c0 c2 = g1+p1g0+p1p0c0

Carry Lookahead Adder ci is CarryIn i generate gi = ai bi propagate pi = ai + bi ci+1 = gi + pi ci c1 = g0+p0c0 c2 = g1+p1g0+p1p0c0 c3 = g2+p2g1+p2p1g0+p2p1p0c0

Carry Lookahead Adder ci is CarryIn i generate gi = ai bi propagate pi = ai + bi ci+1 = gi + pi ci c1 = g0+p0c0 c2 = g1+p1g0+p1p0c0 c3 = g2+p2g1+p2p1g0+p2p1p0c0 c4 = g3+p3g2+p3p2g1+p3p2p1g0+p3p2p1p0c0

Carry Lookahead Adder ci is CarryIn i generate gi = ai bi propagate pi = ai + bi ci+1 = gi + pi ci c1 = g0+p0c0 c2 = g1+p1g0+p1p0c0 c3 = g2+p2g1+p2p1g0+p2p1p0c0 c4 = g3+p3g2+p3p2g1+p3p2p1g0+p3p2p1p0c0 Limited by Gate Fan-in contraints

Carry Lookahead Adder ci is CarryIn i ci+1 = gi + pi ci c1 = g0+p0c0 c2 = g1+p1g0+p1p0c0 c3 = g2+p2g1+p2p1g0+p2p1p0c0 c4 = g3+p3g2+p3p2g1+p3p2p1g0+p3p2p1p0c0 c5 = g4+p4c4 c6 = g5+p5g4+p5p4c4 c7 = g6+p6g5+p6p5g4+p6p5p4c4 c8 = g7+p7g6+p7p6g5+p7p6p5g4+p7p6p5p4c4 Each 4 bit stage has 2 gate delays per stage + 1 for g & p

Using Generate & Propagate 4 bit Carry Lookahead Using Generate & Propagate c0 a0,...,a3 b0,...,b3 generate gi = ai bi propagate pi = ai + bi ci+1 = gi + pi ci ALU s0,...s3 c4 a4,...,a7 b4,...,b7 g p ALU s4,...,s7 1 c8 g p a8,...,a11 b8,...,b11 ALU s8,...s11 2 c12 a12,...,a15 b12,...,b15 g p ALU s12,...,s15 3 c16

4 bit Carry Lookahead 2nd Level Lookahead c0 a0,...,a3 b0,...,b3 ALU so,...s3 c4 a4,...,a7 b4,...,b7 g p ALU s4,...,s7 1 c8 g p a8,...,a11 b8,...,b11 ALU s8,...s11 2 c12 c8 a12,...,a15 b12,...,b15 g p G P ALU s12,...,s15 3 c16

G2 = g11+p11g10+p11p10g9+p11p10p9g8 P2 = p11p10p9p8 c12= G2 +P2c8 c8 g a8,...,a11 b8,...,b11 ALU s8,...s11 2 c12 a12,...,a15 b12,...,b15 g p G P ALU s12,...,s15 3 c16

G2 = g11+p11g10+p11p10g9+p11p10p9g8 P2 = p11p10p9p8 c12= G2 +P2c8 c13=g12+p12G2+p12P2c8 c8 g p a8,...,a11 b8,...,b11 ALU s8,...s11 2 c12 a12,...,a15 b12,...,b15 g p G P ALU s12,...,s15 3 c16

G2 = g11+p11g10+p11p10g9+p11p10p9g8 P2 = p11p10p9p8 c12= G2 +P2c8 c13=g12+p12G2+p12P2c8 c14=g13+p13g12+p13p12G2+p13p12P2c8 c8 g p a8,...,a11 b8,...,b11 ALU s8,...s11 2 c12 a12,...,a15 b12,...,b15 g p G P ALU s12,...,s15 3 c16

G2 = g11+p11g10+p11p10g9+p11p10p9g8 P2 = p11p10p9p8 c12= G2 +P2c8 c13=g12+p12G2+p12P2c8 c14=g13+p13g12+p13p12G2+p13p12P2c8 c15=g14+p14g13+p14p13g12+p14p13p12G2 +p14p13p12P2c8 c8 g p a8,...,a11 b8,...,b11 ALU s8,...s11 2 c12 a12,...,a15 b12,...,b15 g p G P ALU s12,...,s15 3 c16

G2 = g11+p11g10+p11p10g9+p11p10p9g8 P2 = p11p10p9p8 c12= G2 +P2c8 c13=g12+p12G2+p12P2c8 c14=g13+p13g12+p13p12G2+p13p12P2c8 c15=g14+p14g13+p14p13g12+p14p13p12G2 +p14p13p12P2c8 c16=g15+etc c8 g p a8,...,a11 b8,...,b11 ALU s8,...s11 2 c12 a12,...,a15 b12,...,b15 g p G P ALU s12,...,s15 3 c16

Logical Instructions shift left logical sll Shift left shamt bits and fill with 0’s sll $s1, $s2, 10 # $s1 = $s2 << 10 op rs rt rd shamt funct 0 0 18 17 10 0

Logical Instructions shift left logical sll Shift left shamt bits and fill with 0’s sll $s1, $s2, 10 # $s1 = $s2 << 10 op rs rt rd shamt funct 0 0 18 17 10 0 shift right logical srl Shift right shamt bits and fill with 0’s srl $t0, $s0, 16 # $t0 = $s0 >> 16

Logical Instructions logical AND and bit- by-bit logical AND and $s0, $s1, $s2 # $s0 = $s1 & $s2 op rs rt rd shamt funct 0 17 18 16 0 36

Logical Instructions logical AND and bit- by-bit logical AND and $s0, $s1, $s2 # $s0 = $s1 & $s2 op rs rt rd shamt funct 0 17 18 16 0 36 logical AND immediate andi $t0, $t1, 7 # $t0 = $t1 & (000...0111)

Logical Instructions logical AND and bit- by-bit logical AND and $s0, $s1, $s2 # $s0 = $s1 & $s2 op rs rt rd shamt funct 0 17 18 16 0 36 logical AND immediate andi $t0, $t1, 7 # $t0 = $t1 & (000...0111) logical OR or $s1, $t1, $s2 # $s1 = $t1 | $s2 logical OR immediate ori $t1, $s1, 8 # $t1 = $s1 | (000..01000)

Multiplication - Positive numbers Example: 0010 Multiplicand x 1011 Multiplier

Multiplication - Positive numbers Example: 0010 Multiplicand x 1011 Multiplier 0010

Multiplication - Positive numbers Example: 0010 Multiplicand x 1011 Multiplier 0010

Multiplication - Positive numbers Example: 0010 Multiplicand x 1011 Multiplier 0010 0000

Multiplication - Positive numbers Example: 0010 Multiplicand x 1011 Multiplier 0010 0000

Multiplication - Positive numbers Example: 0010 Multiplicand x 1011 Multiplier 0010 0000 0010110 Product

Multiplication - Positive numbers Example: 0010 Multiplicand n bits x 1011 Multiplier m bits 0010 add 0010 shift left and add 0000 shift left and do nothing 0010 shift left and add 0010110 Product n+m bits

Multiplicand 00000010 Multiplier 1011 Control Test Product 00000000 Shift left 00000010 Multiplier 1011 8 bit ALU Control Test Shift right Product 00000000 1. 1 implies add

Multiplicand 00000010 Multiplier 1011 Control Test Product 00000010 Shift left 00000010 Multiplier 1011 8 bit ALU Shift right Control Test Product 00000010 1. 1 implies add 2. Shift

Multiplicand 00000100 Multiplier 1011 Control Test Product 00000010 Shift left 00000100 Multiplier 1011 8 bit ALU Shift right Control Test Product 00000010 1. 1 implies add

Multiplicand 00000100 Multiplier 1011 Control Test Product 00000110 Shift left 00000100 Multiplier 1011 8 bit ALU Shift right Control Test Product 00000110 1 implies add Shift

Multiplicand 00001000 Multiplier 1011 Control Test Product 00000110 Shift left 00001000 Multiplier 1011 8 bit ALU Shift right Control Test Product 00000110 0 no op

Multiplicand 00001000 Multiplier 1011 Control Test Product 00000110 Shift left 00001000 Multiplier 1011 8 bit ALU Shift right Control Test Product 00000110 0 no op Shift

Multiplicand 00010000 Multiplier 1011 Control Test Product 00000110 Shift left 00010000 Multiplier 1011 8 bit ALU Shift right Control Test Product 00000110 1 implies add

Multiplicand 00010000 Multiplier 1011 Control Test Product 00010110 Shift left 00010000 Multiplier 1011 8 bit ALU Shift right Control Test Product 00010110 1 implies add Shift

Multiplicand 00100000 Multiplier 1011 Control Test Product 00010110 Shift left 00100000 Multiplier 1011 8 bit ALU Shift right Control Test Product 00010110

Note: Half of the bits always 0 Multiplicand 00100000 Multiplier 1011 Shift left 00100000 Multiplier 1011 8 bit ALU Shift right Control Test Product 00010110

Multiplication - Positive numbers – Shift Sum Example: 0010 Multiplicand x 1011 Multiplier 0010

Multiplication - Positive numbers – Shift Sum Example: 0010 Multiplicand x 1011 Multiplier 0010

Multiplication - Positive numbers Multiplication - Positive numbers – Shift Sum Example: 0010 Multiplicand x 1011 Multiplier 0010 00110

Multiplication - Positive numbers Multiplication - Positive numbers – Shift Sum Example: 0010 Multiplicand x 1011 Multiplier 0010 00110

Multiplication - Positive numbers Multiplication - Positive numbers – Shift Sum Example: 0010 Multiplicand x 1011 Multiplier 0010 00110

Multiplication - Positive numbers Multiplication - Positive numbers – Shift Sum Example: 0010 Multiplicand x 1011 Multiplier 0010 00110 0010110

Multiplicand 0010 Multiplier 1011 Control Test Product 00000000 4 bit ALU Control Test Shift right Product 00000000 1. 1 implies add Shift right

Multiplicand 0010 Multiplier 1011 Control Test Product 00100000 4 bit ALU Control Test Shift right Product 00100000 1 implies add Shift Shift right

Multiplicand 0010 Multiplier 1011 Control Test Product 00010000 4 bit ALU Control Test Shift right Product 00010000 1 implies add Shift right

Multiplicand 0010 Multiplier 1011 Control Test Product 00110000 4 bit ALU Control Test Shift right Product 00110000 1 implies add Shift Shift right

Multiplicand 0010 Multiplier 1011 Control Test Product 00011000 4 bit ALU Control Test Shift right Product 00011000 0 no op Shift Shift right

Multiplicand 0010 Multiplier 1011 Control Test Product 00001100 4 bit ALU Control Test Shift right Product 00001100 1 implies add Shift right

Multiplicand 0010 Multiplier 1011 Control Test Product 00101100 4 bit ALU Control Test Shift right Product 00101100 1 implies add Shift Shift right

Multiplicand 0010 Multiplier 1011 Control Test Product 00010110 4 bit ALU Control Test Shift right Product 00010110 Shift right

Note: Product uses space as Multiplier decreases Multiplicand 0010 Multiplier 1011 4 bit ALU Control Test Shift right Product 00010110 Shift right Note: Product uses space as Multiplier decreases

Multiplicand 0010 Control Test Product 00001011 1. 1 implies add 4 bit ALU Control Test Product 00001011 1. 1 implies add Shift right Multiplier (1011)

Multiplicand 0010 Control Test Product 00101011 1 implies add Shift 4 bit ALU Control Test Product 00101011 1 implies add Shift Shift right Multiplier (1011) Multiplier

Multiplicand 0010 Control Test Product 00010101 1 implies add 4 bit ALU Control Test Product 00010101 1 implies add Shift right Multiplier (1011) Multiplier

Multiplicand 0010 Control Test Product 00110101 1 implies add Shift 4 bit ALU Control Test Product 00110101 1 implies add Shift Shift right Multiplier (1011) Multiplier

Multiplicand 0010 Control Test Product 00011010 0 no op Shift 4 bit ALU Control Test Product 00011010 0 no op Shift Shift right Multiplier (1011) Multiplier

Multiplicand 0010 Control Test Product 00001101 1 implies add 4 bit ALU Control Test Product 00001101 1 implies add Shift right Multiplier (1011) Multiplier

Multiplicand 0010 Control Test Product 00101101 1 implies add Shift 4 bit ALU Control Test Product 00101101 1 implies add Shift Shift right Multiplier (1011) Multiplier

Multiplicand 0010 Control Test Product 00010110 Multiplier (1011) 4 bit ALU Control Test Product 00010110 Shift right Multiplier (1011) Multiplier

MIPS Instructions for Multiply and Divide Hi,Lo are two 32 bit registers for Product and Remainder multiply mult $s1, $s2 # Hi,Lo = $s1 x $s2 For signed numbers, 1. determine the sign of the product 2. convert to positive representation 3. multiply 4. determine the sign and convert to 2’s complement if needed

MIPS Instructions for Multiply and Divide Hi,Lo are two 32 bit registers for Product and Remainder multiply mult $s1, $s2 # Hi,Lo = $s1 x $s2 multiply unsigned multu $s1, $s2 # Hi,Lo = $s1 x $s2 ( unsigned) MIPS ignores overflow, so it is up to the software. What is the overflow condition for mult $s1, $s2?

MIPS Instructions for Multiply and Divide Hi,Lo are two 32 bit registers for Product and Remainder multiply mult $s1, $s2 # Hi,Lo = $s1 x $s2 multiply unsigned multu $s1, $s2 # Hi,Lo = $s1 x $s2 ( unsigned) MIPS ignores overflow, so it is up to the software. What is the overflow condition for mult $s1, $s2? Hi must be zero or the sign extension of Lo.

MIPS Instructions for Multiply and Divide Hi,Lo are two 32 bit registers for Product and Remainder multiply mult $s1, $s2 # Hi,Lo = $s1 x $s2 multiply unsigned multu $s1, $s2 # Hi,Lo = $s1 x $s2 ( unsigned) move from Hi mfhi $s3 # $s3 = Hi

MIPS Instructions for Multiply and Divide Hi,Lo are two 32 bit registers for Product and Remainder multiply mult $s1, $s2 # Hi,Lo = $s1 x $s2 multiply unsigned multu $s1, $s2 # Hi,Lo = $s1 x $s2 ( unsigned) move from Hi mfhi $s3 # $s3 = Hi move from Lo mflo $s3 # $s3 = Lo