1. -Bit Signed Integer Representations

By convention the MSB is the sign: for positive numbers or zero, for negative numbers.

RepresentationMeaning of the low bits
Signed-magnitudealways the (positive) magnitude
Signed-complement (1’s or 2’s)the magnitude if positive, the complement of the magnitude if negative

Signed-magnitude arithmetic needs an awkward algorithm (compare signs, compare magnitudes, add or subtract, pick a sign) → complement representations are used instead.


2. Signed-Complement Arithmetic

Rules

  • Addition: use an ordinary unsigned adder. The sign bit comes out right automatically, except when overflow occurs (both operands have the same sign and the result’s sign differs).
  • Subtraction: add the complement: .

Signed 1’s Complement (4 bits)

The end carry is added back to the result (end-around carry).

Example 1 –

Example 2 –

Signed 2’s Complement (4 bits)

The end carry is discarded.

Example 1 –

Example 2 –


3. 2’s-Complement Adder/Subtractor

Principle

: invert every bit of (1’s complement), then add 1.

Circuit

A 4-bit ripple-carry adder with an XOR on each input, controlled by the mode bit , which also drives :

A3B3FAS3C3A2B2FAS2C2A1B1FAS1C1A0B0FAS0C4SC0 = S

XOR outputComputes
0 (pass)0
1 (invert)1

The XOR is a controlled inverter — the same circuit adds and subtracts.


4. Overflow Detection

Overflow = the result of an -bit addition/subtraction needs bits.

ArithmeticDetectionExample (3 bits)
Unsignedcarry out of the MSB:
Signed (2’s C)two positives give a negative:
Signed (2’s C)two negatives give a positive:

(3-bit 2’s-complement range: .)

⚠️ The two detection rules are different: a carry out is overflow for unsigned numbers but not for signed ones (e.g. above produces a carry yet the result 0 is correct).


5. Binary Multiplication

Rule

The 1-bit multiplication table is the AND function:

00
01

As in decimal: form partial products (one per multiplier digit), shift (justify) them, and add.

Example – Decimal Review:

Partial products , (shifted 1), (shifted 2); sum .

An -digit × -digit product has up to digits.

Example –

        1 0 1      (5)
      × 0 1 1      (3)
      -------
        1 0 1      ← ×1
      1 0 1        ← ×1
    0 0 0          ← ×0
    ---------
    0 0 1 1 1 1    (15)

Each binary partial product is either all zeros (multiplier bit 0) or a copy of the multiplicand (multiplier bit 1).

2 × 2 Multiplier

  • (half adder; its carry goes left)
  • , = carry of that sum (second half adder)

Four ANDs + two half adders:

A0B0A0B1A1B0A1B1HASCHASCP0P1P2P3

4 × 4 Multiplier

  • bits → -bit product: 4 × 4 → 8 bits ().
  • The 16 partial products are ANDs; the product is formed by summing down each column, propagating carries right to left.
  • Each column sum uses 1-bit adders: an adder that may receive a carry from the right must be a full adder; if no carry can come in, a half adder suffices (a FA with also works as an HA).
flowchart TB
    PP["16 ANDs:<br/>partial products AiBj"] --> R1["Row 1 adders<br/>(add PP row 0 + row 1)"]
    R1 --> R2["Row 2 adders<br/>(+ PP row 2)"]
    R2 --> R3["Row 3 adders<br/>(+ PP row 3)"]
    R3 --> P["Product S7..S0"]

6. Other Arithmetic Functions

Incrementing and Decrementing

  • Incrementing: adding a fixed value (, ). Adding 1 = counting up. Block: incrementer.
  • Decrementing: subtracting a fixed value (, ). Subtracting 1 = counting down. Block: decrementer.

Design by Contraction

Contraction = take an existing block, apply value fixing (rudimentary functions) to some inputs, and remove the logic that became redundant. The new function must be obtainable from the original by fixing inputs; the result is much simpler.

Example – Ripple-Carry Adder → 3-Bit Incrementer

Fix and :

  • Bit 0: → , .
  • Bit 1: → a half adder: , .
  • Bit 2: another half adder: .

A0S0 = A0’HASCA1A0HASCA2S1 = A1 ⊕ A0S2 = A2 ⊕ A1A0C3

The middle cell (a half adder) is repeated for wider incrementers ().

Zero Fill

Extending an -bit operand to bits by filling with 0s, usually at the MSB end (sometimes LSB end). For unsigned data.

Example – 11110101 to 16 bits

  • MSB end: 0000000011110101
  • LSB end: 1111010100000000

Sign Extension

For a complement representation, copy the sign bit (MSB) into the new positions. The value is unchanged in the wider format.

Example – 8 → 16 bits

  • Positive 01110101 → 0000000001110101
  • Negative 11110101 → 1111111111110101 (still )

⚠️ Zero-filling a negative 2’s-complement number changes its value: 11110101 () zero-filled to 16 bits becomes . Use sign extension for signed data.


Exercises: none assigned separately — redo the 1’s/2’s-complement examples (§2), the overflow cases (§4), and (§5).