Problem Set - Binary Signed Multiplication
Tags: #◇Computer Science #◇CSARCH2 #◇Computer Architecture #◇Binary Arithmetic #◇Multiplication #◇Booth's Algorithm #◇Sequential Circuits #◇ALU
◇Overview
Binary integer multiplication in modern ◇Computer Architecture is a fundamental arithmetic operation executed by the Arithmetic Logic Unit (◇ALU). While unsigned multiplication is conceptually identical to standard elementary base-2 multiplication, signed integers represented in 2's complement require specialized hardware algorithms to correctly maintain sign bits and manage partial product accumulations without full sign-extension overhead.
┌──────────────────────────────────────────────────────────┐
│ Signed Binary Multiplication │
└────────────────────────────┬─────────────────────────────┘
│
┌──────────────────────────────┴──────────────────────────────┐
▼ ▼
┌─────────────────────────┐ ┌─────────────────────────┐
│ Software / Manual │ │ Hardware Sequential │
│ Pencil & Paper │ │ Multipliers │
└────────────┬────────────┘ └────────────┬────────────┘
│ │
┌────────────┴────────────┐ ┌────────────┴────────────┐
▼ ▼ ▼ ▼
┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐ ┌─────────────────────┐
│ Radix-2 Booth Recode│ │ Radix-4 Bit-Pair │ │ Hardware Radix-2 │ │ Array / Tree │
│ (Strings of 1s) │ │ (Extended Booth) │ │ Booth Multiplier │ │ Multipliers │
│ Summands: n │ │ Summands: ⌈n/2⌉ │ │ (A, Q, Q_-1, M) │ │ (Wallace/Dadda) │
└─────────────────────┘ └─────────────────────┘ └─────────────────────┘ └─────────────────────┘
This problem set explores four distinct techniques for evaluating signed binary multiplication:
- Pencil-and-Paper Method (Signed 2's Complement): Manual calculation using signed extension and correction subtraction for negative multipliers.
- Booth's Algorithm (Radix-2 Recoding): Recoding the multiplier into digits by exploiting runs of consecutive binary s.
- Extended Booth's Algorithm (Radix-4 Bit-Pair Recoding): Grouping multiplier bits into overlapping 3-bit windows to halve the number of summands.
- Sequential Circuit Binary Multiplier (Hardware Multiplier): The cycle-by-cycle register-transfer level (RTL) implementation utilizing registers , , flip-flop , and multiplicand register .
◇Theoretical Principles & Algorithm Mechanics
1. Determining Operand Bit-Widths in 2's Complement
To represent any signed decimal integer in 2's complement with the fewest number of bits ( bits):
- The dynamic range for a -bit 2's complement integer is:
- For a positive integer (), the Most Significant Bit (MSB, sign bit) must be
0. Thus, must satisfy:
- For a negative integer (), the sign bit must be
1. Thus, must satisfy:
Operand Bit Determination for :
- Multiplicand ():
- In unsigned binary: (5 bits).
- In 5-bit 2's complement,
11011represents . - Therefore, an additional sign bit
0is required:
- Multiplier ():
- In unsigned binary: (3 bits).
- In 3-bit 2's complement,
111represents . - With a leading sign bit
0, the fewest bits for is bits (). - In synchronous hardware datapath designs where registers , , and share uniform word widths (), is sign-extended to 6 bits:
2. Method 1: Pencil-and-Paper Method
The pencil-and-paper algorithm for signed 2's complement multiplication proceeds as follows:
- Represent the multiplicand (, bits) and multiplier (, bits) in 2's complement format.
- The final product has a length of bits. The first intermediate product is sign-extended to bits.
- Succeeding intermediate products are generated for each multiplier bit , shifted left by positions (or aligned successively to the right), and sign-extended to match the product width.
- Correction Step for Negative Multiplier: If the multiplier is negative (), the final partial product corresponding to the sign bit represents . Hence, subtract the multiplicand (i.e., add the 2's complement of , ), sign-extended and shifted to the sign-bit position. If the multiplier is positive (), this correction step is omitted.
3. Method 2: Booth's Algorithm (Radix-2 Recoding)
Booth's multiplication algorithm treats positive and negative multipliers uniformly. Instead of performing an addition for every bit, it replaces a cluster of consecutive s with a single subtraction at the start of the cluster and a single addition after the end of the cluster:
Recoding Rules:
- Append an implicit bit to the right of the Least Significant Bit ().
- For each bit position , examine the pair :
- (No operation)
- (End of a string of 1s: Add )
- (Beginning of a string of 1s: Subtract , i.e., Add )
- (Continuation of a string of 1s: No operation)
- The recoded multiplier digits satisfy:
- Perform manual multiplication using , shifting each partial product by bit positions, and accumulating the results.
4. Method 3: Extended Booth's Algorithm (Radix-4 Bit-Pair Recoding)
Extended Booth's algorithm (also called Bit-Pair Recoding or Radix-4 Booth Multiplier) inspects triplets of overlapping bits with . This reduces the total number of partial products from to , doubling hardware multiplication speed.
Bit Triplets: (Q_5 Q_4 Q_3) (Q_3 Q_2 Q_1) (Q_1 Q_0 Q_-1)
└─────┬─────┘ └─────┬─────┘ └─────┬─────┘
Radix-4 Digit: Digit 2 Digit 1 Digit 0
Shift Weight: 4^2 4^1 4^0
Bit-Pair Recoding Table:
| (MSB) | (LSB) | Recoded Value () | Operation on Multiplicand | |
|---|---|---|---|---|
0 | 0 | 0 | ||
0 | 0 | 1 | ||
0 | 1 | 0 | ||
0 | 1 | 1 | (Shift left 1 bit) | |
1 | 0 | 0 | (Shift left 1 bit) | |
1 | 0 | 1 | (2's complement of ) | |
1 | 1 | 0 | (2's complement of ) | |
1 | 1 | 1 |
Algebraic Derivation:
Each partial product is shifted left by bit positions (multiplied by ).
5. Method 4: Sequential Circuit Binary Multiplier (Hardware Architecture)
The hardware sequential multiplier executes radix-2 Booth's algorithm through discrete synchronous clock cycles (passes).
┌────────────────────────┐
│ Multiplicand Reg (M) │
└───────────┬────────────┘
│
▼
┌───────────────────────────┬───────────────────────────┐
│ Accumulator (A) │ Multiplier (Q) │ ──► [ Q_-1 ]
│ (n bits) │ (n bits) │ (1 bit)
└───────────────────────────┴───────────────────────────┘
│ │
└─────────────┬─────────────┘
│
▼
[ Control Logic & Shifter ]
(Inspects Q_0 and Q_-1,
Controls Adder/Subtractor,
Performs Arithmetic Shift Right)
Datapath Registers:
- (Multiplicand Register): Holds the -bit 2's complement multiplicand.
- : Computed as the 2's complement of ().
- (Accumulator): Initialized to all zeros (, bits).
- (Multiplier Register): Initialized to the -bit multiplier.
- (Flip-Flop): Initialized to
0. - Pass Counter: Initialized to (decremented on each cycle).
Operational Loop per Clock Cycle (Pass):
- Condition Inspection: Examine :
- If
- If
- If No arithmetic operation ( unchanged).
- Arithmetic Shift Right (ASR): Simultaneously shift the combined register to the right by 1 bit:
- The sign bit of () is replicated (arithmetic shift).
- shifts into .
- shifts into .
- The previous is discarded.
- Repeat for passes. The final -bit product resides in the concatenated register pair .
◇Detailed Problem Solutions:
Problem Setup & Operand Encodings
We evaluate the product of and :
| Operand | Decimal | Fewest Bits (Signed 2's Complement) | 6-bit Hardware Register Format |
|---|---|---|---|
| Multiplicand () | 011011 (6 bits) | ||
| Multiplier () | 0111 (4 bits) |
- Two's Complement of Multiplicand ():
- Expected Product in Binary:
Try #1: using Pencil-and-Paper Method
Operand Setup:
- Multiplicand ( bits)
- Multiplier ( bits)
- Product bit-length: bits.
Step-by-Step Multiplication Layout:
0 1 1 0 1 1 (Multiplicand M = +27)
x 0 0 0 1 1 1 (Multiplier Q = +7)
------------------
000000011011 (Bit 0 = 1: 1 * M, sign-extended to 12 bits)
00000011011 (Bit 1 = 1: 1 * M, shifted left 1)
0000011011 (Bit 2 = 1: 1 * M, shifted left 2)
000000000 (Bit 3 = 0: 0 * M, shifted left 3)
00000000 (Bit 4 = 0: 0 * M, shifted left 4)
0000000 (Bit 5 = 0: 0 * M, shifted left 5)
------------------
000010111101 (Sum of partial products = +189_10)
Step-by-Step Accumulation:
- Partial Product 0 ():
0000 0001 1011() - Partial Product 1 ():
0000 0011 0110()
- Partial Product 2 ():
0000 0110 1100()
- Correction Step (Step 4): Since (positive multiplier), no subtraction is required.
Try #2: using Booth's Algorithm
Step 1: Multiplier Recoding
Multiplier . Append :
Pair adjacent bits from LSB to MSB:
- :
- :
- :
- :
- :
- :
Value Verification:
Step 2: Multiplication using Booth's Equivalent
- Multiplicand ()
- Negated Multiplicand ()
0 1 1 0 1 1 (Multiplicand M = +27)
x 0 0 +1 0 0 -1 (Booth's Recoded Multiplier)
------------------
111111100101 (Digit 0 = -1: -M, sign-extended to 12 bits)
00000000000 (Digit 1 = 0: 0)
0000000000 (Digit 2 = 0: 0)
000011011000 (Digit 3 = +1: +M, shifted left by 3 bits)
000000000 (Digit 4 = 0: 0)
00000000 (Digit 5 = 0: 0)
------------------
000010111101 (Sum = +189_10)
Step-by-Step Addition:
(Discarding the 13th carry-out bit , standard in 2's complement modular addition).
Try #3: using Extended Booth's Algorithm (Bit-Pair Recoding)
Step 1: Triplet Grouping & Bit-Pair Recoding
Multiplier ( bits, even length). Append :
Recode each triplet using :
- Triplet 0 ():
- Triplet 1 ():
- Triplet 2 ():
Value Verification:
Step 2: Partial Product Multiples
- ()
- ()
- ()
Step 3: Multiplication Layout (Radix-4 Shifts by 2 Bits)
0 1 1 0 1 1 (Multiplicand M = +27)
x 0 +2 -1 (Extended Booth Recoded Multiplier)
------------------
111111100101 (Pair 0 = -1: -M, sign-extended to 12 bits)
000011011000 (Pair 1 = +2: +2M, shifted left by 2 bits)
000000000000 (Pair 2 = 0: 0, shifted left by 4 bits)
------------------
000010111101 (Sum = +189_10)
Try #4: using Sequential Circuit Binary Multiplier
Register Initialization:
- Multiplicand Register:
- 2's Complement Multiplicand:
- Accumulator:
- Multiplier Register:
- LSB History Flip-Flop:
- Total Passes:
Comprehensive Cycle-by-Cycle Execution Trace:
========================================================================================
INITIAL STATE:
M = 011011 -M = 100101
A = 000000 Q = 000111 Q_-1 = 0
========================================================================================
PASS 1:
Inspect: Q_0 Q_-1 = '10' --> Operation: A <-- A - M (A <-- A + (-M))
A: 000000
+ (-M): 100101
-----------------
A: 100101
Arithmetic Shift Right (ASR) on [A, Q, Q_-1]:
A: 100101 --> ASR --> 110010 (sign bit '1' preserved, LSB '1' -> Q_5)
Q: 000111 --> ASR --> 100011 (receives '1', LSB '1' -> Q_-1)
Q_-1: receives old Q_0 = 1
>>> End of 1st Pass: A = 110010, Q = 100011, Q_-1 = 1
PASS 2:
Inspect: Q_0 Q_-1 = '11' --> Operation: No arithmetic operation (A unchanged)
A: 110010
Arithmetic Shift Right (ASR) on [A, Q, Q_-1]:
A: 110010 --> ASR --> 111001 (sign bit '1' preserved, LSB '0' -> Q_5)
Q: 100011 --> ASR --> 010001 (receives '0', LSB '1' -> Q_-1)
Q_-1: receives old Q_0 = 1
>>> End of 2nd Pass: A = 111001, Q = 010001, Q_-1 = 1
PASS 3:
Inspect: Q_0 Q_-1 = '11' --> Operation: No arithmetic operation (A unchanged)
A: 111001
Arithmetic Shift Right (ASR) on [A, Q, Q_-1]:
A: 111001 --> ASR --> 111100 (sign bit '1' preserved, LSB '1' -> Q_5)
Q: 010001 --> ASR --> 101000 (receives '1', LSB '1' -> Q_-1)
Q_-1: receives old Q_0 = 1
>>> End of 3rd Pass: A = 111100, Q = 101000, Q_-1 = 1
PASS 4:
Inspect: Q_0 Q_-1 = '01' --> Operation: A <-- A + M
A: 111100 (-4 in decimal)
+ M: 011011 (+27 in decimal)
-----------------
A: 1010111 --> 6-bit truncated A = 010111 (+23 in decimal)
Arithmetic Shift Right (ASR) on [A, Q, Q_-1]:
A: 010111 --> ASR --> 001011 (sign bit '0' preserved, LSB '1' -> Q_5)
Q: 101000 --> ASR --> 110100 (receives '1', LSB '0' -> Q_-1)
Q_-1: receives old Q_0 = 0
>>> End of 4th Pass: A = 001011, Q = 110100, Q_-1 = 0
PASS 5:
Inspect: Q_0 Q_-1 = '00' --> Operation: No arithmetic operation (A unchanged)
A: 001011
Arithmetic Shift Right (ASR) on [A, Q, Q_-1]:
A: 001011 --> ASR --> 000101 (sign bit '0' preserved, LSB '1' -> Q_5)
Q: 110100 --> ASR --> 111010 (receives '1', LSB '0' -> Q_-1)
Q_-1: receives old Q_0 = 0
>>> End of 5th Pass: A = 000101, Q = 111010, Q_-1 = 0
PASS 6:
Inspect: Q_0 Q_-1 = '00' --> Operation: No arithmetic operation (A unchanged)
A: 000101
Arithmetic Shift Right (ASR) on [A, Q, Q_-1]:
A: 000101 --> ASR --> 000010 (sign bit '0' preserved, LSB '1' -> Q_5)
Q: 111010 --> ASR --> 111101 (receives '1', LSB '0' -> Q_-1)
Q_-1: receives old Q_0 = 0
>>> End of 6th Pass: A = 000010, Q = 111101, Q_-1 = 0
========================================================================================
Official Summary Solution Table (Try #4)
| After this pass | Register A | Register Q | Bit | Description / ALU Action |
|---|---|---|---|---|
| Initial | 000000 | 000111 | 0 | Initialize registers |
110010 | 100011 | 1 | ; ASR | |
111001 | 010001 | 1 | No op; ASR | |
111100 | 101000 | 1 | No op; ASR | |
001011 | 110100 | 0 | ; ASR | |
000101 | 111010 | 0 | No op; ASR | |
000010 | 111101 | 0 | No op; ASR |
Final Product Reconstruction:
◇Comparison Matrix of Multiplication Techniques
| Metric / Feature | Pencil-and-Paper | Radix-2 Booth's Algorithm | Radix-4 Extended Booth | Hardware Sequential Multiplier |
|---|---|---|---|---|
| Operand Handling | Requires sign-bit correction step if | Uniform for signed/unsigned operands | Uniform for signed/unsigned operands | Uniform via control |
| Summands Count | partial products | At most partial products | partial products | clock passes |
| Best Case Speed | (all zero rows) | Isolated strings of 1s (e.g. 011110 ops) | Uniform halving of passes | Skips adder if |
| Worst Case | ( adds) | Alternating bits 010101 ( adds/subs) | Non-zero digits across all pairs | Alternating bits 010101 |
| Hardware Complexity | High software overhead | Low (Standard ALU adder/subtractor) | Moderate (Multiplexer for ) | Minimal datapath footprint |
◇Key Takeaways
- 2's Complement Sign Preservation: When converting positive numbers to signed 2's complement, always append a leading
0sign bit to prevent misinterpretation as a negative value (e.g., , not ). - Booth's Optimization Principle: Booth's algorithm converts consecutive strings of s into a single subtraction at the LSB boundary and a single addition at the MSB boundary, drastically minimizing ALU addition cycles in clustered binary numbers.
- Radix-4 Multipliers in High-Performance CPUs: By processing 2 bits per cycle through bit-pair recoding, Extended Booth reduces partial product generation time by , forming the core building block of modern hardware multipliers.
- Shift Invariant: The hardware sequential multiplier utilizes an Arithmetic Shift Right (ASR) to preserve the sign of negative intermediate sums in accumulator while routing vacated bits seamlessly into multiplier register .