Arithmetic Algorithms: Multiplication and Division

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

In an array multiplier, what is the primary function of the AND gate within each cell?

  • To act as a full adder for the incoming partial product bit.
  • To shift the partial product one position to the left.
  • To determine whether a multiplicand bit is added based on the multiplier bit. (correct)
  • To perform the addition of the multiplicand and partial product bits.

What is the role of the full adder (FA) in each cell of an array multiplier?

  • To pass the partial product vertically downward unchanged.
  • To perform the AND operation between the multiplicand and multiplier bits.
  • To add the multiplicand bit to the incoming partial product bit. (correct)
  • To determine whether a shift operation is needed.

In the context of array multipliers, what does shifting the partial product to the left by one position per row achieve?

  • It compensates for the delay introduced by the full adders.
  • It simplifies the addition process by reducing the number of bits to be added.
  • It correctly aligns the partial products for addition based on their significance. (correct)
  • It ensures that the final product is properly scaled.

What is the purpose of using half adders in an n-bit by n-bit array multiplier?

<p>To handle cases where there are only two inputs to add. (D)</p> Signup and view all the answers

What is the 'critical path' in the context of an array multiplier?

<p>The longest path of input to output signal propagation through the array. (A)</p> Signup and view all the answers

In a sequential circuit multiplier, what is the purpose of the Add/Noadd signal?

<p>To determine whether the multiplicand should be added to the partial product. (A)</p> Signup and view all the answers

What is the function of the multiplexer (MUX) in a sequential circuit multiplier?

<p>To select either 0 or the multiplicand to be added to the partial product. (B)</p> Signup and view all the answers

In the context of multiplying signed numbers using 2's complement representation, what is the significance of sign extension?

<p>It maintains the correct sign and magnitude of the partial products. (B)</p> Signup and view all the answers

What is the primary advantage of using Booth's algorithm for multiplication?

<p>Booth's algorithm reduces the number of addition and subtraction operations by handling blocks of 1s in the multiplier more efficiently. (D)</p> Signup and view all the answers

In Booth's algorithm, what action is performed when transitioning from '1' to '0' in the multiplier bits (scanning from right to left)?

<p>Add the shifted multiplicand to the partial product. (B)</p> Signup and view all the answers

According to the content, what defines a "good multiplier" in the context of Booth's algorithm?

<p>A multiplier with a majority of 0s. (C)</p> Signup and view all the answers

What is the result of applying the transformation called "skipping over 1s"?

<p>Reducing the number of add/subtract operations in multiplication. (C)</p> Signup and view all the answers

In the restoring division algorithm, what action is taken if the remainder after a subtraction is negative?

<p>The quotient bit is set to 0 and the divisor is added back to the remainder. (C)</p> Signup and view all the answers

In the restoring division algorithm, what does 'repositioning the divisor' refer to?

<p>Shifting the divisor to the right. (B)</p> Signup and view all the answers

What is the benefit of pipelining in processor design?

<p>It increases the throughput of instructions by overlapping their execution. (D)</p> Signup and view all the answers

According to the content, what is the first step in a typical pipeline processor for each instruction?

<p>Fetch the instruction. (B)</p> Signup and view all the answers

What is the purpose of the storage buffer between stages in a pipeline?

<p>To temporarily hold information as it passes from one stage to the next. (D)</p> Signup and view all the answers

What is the function of registers R1 through R5 in the example pipeline organization described?

<p>To receive new data with every clock pulse. (A)</p> Signup and view all the answers

In a four-segment pipeline, how many clock pulses are required to retrieve the first output?

<p>Four clock pulses. (C)</p> Signup and view all the answers

If a non-pipelined processor takes time 'tn' to complete a task, what determines the speedup of a k-segment pipeline processing the same task?

<p>The ratio of 'tn' to 'tp'. (B)</p> Signup and view all the answers

What is instruction lookahead in the context of instruction pipelining?

<p>Overlapping the execution of current instructions with the fetch and decode of subsequent instructions. (A)</p> Signup and view all the answers

What is the purpose of processor pipelining?

<p>To process the same data stream by a cascade of processors for specific tasks. (A)</p> Signup and view all the answers

In a floating-point adder pipeline, what step follows comparing the exponents of the two numbers?

<p>Aligning the mantissa. (B)</p> Signup and view all the answers

In a floating-point adder pipeline, what is the purpose of "normalizing the result"?

<p>To ensure a unique representation of the floating-point number. (A)</p> Signup and view all the answers

According to the content, what is a resource conflict in a pipeline?

<p>When two segments try to access the same memory at the same time. (D)</p> Signup and view all the answers

What is the primary cause of data dependency conflicts in pipelines?

<p>Instructions depending on results not yet available from previous instructions. (C)</p> Signup and view all the answers

What is the cause of Write After Read (WAR) hazards in pipelining?

<p>An instruction attempts to modify a data object that is read by a subsequent instruction. (D)</p> Signup and view all the answers

In the context of pipeline hazards, what is 'data forwarding'?

<p>A technique to bypass stalls by providing data directly to waiting instructions. (D)</p> Signup and view all the answers

What is a common approach to detect hazards in a pipeline processor?

<p>Comparing the domain and range of incoming instructions with those being processed. (B)</p> Signup and view all the answers

Flashcards

Unsigned Multiplication

Product of 2 n bit numbers is at most 2n bit number. Unsigned multiplication can be viewed as addition of shifted versions of the multiplicand.

Array Multiplier

A combinational two-dimensional logic array is used to implement binary multiplication.

Array Multiplier Hardware

An n bit by n bit array multiplier requires n² AND gates and n(n-2) full adders and n half adders.

Critical Path

The longest path of input to output in an array multiplier.

Signup and view all the flashcards

Sequential Circuit Multiplier

Multiplication is performed as a series of conditional addition and shift operations.

Signup and view all the flashcards

Conditional Add and Shift

If the given bit of the multiplier is 0 then only a shift operation is performed, while if the given bit of the multiplier is 1 then addition of the partial products and a shift operation are performed.

Signup and view all the flashcards

Add signal in sequential multiplication

Adds the multiplicand M with register A and the result is stored in A, if LSB of the multiplier q₁ =1.

Signup and view all the flashcards

Signed Multiplication

Multiplication of 2’s-complement operands, generating a double-length product with sign extension.

Signup and view all the flashcards

Sign Extension

Extend the sign-bit value of the multiplicand to the left as far as the product will extend.

Signup and view all the flashcards

Number sign

Sign bit is 0 then the number is positive, If the sign bit is 1, then the number is negative

Signup and view all the flashcards

Negative Multiplier

Form the 2's-complement of both the multiplier and the multiplicand and proceed as in the case of a positive multiplier for a negative multiplier.

Signup and view all the flashcards

Booth Algorithm

An algorithm for signed multiplication that handles both positive and negative multipliers efficiently.

Signup and view all the flashcards

Booth Multiplication Initialization

The multiplier and multiplicand are loaded into two registers Q and BR. Third register A and C are initialized to 0.

Signup and view all the flashcards

Booth Algorithm Steps

Compare Qn and Qn+1 and perform the following depending on bit combinations.

Signup and view all the flashcards

ASHR in Booth's Algorithm

Arithmetic Shift Right operation on AC and QR.

Signup and view all the flashcards

Booth's Algorithm Benefit

Booth algorithm works equally well for both negative and positive multipliers.

Signup and view all the flashcards

Booth's Features

Booth algorithm deals with signed multiplicand of given number and Speed up the multiplication process.

Signup and view all the flashcards

Booth Recoding

-1 times the shifted multiplicand is selected when moving from 0 to 1, and +1 times the shifted multiplicand is selected when moving from 1 to 0.

Signup and view all the flashcards

Booth Algorithm Efficiency

Efficiency in the number of additions required when the multiplier had a few large blocks of 1s. The speed gained by skipping over 1s depends on the data.

Signup and view all the flashcards

Restoring Division

A division algorithm where the remainder is restored if a subtraction results in a negative value.

Signup and view all the flashcards

Restoring Division Result

Register A is set to 0. After the division is complete, the n-bit quotient is in register Q and the remainder is in register A.

Signup and view all the flashcards

Restoring Division

Positions the divisor appropriately with respect to the dividend and performs a subtraction.

Signup and view all the flashcards

Pipelining

Decomposing a sequential process into sub operations, with each sub process being executed in a special dedicated segment that operates concurrently with all other segments.

Signup and view all the flashcards

Pipeline steps

Read the instruction from the memory, Decode the instruction and fetch the source operands, Perform the operation specified by the instruction, Store the result in the destination location.

Signup and view all the flashcards

Arithmetic Pipelining

The arithmetic logic units of a computer can be segmented for pipeline operations in various data formats.

Signup and view all the flashcards

Instruction Pipelining

The execution of stream of instructions can be pipelined by overlapping the execution of current instruction with the fetch, decode and execution of subsequent instructions.

Signup and view all the flashcards

Processor Pipelining

Pipeline processing of the same data stream by a cascade of processors, each of which processes a specific task.

Signup and view all the flashcards

Floating-Point Adder Pipelines

The inputs to the floating point adder pipeline are two normalized floating point binary numbers

Signup and view all the flashcards

Pipeline substeps in floating point addition

Compares the exponents, Align the mantissa, Add or subtract the mantissas, Normalize the result.

Signup and view all the flashcards

Overflow

When the result of an Arithmetic operation is finite but larger in magnitude than the largest floating point which can be stored by the precision.

Signup and view all the flashcards

Underflow

When the result of an Arithmetic operation is smaller in magnitude than the smallest floating point which can be stored

Signup and view all the flashcards

Study Notes

  • Module 3 covers arithmetic algorithms for multiplication and division, pipelining principles, classification of pipeline processors, instruction and arithmetic pipelines, hazard detection, and resolution.

Multiplication of Unsigned Numbers

  • The product of two n-bit numbers is at most 2n bits.
  • Unsigned multiplication involves adding shifted versions of the multiplicand.
  • Partial products are generated for each digit in the multiplier and then summed.
  • If the multiplier bit is 0, the partial product is 0; otherwise, the partial product is the multiplicand.
  • Successive partial products are shifted one position to the left relative to the preceding one.

Array Multiplier

  • Binary multiplication can be implemented using a combinational two-dimensional logic array called an array multiplier.
  • The main component in each cell is a full adder (FA).
  • An AND gate in each cell determines whether a multiplicand bit is added to the incoming partial product depending on the multiplier bit's value.
  • Each row adds the appropriately shifted multiplicand to the incoming partial product to generate the outgoing partial product if the multiplier bit equals 1.
  • If the multiplier bit is 0, the partial product is passed vertically downward unchanged.
  • The multiplication shifts left one position per row via the diagonal signal path.

Array Multiplier Disadvantages

  • An n-bit by n-bit array multiplier requires n² AND gates and n(n-2) full adders, along with n half adders.
  • The longest input-to-output path goes through n adders in the top row, n-1 adders in the bottom row, and n-3 adders in the middle row; this is called the critical path.

Sequential Circuit Multiplier

  • Multiplication is performed as a series of n conditional addition and shifts.
  • If the multiplier bit is 0, only a shift occurs.
  • If the multiplier bit is 1, the partial products are added and a shift occurs.
  • Sequential circuits use a single n-bit adder, unlike combinational array multipliers which require a large number of logic gates.
  • Registers A and Q (concatenated) hold the partial product, while the multiplier bit generates the Add/Noadd signal.
  • The multiplexer (MUX) selects 0 when the multiplier bit is 0 or the multiplicand when the bit equals 1, which is then added to the partial product.
  • The product is computed in n cycles with the partial product growing one bit per cycle.
  • The carry-out from the adder is stored in a flip-flop C.

Multiplication Algorithm

  • The multiplier and multiplicand are loaded into registers Q and M, respectively; registers A and C are cleared to 0.
  • Each cycle performs two steps:
    • If the LSB of the multiplier (qᵢ) equals 1, the control sequencer generates an Add signal to add the multiplicand (M) to register A, storing the result in A.
    • If qᵢ = 0, a Noadd signal is generated to maintain the previous value in register A.
  • Registers C, A, and Q are right-shifted by 1 bit.

Multiplication of Signed Numbers

  • Multiplication of 2’s-complement operands generates a double-length product.
  • A negative multiplicand added to a partial product requires sign-bit extension to the product's full length.
  • A straightforward approach for a negative multiplier is to take the 2's complement of both the multiplier and the multiplicand.
  • Complementing both operands does not change the product's value or sign.
  • A positive sign bit of 0 denotes a positive number, whereas a negative sign bit of 1 denotes a negative number.

Booth Algorithm

  • Used for signed number multiplication
  • The multiplicand is placed in the BR register, and the multiplier is placed in the QR register.
  • The accumulator register AC and Qₙ₊₁ are initialized to 0.
  • The sequence counter SC is initialized to n (number of bits).
  • The values of Qₙ and Qₙ₊₁ are compared, and the following operations are performed:
    • 01 -> AC = AC + BR
    • 10 -> AC = AC + BR’ + 1
    • 00 -> No arithmetic operation
    • 11 -> No arithmetic operation
  • An Arithmetic Shift Right (ASHR) operation is performed on AC and QR.
  • The sequence counter SC is decremented by 1.
  • The final product is stored in AC and QR.

Features of the Booth Algorithm

  • The Booth algorithm works well for both negative and positive multipliers.
  • It handles signed multiplication and speeds up the multiplication process.

Booth Recording of a Multiplier

  • In the Booth algorithm, multiplying by -1 involves a shift of the multiplicand and is selected when moving from 0 to 1.
  • Multiplying by +1 involves a shift of the multiplicand and is selected when moving from 1 to 0, as the multiplier is scanned from right to left.
  • The least significant bit (LSB) of the multiplier is handled by assuming that an implied 0 lies to its right.
  • Having a worst-case multiplier means that numbers of addition and subtraction operations are large.
  • In an ordinary multiplier, 0 indicates no operation, but addition and subtraction operations still occur.
  • A good multiplier consists of a block/sequence of 1s.
  • The best case involves a long string of 1s (skipping over 1s).
  • The worst case involves alternating 0s and 1s.
  • The transformation 011....110 to 100....0-10 is called skipping over 1s.

Integer Division

  • Binary division is similar to calculation, with the quotient bits being 0 and 1.
  • A circuit implements division, positioning the divisor appropriately and performing subtraction.
  • If the remainder is zero or positive, the quotient bit is 1, and the remainder is extended with another bit of the dividend.
  • The divisor is repositioned, and another subtraction is performed.
  • If the remainder is negative, the quotient bit is 0, the dividend is restored by adding back the divisor, and the divisor is repositioned for another subtraction; this is the restoring division algorithm.
  • An n-bit positive divisor and dividend are loaded into registers M and Q, respectively, with register A initially set to 0.
  • After division, the n-bit quotient is in register Q and the remainder in register A.

Restoring Division Algorithm

  • An n-bit positive divisor is loaded into register M, and an n-bit positive dividend is loaded into register Q; register A is set to 0.
  • After division, the n-bit quotient is in register Q, and the remainder is in register A.
  • The following steps are performed n times:
    • Shift A and Q left one bit position.
    • Subtract M from A (A-M) and place the answer back in A.
    • If the sign of A is 1, set q₀ to 0 and add M back to A (restore A); otherwise, set q₀ to 1.

Pipelining

  • Pipelining decomposes a sequential process into sub-operations, each executed in a dedicated segment concurrently with others.
  • A pipeline is visualized as a collection of processing segments for binary information flow.
  • Each segment performs partial processing based on task partitioning, transferring results to the next segment.
  • The final result is obtained after data passes through all segments.
  • A pipeline processor can execute each instruction in 4 steps:
    • Fetch: Read the instruction from the memory.
    • Decode: Decode the instruction and fetch the source operands.
    • Execute: Perform the operation specified by the instruction.
    • Write: Store the result in the destination location.
  • Four distinct hardware units are needed to allow four instructions to progress at any given time.
  • Units must perform tasks simultaneously without interference, passing information via storage buffers.
  • As an instruction progresses through the pipeline, needed information is passed by stages downstream.

Pipeline Organization

  • Each segment consists of an input register followed by a combinational circuit.
  • The register stores data, and the combinational circuit performs the sub-operation.
  • The combinational circuit's output is applied to the next segment's input register.
  • A clock is applied to registers after enough time has passed for all segment activity.
  • Data flows through the pipeline one step at a time.
  • Registers receive new data with every clock pulse.

Four Segment Pipeline

  • Operands pass through all four segments in a fixed sequence.
  • Each segment contains a combinational circuit that performs a sub-operation on the data stream.
  • Registers separate segments, holding intermediate results between stages.
  • Information flows between adjacent stages under a common clock control applied to all registers simultaneously.

Space-Time Diagram

  • Illustrates pipeline behavior, showing segment utilization over time.
  • The horizontal axis represents time in clock cycles, and the vertical axis represents the segment number.
  • It takes three clock pulses to fill the pipe and retrieve the first output.

Pipeline Performance

  • For a k-segment pipeline executing n tasks with a clock cycle time tp, the first task requires ktp to complete.
  • The remaining n-1 tasks emerge at a rate of one task per clock cycle and are completed after (n-1)tp.
  • Completing n tasks using a k-segment pipeline requires k + (n - 1) clock cycles.

Speedup

  • S = nt n/(k+n-1)*tp, where t n is the time to complete each task with a non-pipelined unit
  • As n increases, the speedup ratio approaches S = t n/t p.
  • Assuming processing time is the same in pipeline and non-pipeline circuits (t n = kt p), the speedup reduces to S = k.

Classification of Pipeline Processors

  • Arithmetic pipelining: Arithmetic logic units are segmented for pipeline operations across various data formats.
  • Instruction pipelining: The execution of a stream of instructions is pipelined by overlapping execution, fetch, and decode; this is known as instruction lookahead.
  • Processor pipelining: A cascade of processors processes the same data stream, each performing a specific task, with data stored and accessible by subsequent processors.

Arithmetic Pipelines

  • Break down arithmetic operations into sub-operations for execution in pipeline segments.
  • They are commonly found in high-speed computers.
  • They are used to implement floating-point operations, multiplication of fixed-point numbers, and similar computations for scientific problems.

Pipeline Unit for Floating-Point Addition and Subtraction

  • Inputs are two normalized floating-point binary numbers: X = A * 2ª and Y = B * 2b
  • Floating-point addition and subtraction are performed in four segments:
    • Compare the exponents.
    • Align the mantissa.
    • Add or subtract the mantissas.
    • Normalize the result.
  • The exponents are compared by subtracting to determine their difference with the larger exponent of the chosen result.
  • The exponent difference determines how many times the mantissa associated with the smaller exponent must be shifted to the right to align the mantissas.
  • The two mantissas are added or subtracted in segment 3, and the result is normalized in segment 4.
  • Overflow: When the result is larger in magnitude than the largest floating-point number that can be stored.
  • Underflow: When the result is smaller in magnitude than the smallest floating-point number that can be stored.

Instruction Pipeline

  • Operates on a stream of instructions by overlapping the instruction cycle's phases (fetch, decode, execute).
  • An instruction pipeline reads consecutive instructions while previous ones are executed, enabling simultaneous operations.
  • A computer is designed with instruction fetch and execute units to provide a two-segment pipeline implemented using a FIFO buffer.
  • While execution is not using memory, consecutive instructions are read via an incremented program counter and placed in the FIFO buffer for execution on a first-in, first-out basis.

Four-Segment Instruction Pipeline

  • Fetch the instruction (FI)
  • Decode the instruction (DA) and calculate the effective address.
  • Fetch the operands from memory (FO).
  • Execute the instruction (EX).
  • The clock is divided into steps of equal duration
  • FI is the segment that fetches the instruction
  • DA is the segment that decodes the instruction and calculates the effective address
  • FO is the segment that fetches the operand
  • EX is the segment that executes the instruction

Pipeline Conflicts

  • Resource Conflicts: Caused by memory access by two segments simultaneously; resolved by using separate instruction and data memories.
  • Data Dependency: Occurs when an instruction relies on a previous instruction's result but the result is unavailable.
  • Branch Difference: Results from branch instructions that change the program counter's value.

Pipeline Hazards

  • Caused by resource usage conflicts among instructions.
  • Triggered by inter-instruction dependencies when successive instructions overlap fetch, decode, and execution.
  • Inter-instruction dependencies prevent sequential data flow in the pipeline.
  • Hazards can lead to the pipeline inter-locking.
  • Three classes of data-dependent hazards exist:
    • Write After Read (WAR) hazards occur.
    • Read After Write (RAW) hazards occur.
    • Write After Write (WAW) hazards occur.
  • Read After Read does not pose a problem.

Resources, Objects, and Hazards

  • Resource object: Refers to working registers, memory locations, and special flags whose contents are called data objects.
  • Instruction: A mapping from a set of data objects to another set.
  • The domain D(I) of instruction I is a set of resource objects whose data objects may affect I's execution.
  • The range R(I) is the set of resource objects whose data objects may be modified by the execution of I.
  • Hazard Types and Resolution
    • RAW hazard: Instruction J attempts to read a data object modified by instruction I.
    • WAR hazard: Instruction J attempts to modify a data object read by instruction I.
    • WAW hazard: Both instructions I and J attempt to modify the same data object.
  • A short-circuiting approach gives the instruction waiting to read a copy of the data object to be written.
  • Data forwarding forwards multiple data copies to waiting instructions.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Use Quizgecko on...
Browser
Browser