Digital Logic
Explore digital computer fundamentals, computer architecture, logic gates, Boolean algebra, Karnaugh map simplification, combinational circuits, flip-flops, and sequential circuit design.
Introduction
Have you ever wondered how a computer converts silent pulses of electrical voltage into complex mathematical computations, software applications, and intelligent decisions? At its fundamental physical layer, every digital computer relies on remarkably simple binary building blocks operating in structured mathematical harmony.
In this lesson, we will systematically explore the hierarchy of digital logic—starting from raw bits and logic gates, advancing through Boolean simplification and combinational circuits, and culminating in stateful sequential machines. By the end of this journey, you will be able to:
- Distinguish between computer organization, design, and architecture, including the structural trade-offs between von Neumann and Harvard designs.
- Analyze and manipulate logic gates, Boolean algebraic expressions, and canonical forms.
- Minimize complex Boolean functions using Karnaugh maps (K-maps) and don't-care conditions.
- Construct fundamental combinational circuits, such as half-adders and full-adders.
- Design and evaluate synchronous sequential circuits using flip-flops, state tables, and state diagrams.
Digital Computers
A digital computer is a system designed to perform computational tasks using variables that take a limited number of discrete values. While decimal systems rely on 10 discrete digits ( through ), physical electronic components operate far more reliably when constrained to just two states—high voltage and low voltage. This physical restriction naturally aligns with binary logic (true-or-false, yes-or-no), making the binary number system (base 2, using digits 0 and 1) the foundation of all modern computing. A single binary digit is called a bit.
In a digital computer, groups of bits represent diverse forms of information. For instance, the 7-bit sequence 1001011 can be expanded into a power series to represent the decimal number :
Yet, that exact same sequence of seven bits represents the upper-case letter 'K' when interpreted through a standard alphanumeric code, or it might serve as a specific control instruction for internal processor hardware. Just as the same letters of an alphabet construct different languages, binary bit patterns derive their meaning entirely from context.
Hardware, Software, and System Entities
To process these bit patterns, a complete computer system integrates two main entities:
- Hardware: The physical electronic components and electromechanical devices.
- Software: The instructions and data manipulated by the hardware. A sequence of instructions forms a program, while the data manipulated forms the data base.
System software—specifically the operating system—bridges the gap between physical hardware capabilities and user applications. For example, when a user writes a high-level application program, a system program called a compiler translates that program into machine-level binary code.
The hardware architecture of a computer is traditionally divided into three central functional components:
- Central Processing Unit (CPU): Contains the arithmetic and logic unit (ALU) for manipulating data, registers for temporary storage, and control circuits for fetching and executing instructions.
- Memory (RAM): Stores instructions and data. It is called Random-Access Memory because the CPU can access any location at random in a fixed time interval.
- Input-Output Processor (IOP): Handles communication and data transfers between internal memory and external devices (keyboards, displays, disk drives).
Three Perspectives of Hardware
Computer hardware is studied from three distinct viewpoints depending on the level of abstraction:
- Computer Organization: Focuses on how functional hardware units operate and are interconnected (investigating the internal structure to verify components work as intended).
- Computer Design (Implementation): Focuses on selecting specific hardware components and establishing their physical interconnections to meet set specifications.
- Computer Architecture: Focuses on the structure and behavior of the computer as seen by the software user, including instruction sets, addressing modes, and register formats.
System Architectural Frameworks
Two foundational computer architectures define how instructions and data move through memory:
- von Neumann Architecture: Features a single, shared memory space and signal pathway (bus) for both instructions and data. It operates on the stored-program principle, executing instructions sequentially. Because data and instructions share the same bus, the CPU cannot read an instruction and read/write data simultaneously—a phenomenon known as the von Neumann bottleneck.
- Harvard Architecture: Uses physically separate memory units and signal pathways for instructions and data. This separation allows simultaneous access to instruction and data memory, effectively doubling memory bandwidth. DesktopPersonal Computers rely primarily on von Neumann structures, whereas specialized microcontrollers and Digital Signal Processors (DSPs) favor Harvard architectures.
Logic Gates
Binary information is represented inside a computer by physical electrical signals. For example, a system might define as binary 1 and as binary 0. Logic gates are hardware circuits that manipulate these electrical signals based on logical rules, producing binary outputs when specific input conditions are met.
Each logic gate is characterized by its graphic symbol, algebraic expression, and truth table—a tabular listing of all possible binary input combinations and their corresponding outputs.
The Eight Primary Logic Gates
- AND Gate: Produces output
1if and only if all inputs are1. Symbolized algebraically as or . An AND gate is sensitive to a logic0on any input. - OR Gate: Produces output
1if any input is1(inclusive OR). Symbolized algebraically as . - Inverter (NOT Gate): Accepts a single input and flips its logic state. Symbolized as or . Its symbol features a small bubble at the output designating logical complementation.
- Buffer: A single-input circuit that produces an output identical to its input (). It produces no logic change but provides power amplification to drive downstream gates requiring higher current.
- NAND Gate: The complement of AND (x = (A$$B)'). It produces
0only when all inputs are1. - NOR Gate: The complement of OR (). It produces
1only when all inputs are0. - Exclusive-OR (XOR) Gate: Produces output
1if the inputs are different (). More generally, an -input XOR functions as an odd function, yielding1when an odd number of inputs are1. - Exclusive-NOR (XNOR) Gate: The complement of XOR (). It yields
1if the inputs are identical (both0or both1).
Universal Gates
NAND and NOR gates are known as universal gates because any Boolean function or logic logic gate (AND, OR, NOT) can be constructed entirely out of NAND or NOR gates alone.
Boolean Algebra
To systematically analyze and design digital circuits, engineers use Boolean algebra (specifically two-element switching algebra ). Boolean algebra defines operations on binary variables using three fundamental operators: AND (product, ), OR (sum, ), and NOT (complement, ).
A Boolean function can be transformed between an algebraic equation, a truth table with combinations (for variables), and a logic diagram composed of interconnected logic gates.
Basic Identities of Boolean Algebra
These identity rules allow complex logic expressions to be simplified into minimal forms, reducing the physical gate count:
- Identity Elements: ,
- Null Elements: ,
- Idempotent Laws: ,
- Complement Laws: ,
- Involution Law:
- Commutative Laws: ,
- Associative Laws: ,
- Distributive Laws: ,
Note: The identity is extremely powerful in Boolean simplification, even though it has no equivalent in standard real-number algebra!
DeMorgan's Theorems
DeMorgan's theorems provide the mathematical bridge between AND and OR operations, making them essential for working with universal NAND and NOR logic:
- (A NOR gate is equivalent to an Invert-AND gate)
- (A NAND gate is equivalent to an Invert-OR gate)
Complemented Functions and Canonical Forms
To complement an entire algebraic function , swap all and operators and complement every individual literal variable.
Functions can be expressed in non-canonical or canonical forms (where every term contains every variable in either its primed or unprimed state):
- Canonical Sum-of-Products (SOP): Formed by ORing binary minterms (product terms equal to 1 for specific variable combinations).
- Canonical Product-of-Sums (POS): Formed by ANDing binary maxterms (sum terms equal to 0 for specific variable combinations).
Map Simplification
While Boolean identities can minimize logic expressions, algebraic simplification can be trial-and-error because it lacks a rigid procedural recipe. The Karnaugh Map (K-map) method provides a clear visual layout of a truth table that makes minimizing expressions up to 6 variables straightforward.
K-Map Fundamentals
A K-map consists of adjacent squares for an -variable function, where each square represents a single minterm. Adjacent squares differ by exactly one binary literal. To maintain this geometric adjacency across grid borders, coordinates are ordered using Gray code (00, 01, 11, 10). Consequently, the top and bottom rows are adjacent, as are the leftmost and rightmost columns.
To minimize a function using a K-map:
- Place a
1in every square corresponding to a minterm where the function evaluates to1. - Combine adjacent
1s into rectangular groups of size (). Larger groups eliminate more variables. - Ensure every
1is included in at least one group. Groups may overlap. - Read out the simplified Sum-of-Products (SOP) expression by identifying variables that remain constant across each group.
Product-of-Sums (POS) Minimization
To find a minimized Product-of-Sums expression using a K-map:
- Group the empty squares containing
0s to obtain the simplified complement function, . - Apply DeMorgan's theorem to to yield in POS form (OR terms connected by an AND operation).
Don't-Care Conditions
In many practical logic systems, certain input combinations will never occur in real-world operation. These minterms are called don't-care conditions and are marked with an '' (or '') on the map.
When simplifying, an '' can be treated as a 1 if it helps form a larger group, or as a 0 if it offers no benefit. You are never required to cover '' squares.
Combinational Circuits
Digital logic circuits fall into two broad structural categories:
- Combinational Circuits: Contain no memory elements or feedback paths. The outputs at any instant depend entirely on the binary inputs present at that exact moment.
- Sequential Circuits: Contain memory elements (flip-flops) and feedback loops. Outputs depend on both present inputs and the internal state history.
Design Procedure for Combinational Logic
Designing a combinational circuit follows five structured steps:
- State the practical problem clearly.
- Assign letter symbols to inputs and outputs.
- Construct the truth table defining output values for all input combinations.
- Obtain simplified Boolean expressions for each output using K-maps.
- Draw the resulting gate-level logic diagram.
Building Block Case Studies: Adders
Arithmetic logic is foundational to computation. Let's look at the basic building blocks used for binary addition:
- Half-Adder
A half-adder adds two single binary bits ( and ) and produces two outputs: a Sum () and a Carry ().
- Sum Function: (Exclusive-OR)
- Carry Function: (AND)
- Full-Adder
A full-adder adds three binary bits: two significant operand bits ( and ) plus an incoming carry bit () from a lower-order position.
- Sum Function: (Odd function)
- Carry-Out Function:
Notice that a full-adder circuit can be constructed directly out of two half-adders and a single OR gate.
Flip-Flops
To create system memory and sequential control, digital circuits require storage elements capable of retaining binary state information. In clocked synchronous sequential circuits, state changes occur only at discrete time intervals controlled by a master clock pulse generator.
The basic 1-bit memory element used in synchronous circuits is the flip-flop. A flip-flop has two complementary outputs ( and ) and maintains its binary state until an edge transition on its clock input () triggers an update.
Core Types of Flip-Flops
- SR Flip-Flop (Set-Reset): Has inputs (Set) and (Reset). Setting forces . Setting clears . If , the state remains unchanged. Crucially, is an illegal/indeterminate condition that must be avoided.
- D Flip-Flop (Data): Eliminates invalid states by passing a single data input through an internal inverter to and . Whatever logic value exists on input is transferred directly to output on the clock transition: .
- JK Flip-Flop: Resolves the SR invalid state problem. Inputs and act like Set and Reset, but when and simultaneously, the clock transition complements (toggles) the output state: .
- T Flip-Flop (Toggle): Created by connecting and together into a single input . If , the state is unchanged; if , the state toggles.
Triggering Mechanisms and Excitation Tables
Modern designs use edge-triggered flip-flops that sample inputs and change state during a sharp signal transition—either on the rising edge (positive edge) or falling edge (negative edge) of the clock pulse. Inputs must remain stable for a minimum setup time before the edge and a hold time after it.
While a flip-flop's characteristic table dictates the next state given the inputs and present state , circuit designers use an excitation table to reverse this logic. An excitation table specifies the required input values needed to force a desired state transition ():
Sequential Circuits
A complete sequential circuit consists of an interconnected array of flip-flops alongside a combinational logic network. The combinational logic receives system inputs and current flip-flop states () to generate system outputs and the flip-flop input equations (, etc.) that determine the next state.
Representing Sequential Behavior
Sequential behavior is formally tracked using two equivalent representations:
- State Table: A table listing the Present State, Inputs, Next State, and Outputs.
- State Diagram: A graphical layout where states are represented by labeled circles, and state transitions are indicated by directed arcs labeled with binary
Input / Outputvalues.
Complete Sequential Design Procedure
To build a sequential logic circuit from functional specifications:
- Create a State Diagram capturing all operational states and transitions.
- Derive the corresponding State Table.
- Select the flip-flop type (e.g., JK, D, T).
- Expand the state table into a complete Excitation Table by looking up required flip-flop input values for every transition.
- Map the excitation inputs using K-maps to derive simplified Flip-Flop Input Equations.
- Draw the complete Logic Diagram.
Design Example: 2-Bit Binary Counter
Let's design a 2-bit binary counter using two JK flip-flops ( and ) and an external control input .
- If , the counter cycles through binary states
- If , the counter holds its present state.
By evaluating state transitions in the excitation table, mapping the required and values on K-maps, and simplifying, we get these input equations:
The physical realization requires just two JK flip-flops and a single AND gate to feed and !
Summary
Digital hardware transforms abstract mathematical logic into physical computation through a structured hierarchy of components—starting from two-state physical voltages and logic gates, progressing through Boolean expressions and combinational building blocks, and culminating in stateful, clocked sequential systems.
Key Takeaways
- Binary Representation: Computers process discrete data using binary bits (
0and1), which derive their semantic meaning (numbers, text, control signals) from execution context. - Architectural Models: Von Neumann architectures share a single memory space for data and instructions (leading to sequential execution limits), whereas Harvard architectures utilize separate memories to boost bandwidth.
- Universal Logic: NAND and NOR gates can implement any Boolean function. Logic expressions can be minimized algebraically or visually using Karnaugh maps.
- Combinational vs. Sequential: Combinational circuits (e.g., adders) lack memory and depend solely on instantaneous inputs; sequential circuits (e.g., counters) use clocked flip-flops to retain state history.
- Sequential Design Flow: State Diagrams State Tables Excitation Tables K-map Input Equations Circuit Schematics.