SlideServe
Menu
Préférences
© SlideServe · v2026

Building a 32-Bit ALU: Implementation and Optimization

gudrun avatar
12 diapositives · 206 Views · Aug 15, 2014

Explore the design and implementation of a 32-bit Arithmetic Logic Unit (ALU) for supporting MIPS instructions, including addition, subtraction, comparison, and optimization techniques. Learn the importance of efficient hardware organization and the role of gates in ALU performance.

Building a 32-Bit ALU: Implementation and Optimization - slide 1
01 / 12Building a 32-Bit ALU: Implementation and Optimization
1 / 17

Télécharger la présentation

Building a 32-Bit ALU: Implementation and Optimization
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. operation a ALU 32 result 32 b 32 Arithmetic • Where we've been: • Abstractions: Instruction Set Architecture Assembly Language and Machine Language • What's up ahead: • Implementing the Architecture

  2. Review: Boolean Algebra & Gates • Problem: Consider a logic function with three inputs: A, B, and C. Output D is true if at least one input is true Output E is true if exactly two inputs are true Output F is true only if all three inputs are true • Show the truth table for these three functions. • Show the Boolean equations for these three functions. • Show an implementation consisting of inverters (NOT), AND, and OR gates.

  3. operation op a b res result An ALU (arithmetic logic unit) • Let's build an ALU to support the andi and ori instructions • we'll just build a 1 bit ALU, and use 32 of them • Possible Implementation: • could use sum-of-products, but there’s an easier way a b

  4. S A C B Review: The Multiplexor • Selects one of the inputs to be the output, based on a control input • What does it look like on the inside? (p. B-9) • C = (A AND Not(S)) OR (B AND S) • Let’s build our ALU using a MUX:Figure 4.9, p. 231 note: we call this a 2-input mux even though it has 3 inputs! 0 1

  5. Different Implementations • Not easy to decide the “best” way to build something • Don't want too many inputs to a single gate • Don’t want to have to go through too many gates • for our purposes, ease of comprehension is important • Let's look at a 1-bit ALU for addition: • How could we build a 1-bit ALU for add, and, and or? (p. 234) • How could we build a 32-bit ALU? (p. 235) cout = a b + a cin + b cin (set if at least 2 inputs are set) sum = a xor b xor cin (set if exactly 1 input is set or all 3 are set

  6. Building a 32 bit ALU

  7. What about subtraction (a – b) ? • Two's complement approach: just negate b and add. • How do we negate? • A very clever solution (p. 236):

  8. Tailoring the ALU to the MIPS • Need to support the set-on-less-than instruction (slt) • remember: slt is an arithmetic instruction • produces a 1 if rs < rt and 0 otherwise • use subtraction: (a-b) < 0 implies a < b • Need to support test for equality (beq $t5, $t6, $t7) • use subtraction: (a-b) = 0 implies a = b

  9. Supporting slt • Can we figure out the idea?

  10. Test for equality • Notice control lines:000 = and001 = or010 = add110 = subtract111 = slt • Note: zero is a 1 when the result is zero! • See p. 241 for ALU symbol

  11. Conclusion • We can build an ALU to support the MIPS instruction set • key idea: use multiplexor to select the output we want • we can efficiently perform subtraction using two’s complement • we can replicate a 1-bit ALU to produce a 32-bit ALU • Important points about hardware • all of the gates are always working • the speed of a gate is affected by the number of inputs to the gate • the speed of a circuit is affected by the number of gates in series (on the “critical path” or the “deepest level of logic”) • Our primary focus: comprehension, however, • Clever changes to organization can improve performance (similar to using better algorithms in software) • There are faster ways to do addition, for example. See pp. 241-249