1 / 70

Introduction to Computer Organization and Architecture

Introduction to Computer Organization and Architecture. Lecture 10 By Juthawut Chantharamalee http://dusithost.dusit.ac.th/~juthawut_cha/home.htm. Outline. Adders Comparators Shifters Multipliers Dividers Floating Point Numbers. Binary Representations of Numbers.

Télécharger la présentation

Introduction to Computer Organization and Architecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Computer Organization and Architecture Lecture 10 By Juthawut Chantharamalee http://dusithost.dusit.ac.th/~juthawut_cha/home.htm

  2. Outline • Adders • Comparators • Shifters • Multipliers • Dividers • Floating Point Numbers Introduction to Computer Organization and Architecture

  3. Binary Representations of Numbers • To find negative numbers • Sign and magnitude: msb = ‘1’ • 1’s complement: complement each bit to change sign • 2’s complement: 2n – positive number Introduction to Computer Organization and Architecture

  4. Single-Bit Addition Half Adder Full Adder Introduction to Computer Organization and Architecture 4

  5. Single-Bit Addition Half Adder Full Adder Introduction to Computer Organization and Architecture

  6. Carry-Ripple Adder • Simplest design: cascade full adders • Critical path goes from Cin to Cout • Design full adder to have fast carry delay Introduction to Computer Organization and Architecture

  7. Carry Propagate Adders • N-bit adder called CPA • Each sum bit depends on all previous carries • How do we compute all these carries quickly? Introduction to Computer Organization and Architecture

  8. Propagate and Generate - Define • An n-bit adder is just a combinational circuit • si = a XOR b XOR c = aibi’ci’ + ai’bici’ + ai’bi’ci + aibici • ci+1 = MAJ(a,b,c) = aibi + aici + bici • Want to write si in “sum of products” form • ci+1 = gi + pici, where gi = aibi, pi = ai + bi • if gi is true, then ci+1 is true, thus carry is generated • if pi is true, and if ci is true, ci is propagated • Note that the pi equation can also be written as pi = ai XOR bi since gi = 1 when ai = bi = 1 (i.e. generate occurs, so propagate is a “don’t care”) Introduction to Computer Organization and Architecture

  9. Propagate and Generate - Blocks • In the general case, for any j with i<j, j+1<k • ck+1 = Gik + Pikci • Gik = Gj+1,k + Pj+1,k Gij • Pik = PijPj+1,k • Gik equation in words: • A carry is generated out of the block consisting of bits i through k inclusive if • it is generated in the high-order part of the block (j+1, k) or • it is generated in the low-order (i,j) part of the block and then propagated through the high part Introduction to Computer Organization and Architecture

  10. Propagate and Generate-Lookahead Recursively apply to eliminate carry terms ci+1 = gi + pigi-1 + pipi-1gi-2 + … + pipi-1…p1g0 + pipi-1…p1p0c0 This is a carry-lookahead adder Note large fan-in of OR gate and last AND gate Too big! Build p’s and g’s in steps c1 = g0 + p0c0 c2 = G01 + P01c0 Where: G01 = g1 + p1g0,P01 = p1p0 Introduction to Computer Organization and Architecture 10

  11. PG Logic Introduction to Computer Organization and Architecture

  12. Carry-Ripple Revisited • G03 = G3 + P3 G02 Introduction to Computer Organization and Architecture

  13. Carry-Skip Adder • Carry-ripple is slow through all N stages • Carry-skip allows carry to skip over groups of n bits • Decision based on n-bit propagate signal Introduction to Computer Organization and Architecture

  14. Carry-Lookahead Adder • Carry-lookahead adder computes G0i for many bits in parallel. • Uses higher-valency cells with more than two inputs. Introduction to Computer Organization and Architecture

  15. Carry-Select Adder • Trick for critical paths dependent on late input X • Precompute two possible outputs for X = 0, 1 • Select proper output when X arrives • Carry-select adder precomputes n-bit sums • For both possible carries into n-bit group Introduction to Computer Organization and Architecture

  16. Comparators • 0’s detector: A = 00…000 • 1’s detector: A = 11…111 • Equality comparator: A = B • Magnitude comparator: A < B Introduction to Computer Organization and Architecture

  17. 1’s & 0’s Detectors • 1’s detector: N-input AND gate • 0’s detector: NOTs + 1’s detector (N-input NOR) Introduction to Computer Organization and Architecture

  18. Equality Comparator • Check if each bit is equal (XNOR, aka equality gate) • 1’s detect on bitwise equality Introduction to Computer Organization and Architecture

  19. Magnitude Comparator • Compute B-A and look at sign • B-A = B + ~A + 1 • For unsigned numbers, carry out is sign bit Introduction to Computer Organization and Architecture

  20. Signed vs. Unsigned • For signed numbers, comparison is harder • C: carry out • Z: zero (all bits of A-B are 0) • N: negative (MSB of result) • V: overflow (inputs had different signs, output sign  B) Introduction to Computer Organization and Architecture

  21. Shifters • Logical Shift: • Shifts number left or right and fills with 0’s • 1011 LSR 1 = ____ 1011 LSL1 = ____ • Arithmetic Shift: • Shifts number left or right. Rt shift sign extends • 1011 ASR1 = ____ 1011 ASL1 = ____ • Rotate: • Shifts number left or right and fills with lost bits • 1011 ROR1 = ____ 1011 ROL1 = ____ Introduction to Computer Organization and Architecture

  22. Shifters • Logical Shift: • Shifts number left or right and fills with 0’s • 1011 LSR 1 = 0101 1011 LSL1 = 0110 • Arithmetic Shift: • Shifts number left or right. Rt shift sign extends • 1011 ASR1 = 1101 1011 ASL1 = 0110 • Rotate: • Shifts number left or right and fills with lost bits • 1011 ROR1 = 1101 1011 ROL1 = 0111 Introduction to Computer Organization and Architecture

  23. Funnel Shifter • A funnel shifter can do all six types of shifts • Selects N-bit field Y from 2N-bit input • Shift by k bits (0  k < N) Introduction to Computer Organization and Architecture

  24. Funnel Shifter Operation • Computing N-k requires an adder Introduction to Computer Organization and Architecture

  25. Funnel Shifter Operation • Computing N-k requires an adder Introduction to Computer Organization and Architecture

  26. Funnel Shifter Operation • Computing N-k requires an adder Introduction to Computer Organization and Architecture

  27. Funnel Shifter Operation • Computing N-k requires an adder Introduction to Computer Organization and Architecture

  28. Funnel Shifter Operation • Computing N-k requires an adder Introduction to Computer Organization and Architecture

  29. Simplified Funnel Shifter • Optimize down to 2N-1 bit input Introduction to Computer Organization and Architecture

  30. Simplified Funnel Shifter • Optimize down to 2N-1 bit input Introduction to Computer Organization and Architecture

  31. Simplified Funnel Shifter • Optimize down to 2N-1 bit input Introduction to Computer Organization and Architecture

  32. Simplified Funnel Shifter • Optimize down to 2N-1 bit input Introduction to Computer Organization and Architecture

  33. Simplified Funnel Shifter • Optimize down to 2N-1 bit input Introduction to Computer Organization and Architecture

  34. Funnel Shifter Design 1 • N N-input multiplexers • Use 1-of-N hot select signals for shift amount Introduction to Computer Organization and Architecture

  35. Funnel Shifter Design 2 • Log N stages of 2-input muxes • No select decoding needed Introduction to Computer Organization and Architecture

  36. Multi-input Adders • Suppose we want to add k N-bit words • Ex: 0001 + 0111 + 1101 + 0010 = _____ Introduction to Computer Organization and Architecture

  37. Multi-input Adders • Suppose we want to add k N-bit words • Ex: 0001 + 0111 + 1101 + 0010 = 10111 Introduction to Computer Organization and Architecture

  38. Multi-input Adders • Suppose we want to add k N-bit words • Ex: 0001 + 0111 + 1101 + 0010 = 10111 • Straightforward solution: k-1 N-input CPAs • Large and slow Introduction to Computer Organization and Architecture

  39. Carry Save Addition • A full adder sums 3 inputs and produces 2 outputs • Carry output has twice weight of sum output • N full adders in parallel are called carry save adder • Produce N sums and N carry outs Introduction to Computer Organization and Architecture

  40. CSA Application • Use k-2 stages of CSAs • Keep result in carry-save redundant form • Final CPA computes actual result Introduction to Computer Organization and Architecture

  41. CSA Application • Use k-2 stages of CSAs • Keep result in carry-save redundant form • Final CPA computes actual result Introduction to Computer Organization and Architecture

  42. CSA Application • Use k-2 stages of CSAs • Keep result in carry-save redundant form • Final CPA computes actual result Introduction to Computer Organization and Architecture

  43. Multiplication • Example: Introduction to Computer Organization and Architecture

  44. Multiplication • Example: Introduction to Computer Organization and Architecture

  45. Multiplication • Example: Introduction to Computer Organization and Architecture

  46. Multiplication • Example: Introduction to Computer Organization and Architecture

  47. Multiplication • Example: Introduction to Computer Organization and Architecture

  48. Multiplication • Example: Introduction to Computer Organization and Architecture

  49. Multiplication • Example: • M x N-bit multiplication • Produce N M-bit partial products • Sum these to produce M+N-bit product Introduction to Computer Organization and Architecture

  50. General Form • Multiplicand: Y = (yM-1, yM-2, …, y1, y0) • Multiplier: X = (xN-1, xN-2, …, x1, x0) • Product: Introduction to Computer Organization and Architecture

More Related