Skip to content

Exclusive-OR (XOR) Gate

  • Output active-HIGH (=1) when exactly one input is HIGH.
  • Only 2-input XOR gates exist; no 3- or 4-input versions.
  • IEEE/ANSI symbol:

  • Common ICs:
    • 74LS86 (TTL)
    • 74C86 (CMOS)
    • 74HC86 (High-speed CMOS)

Exclusive-NOR (XNOR) Gate

  • Output HIGH when inputs are equal (complement of XOR).
  • Often implemented by connecting XOR output to an inverter.
  • Common ICs:
    • 74LS266 (TTL)
    • 74C266 (CMOS)
    • 74HC266 (High-speed CMOS)

Parity Generator and Checker

  • Purpose: Detect single-bit errors in transmission by adding a parity bit.
  • Even parity: total 1s (including parity bit) = even.
  • Odd parity: total 1s (including parity bit) = odd.

Example 1: Even parity generator (4-bit data D0D1D2D3)

P=D0D1D2D3

Example 2: Odd parity generator (3-bit data D0D1D2)

P=D0D1D2

Combinational Circuits

  • Output depends only on current inputs, no memory or feedback.
  • Components: interconnection of logic gates transforming input data -> output data.

Image of Combinational Circuit

  • Applications: Often connected to registers; if registers included -> sequential circuit.
  • Standard combinational circuits:
    • Adders
    • Subtractors
    • Comparators
    • Decoders
    • Encoders
    • Multiplexers

Half-Adder (HA)

Purpose: Adds two single-bit inputs to produce sum and carry.

Inputs and Outputs

  • Inputs: A, B
  • Outputs:
    • Sum (S) = AB
    • Carry (C) = AB

Truth Table

ABSum (S)Carry (C)
0000
0110
1010
1101

Logic Formulas

S=ABC=AB

Explanation:

  • Sum is HIGH when inputs are different.
  • Carry is HIGH when both inputs are 1.
  • Can only handle two inputs, so it cannot propagate carry from a previous addition.

Full-Adder (FA)

Purpose: Adds three single-bit inputs (including carry-in) to produce sum and carry-out.

Inputs and Outputs

  • Inputs: A, B, Cin
  • Outputs:
    • Sum (S) = ABCin
    • Carry (Cout) = (AB)+(BCin)+(ACin)

Truth Table

ABCinSum (S)Cout
00000
00110
01010
01101
10010
10101
11001
11111

Logic Formulas

S=ABCinCout=(AB)+(BCin)+(ACin)

Explanation:

  • Sum is HIGH when an odd number of inputs are 1.
  • Carry-out is HIGH when at least two inputs are 1.
  • Can handle carry from previous stage, so suitable for multi-bit addition.

Half-Subtractor (HS)

Purpose: Subtracts two single-bit inputs to produce difference and borrow.

Inputs and Outputs

  • Inputs: A, B
  • Outputs:
    • Difference (D) = AB
    • Borrow (Bout) = A¯B

Truth Table

ABDifference (D)Borrow (Bout)
0000
0111
1010
1100

Logic Formulas

D=ABBout=A¯B

Explanation:

  • Difference is HIGH when inputs are different.
  • Borrow is HIGH when B=1 and A=0.
  • Cannot handle a borrow from a previous stage.

Full-Subtractor (FS)

Purpose: Subtracts three single-bit inputs (including borrow-in) to produce difference and borrow-out.

Inputs and Outputs

  • Inputs: A, B, Bin
  • Outputs:
    • Difference (D) = ABBin
    • Borrow (Bout) = (A¯B)+(A¯Bin)+(BBin)

Truth Table

ABBinDifference (D)Bout
00000
00111
01011
01101
10010
10100
11000
11111

Logic Formulas

D=ABBinBout=(A¯B)+(A¯Bin)+(BBin)

Explanation:

  • Difference is HIGH when an odd number of inputs are 1.
  • Borrow-out is HIGH when subtraction requires borrowing.
  • Can handle borrow from previous stage, making it suitable for multi-bit subtraction.

3-bit Adder

  • Description: This is a 3-bit ripple carry adder composed of three Full Adder stages where the initial carry input is tied to 0 to perform binary addition.
  • Logic Expression:
    • S: Sum
    • C: Carry
    • Si=aibiCi
    • Ci+1=(aibi)+(Ci(aibi))
    • Initial condition: C0=0

Figure of a 3-bit adder with 3 inputs and one control bit (zero for now)

3-bit Subtractor

  • Description: This circuit performs 3-bit binary subtraction (AB) by feeding ai, the complement bi, and an initial borrow/carry of 1 into Full Adder stages to implement 2's complement logic.
  • Logic Expression:
    • D: Difference
    • B: Borrow
    • Di=aibiBi
    • Bi+1=(aibi)+(Bi(aibi))
    • Initial condition: B0=1

Figure of a 3-bit subtractor with 3 inputs and one control bit (1 for now)

3-bit Adder-Subtractor

  • Description: This multi-function circuit uses a Control Bit (M) and XOR gates to conditionally invert the b inputs and set the initial carry, allowing it to act as either an adder (M=0) or a subtractor (M=1).
  • Logic Expression:
    • M: Control Bit
    • C: Carry
    • Resulti=ai(biM)Ci
    • Ci+1=(ai(biM))+(Ci(ai(biM)))
    • Initial condition: C0=M

2's Complement Logic Circuit

Purpose: Represents negative numbers in binary and enables subtraction using addition.

Inputs and Outputs

  • Inputs:
    • Binary number: A
    • Control bit: SUB
  • Outputs:
    • 2's complement result: A2C

Logic Description

2's complement is generated in two steps:

  1. One's complement: invert all bits
  2. Add 1 to the inverted result

Logic Formulas (per bit)

AAA2C=A+1

1-Bit Truth Table (with Carry-In)

ACinASumCout
00110
01101
10000
11010

Explanation

  • Bitwise NOT converts A to one's complement
  • Adding 1 completes the 2's complement
  • Enables subtraction using:AB=A+(2s complement of B)
  • Used internally in ALUs and CPUs

Arithmetic and Logic Unit (ALU)

Purpose: Performs arithmetic and logical operations on binary data.

Inputs and Outputs

  • Inputs:
    • Operands: A, B
    • Control signals: S1, S0
  • Outputs:
    • Result: F
    • Status flags (optional): Zero, Carry, Overflow

Example Operation Selection Table

S1S0OperationDescription
00A+BAddition
01ABSubtraction (2's comp)
10ABAND
11ABXOR

Internal Logic

  • Arithmetic block
    • Full adders
    • 2's complement logic for subtraction
  • Logic block
    • AND, OR, XOR, NOT gates
  • Multiplexer
    • Selects output based on control signals

Explanation

  • ALU is the core computation unit of the CPU
  • Uses control signals to choose the operation
  • Combines adders, logic gates, and multiplexers
  • Scales to multi-bit designs (e.g., 32-bit, 64-bit)

Decoder

  • Function: A decoder activates exactly one of its 2n output lines based on the binary combination of its n input lines.
  • Complexity: An n-to-2n decoder requires 2n AND gates, each with n inputs.

functional block diagrams of an n-to-2n line decoder, specifically illustrating a 3-to-8 line decoder and the general n-input model

functional block diagram and the internal logic gate implementation of a 3-to-8 line decoder and a general n-to-2n decoder

Logic Implementation of a 3-to-8 Decoder

For a 3-to-8 decoder with inputs x,y,z, the outputs D0 through D7 correspond to the minterms of the inputs:

  • D0=xyz (Binary 000)
  • D1=xyz (Binary 001)
  • D2=xyz (Binary 010)
  • D3=xyz (Binary 011)
  • D4=xyz (Binary 100)
  • D5=xyz (Binary 101)
  • D6=xyz (Binary 110)
  • D7=xyz (Binary 111)

Formulas for Decoder Logic

Since you are working with LaTeX in Markdown, here is how you would formally represent the output logic for a specific line (e.g., D5):

D5=xyz

Or using the "prime" notation seen in your image:

D5=xyz

Design a 2-bit multiplier using decoder

The table below shows the relationship between two 2-bit inputs (a and b) and the 4-bit product (r).

Mathematically, this represents (a1a0)2×(b1b0)2=(r3r2r1r0)2.

a1a0b1b0r3r2r1r0
00000000
00010000
00100000
00110000
01000000
01010001
01100010
01110011
10000000
10010010
10100100
10110110
11000000
11010011
11100110
11111001

Encoder

functional block diagrams of a general 2N-to-N encoder, a specific 4-to-2 encoder, and a corresponding 2-to-4 decoder to illustrate the inverse relationship between encoding and decoding.

Truth Table of an Octal-to-Binary Encoder

The following table represents the logic of an 8x3 encoder, where each of the eight input lines (D0 through D7) corresponds to an octal digit, and the three output lines (x,y,z) provide the equivalent 3-bit binary code.

D0D1D2D3D4D5D6D7xyz
10000000000
01000000001
00100000010
00010000011
00001000100
00000100101
00000010110
00000001111

Logic Equations

Based on the truth table, the Boolean expressions for the outputs are derived by identifying which input lines activate each specific output bit:

  • z=D1+D3+D5+D7
  • y=D2+D3+D6+D7
  • x=D4+D5+D6+D7

Priority Encoder

functional block diagram of a 4-input priority encoder, where input  is designated as the highest priority and  as the lowest priority

Understanding Priority Encoders

In a standard encoder, only one input can be active at a time. A priority encoder solves this limitation by ensuring that if two or more inputs are high simultaneously, the input with the highest priority takes precedence.

For the 4-bit priority encoder shown:

  • If I3 is 1, the output will be 11 regardless of the states of I2,I1, and I0.
  • If I3 is 0 and I2 is 1, the output will be 10 regardless of I1 and I0.

Multiplexer

block diagram of a 2-to-1 multiplexer (MUX) and its internal logic gate implementation using AND, OR, and NOT gates

gate-level logic circuit for a 4-to-1 multiplexer, utilizing four 3-input AND gates and a 4-input OR gate

Truth Table: 2-to-1 Multiplexer

For a 2-to-1 MUX, the select line S determines which input (I0 or I1) is routed to the output Y.

SY
0I0
1I1

Boolean Equation: Y=SI0+SI1

Truth Table: 4-to-1 Multiplexer

For a 4-to-1 MUX, two select lines (S1,S0) are required to choose between the four available inputs.

S1​S0​Y
00I0
01I1
10I2
11I3

Boolean Equation:

Y=S1S0I0+S1S0I1+S1S0I2+S1S0I3