UNIHIVE

Study Hub UNIPORT CSC 284

CSC 284 · Introduction to Logic Design

Combinational circuits: adders, subtractors and comparators

Half and full adders, ripple-carry adders, adder-subtractors, and magnitude comparators.

Our notes

2 min read

Combinational circuits

The output depends only on the present inputs: no memory. Design steps: state the problem, list inputs and outputs, write the truth table, minimise, draw the circuit.

Half adder

Adds two bits A and B.

  • Sum S = A ⊕ B.
  • Carry C = AB.

One XOR and one AND gate.

Full adder

Adds A, B and a carry in Cin.

  • S = A ⊕ B ⊕ Cin.
  • Cout = AB + Cin(A ⊕ B) (equal to AB + BCin + ACin).

It can be made from two half adders and an OR gate.

Worked example

A = 1, B = 1, Cin = 1: S = 1 ⊕ 1 ⊕ 1 = 1; Cout = 1. So 1 + 1 + 1 = 11₂ = 3. Correct.

Ripple-carry adder

Chain n full adders; each carry out feeds the next carry in. Simple, but slow: the last sum waits for the carry to ripple through every stage. With 16 stages at 10 ns per carry, the worst case is about 160 ns.

Carry look-ahead

Each stage computes generate G = AB and propagate P = A ⊕ B; all carries are worked out at once from these, so adding is much faster. Used inside processors.

Adder-subtractor

To compute A − B, invert each bit of B (XOR gates with a control line M = 1) and set the first carry in to 1: that adds the two's complement of B. With M = 0 the same circuit adds. Overflow (signed) = carry into the top bit XOR carry out of it.

Worked example

4-bit A = 0110 (6), B = 0011 (3), M = 1: B inverted = 1100, add 1 via carry in: 0110 + 1100 + 1 = 1 0011. Ignore the final carry: 0011 = 3. Correct.

Magnitude comparator

Compares A and B and gives A > B, A = B or A < B.

  • 1-bit: equal = (A ⊕ B)' (XNOR); A > B = AB'; A < B = A'B.
  • n-bit: A = B when every bit pair is equal; A > B is decided by the first (most significant) bit pair that differs. The 74LS85 is a 4-bit comparator that can be cascaded.

The ALU

An arithmetic logic unit combines an adder, logic operations (AND, OR, XOR) and a multiplexer that picks the result by an operation code. It is the heart of the processor's data path.

Exams usually ask

  • Derive half and full adder equations from truth tables and draw them.
  • Explain ripple-carry delay and how an adder-subtractor works.

Common mistake

Writing the full-adder carry as A ⊕ B ⊕ Cin: that is the sum, not the carry.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

Read

Watch

Practise

We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.

All CSC 284 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.