Your phone, laptop, the UPI payment terminal at a shop, the digital clock in your bus and the washing machine at home all have one thing in common: inside them, every piece of information (a photo, a song, a bank balance, a key press) is handled as a long stream of just two values, 0 and 1. The subject that explains how circuits store and process these 0s and 1s is digital electronics, also called digital logic or digital design.
This tutorial takes you from the very basics (what a "1" physically is) to gates, Boolean algebra, K-maps, adders, multiplexers, flip-flops, counters, state machines, memories and logic families. It follows the syllabus of most Indian university courses (Digital Logic / Digital Electronics / Switching Theory) and covers everything GATE CS asks in the Digital Logic section.
Digital electronics is the branch of electronics that represents information using a small number of discrete values (almost always two: 0 and 1) and builds circuits that process those values according to the rules of logic.
In this first chapter we will understand why the world chose digital, what 0 and 1 mean as voltages, how a digital signal looks on an oscilloscope, what "noise margin" and "propagation delay" are, and how the rest of the tutorial is organised.
Analog vs Digital
A quantity is analog if it can take any value in a continuous range. Room temperature can be 27.3 °C or 27.31 °C or 27.3142 °C; the voltage from a microphone rises and falls smoothly with your voice.
A quantity is digital if it can take only a finite set of separate (discrete) values. A light switch is ON or OFF; the number of students in a class is 59 or 60, never 59.5.
Analog signal (continuous) Digital signal (two levels)
V V
| .--. | ____ ________
| .' '. .--. | | | | |
| .' '. .' '. | | | | |
|.' '..' '. |__| |____| |____
+----------------------------- t +----------------------------- t
any value at any instant only LOW (0) or HIGH (1)
Point | Analog | Digital |
|---|---|---|
Values | Continuous, infinitely many | Discrete, finitely many (usually 2) |
Effect of noise | Noise adds directly to the signal and cannot be removed later | Small noise is ignored; the signal is "regenerated" at every gate |
Copying / storage | Every copy loses quality (think of old cassette tapes) | Perfect copies, any number of times |
Accuracy | Limited by component tolerance and drift | Set by the number of bits; add bits for more precision |
Processing | Hard to program; each function needs its own circuit | Programmable; one processor can do any task |
Examples | Microphone output, thermocouple, old radio receivers | Computers, phones, digital watches, DVDs, UPI QR scanners |
The real world is analog (sound, light, temperature). So most systems are mixed: an ADC (analog-to-digital converter) turns the microphone signal into numbers, the digital part processes them, and a DAC turns numbers back into a voltage for the speaker. We study these converters in DAC & ADC at the end of the tutorial.
sound ──► microphone ──► ADC ──► digital processing ──► DAC ──► speaker ──► sound
(analog) (0s and 1s: filter, (analog)
compress, store, send)
Why Only Two Values?
We could build circuits with 10 voltage levels, one per decimal digit. Early machines like ENIAC did use decimal counting circuits. So why does almost every digital system today use binary (two levels)?
Reliability. A transistor is easy to use as a switch that is either fully ON or fully OFF. Telling "ON" from "OFF" is easy even when voltages drift with temperature, ageing or noise. Telling level 6 from level 7 out of 10 is much harder.
Wide tolerance. Each of the two levels can be a whole range of voltages (for example, anything near 0 V is 0, anything near 5 V is 1). Components need not be precise, so they are cheap.
Simple mathematics. Two-valued logic has a complete, simple algebra (Boolean algebra, introduced by George Boole in 1854). In 1937 Claude Shannon showed in his master's thesis that switching circuits can be designed using this algebra. Every circuit in this tutorial rests on that idea.
Low power and dense packing. A switch that is fully OFF or fully ON wastes little power in either state, which is why billions of them fit on one chip.
A bit (binary digit) is a single 0 or 1. A group of 4 bits is a nibble, and a group of 8 bits is a byte.
With n bits we can represent 2n different patterns: 8 bits give 256 patterns, 16 bits give 65,536. How numbers, letters and other data are encoded in these patterns is the subject of the next chapter, Number Systems & Binary Codes.
Logic Levels: What Is a "1" Physically?
Inside a circuit, 0 and 1 are just two voltage ranges. In positive logic (the normal convention, used throughout this tutorial):
HIGH (H) voltage = logic 1
LOW (L) voltage = logic 0
The ranges are not the same for inputs and outputs. A chip guarantees that its outputs are inside a tighter range than its inputs will accept. The gap between the two is what protects us from noise.
The four numbers on every logic data sheet are:
Symbol | Meaning | Standard TTL (74xx, VCC = 5 V) |
|---|---|---|
VOH(min) | Lowest voltage an output gives for a HIGH | 2.4 V |
VOL(max) | Highest voltage an output gives for a LOW | 0.4 V |
VIH(min) | Lowest input voltage guaranteed to be read as HIGH | 2.0 V |
VIL(max) | Highest input voltage guaranteed to be read as LOW | 0.8 V |
OUTPUT guarantees INPUT accepts
5.0 V ┬ 5.0 V ┬
│ valid HIGH output │
2.4 V ┤ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ │ read as HIGH
│ │ NM_H = 0.4 V │
│ └ ─ ─ ─ ─ ─ ─ ┤ 2.0 V
│ (never driven │ undefined region
│ by a good output) │ (forbidden)
│ ┌ ─ ─ ─ ─ ─ ─ ┤ 0.8 V
│ │ NM_L = 0.4 V │
0.4 V ┤ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ │ read as LOW
│ valid LOW output │
0.0 V ┴ 0.0 V ┴
Noise Margin
Noise margin is the largest noise voltage that can be added to a valid output before the next gate's input may read it wrongly.
NMH = VOH(min) − VIH(min) and NML = VIL(max) − VOL(max)
Example 1: TTL Noise Margins
NM_H = V_OH(min) − V_IH(min) = 2.4 − 2.0 = 0.4 V
NM_L = V_IL(max) − V_OL(max) = 0.8 − 0.4 = 0.4 V
So a TTL HIGH output (at least 2.4 V) can drop by up to 0.4 V due to noise
and the next gate will still read a HIGH.
Example 2: CMOS (74HC Series at VCC = 4.5 V)
Data sheets for 74HC-series gates give, at VCC = 4.5 V and a light load: VOH(min) = 4.4 V, VOL(max) = 0.1 V, VIH(min) = 3.15 V, VIL(max) = 1.35 V.
NM_H = 4.4 − 3.15 = 1.25 V
NM_L = 1.35 − 0.1 = 1.25 V
CMOS gives a much larger noise margin than standard TTL, one reason CMOS dominates today. (At heavier output currents the output levels get worse, so the margin shrinks. Real designs always read the data sheet for the exact operating conditions.) Families, fan-out and power are covered in Logic Families: TTL & CMOS.
Positive and Negative Logic
In negative logic, LOW = 1 and HIGH = 0. The physical circuit does not change; only our interpretation does. This has a surprising effect:
A physical gate behaves like this (in voltages):
In1 In2 | Out
L L | L
L H | L
H L | L
H H | H
Positive logic (H=1, L=0): 0 0→0, 0 1→0, 1 0→0, 1 1→1 → AND gate
Negative logic (H=0, L=1): 1 1→1, 1 0→1, 0 1→1, 0 0→0 → OR gate
So the same chip is a positive-logic AND and a negative-logic OR. In general, switching conventions turns a function into its dual (AND ↔ OR, NAND ↔ NOR). We meet duality formally in Boolean Algebra Laws. Signals that are "active-low" (they do their job when LOW, like a chip-select CS′ or a RESET′ pin) are a practical use of this idea.
Digital Waveforms
A digital signal changes between LOW and HIGH over time. The plot of the signal against time is called a waveform or timing diagram.
┌──────┐ ┌──────┐ ┌──────┐
CLOCK │ │ │ │ │ │
───┘ └──────┘ └──────┘ └──────
◄─ tH ─►◄─ tL ─►
◄──── T ──────►
↑ rising edge ↑ falling edge
Pulse: a signal that goes from its normal level to the other level and back. Pulse width tW is measured at 50% of the amplitude.
Rising (positive) edge: the LOW → HIGH transition. Falling (negative) edge: HIGH → LOW.
Periodic waveform: repeats every period T. Frequency f = 1 / T.
Duty cycle = (tH / T) × 100%, the percentage of the period the signal is HIGH.
Clock: the periodic signal that tells sequential circuits when to change state. Your processor's "3.2 GHz" is its clock frequency.
Rise Time and Fall Time
Real edges are not vertical; a voltage takes time to change.
Rise time tr is the time a signal takes to go from 10% to 90% of its HIGH amplitude. Fall time tf is the time from 90% down to 10%.
100% ─ ─ ─ ─ ─ ─ ─ ─ ┌───────────────┐
90% ─ ─ ─ ─ ─ ─ ─ ─/│ │\
/ │ │ \
50% ─ ─ ─ ─ ─ ─ ─/─ ┼ ─ ─ pulse ─ ─ ┼ ─\─ ─
/ │ width │ \
10% ─ ─ ─ ─ ─ ─/─ ─ │ │ ─ ─\─
0% ──────────┘ └──────
◄─tr─► ◄─tf─►
Example 3: Period, Frequency and Duty Cycle
A clock runs at 50 MHz and is HIGH for 5 ns in every cycle.
Period T = 1 / f = 1 / (50 × 10^6 Hz) = 20 × 10^-9 s = 20 ns
Duty cycle = tH / T × 100% = 5 / 20 × 100% = 25%
LOW time tL = T − tH = 20 − 5 = 15 ns
A "square wave" is a periodic waveform with a 50% duty cycle.
Propagation Delay
When a gate's input changes, its output does not change instantly. Transistors take time to switch and wires take time to charge.
Propagation delay is the time between an input change and the resulting output change, measured from the 50% point of the input edge to the 50% point of the output edge.
tPHL: delay when the output goes HIGH → LOW.
tPLH: delay when the output goes LOW → HIGH.
Average delay tpd = (tPHL + tPLH) / 2.
Example 4: Delay Through a Path
A gate has tPHL = 7 ns and tPLH = 11 ns.
Average delay tpd = (7 + 11) / 2 = 9 ns
A signal passes through 4 such gates in series.
Safe upper bound (assume every gate takes its slower delay, 11 ns):
path delay ≤ 4 × 11 = 44 ns
Using the average figure instead: 4 × 9 = 36 ns
If the 4 gates are INVERTING (NOT, NAND, NOR), one input edge makes the
outputs alternate: rise, fall, rise, fall (or fall, rise, fall, rise).
So the path really takes 11 + 7 + 11 + 7 = 36 ns for either edge.
The 4 × tPLH(max) figure is the quick, conservative estimate used when you do not know the edge directions; tracing the actual edges, as in the last two lines, gives the exact answer.
Propagation delay is why the speed of a circuit is limited: the clock cannot tick again until signals have travelled through the slowest path (the critical path). It is also the root cause of glitches, which we study in Hazards in Combinational Circuits, and the reason a ripple-carry adder is slow (Ripple-Carry & Carry Look-Ahead Adders).
Combinational vs Sequential Circuits
Every digital circuit in this tutorial falls into one of two families:
A combinational circuit's outputs depend only on its present inputs. A sequential circuit's outputs depend on its present inputs AND on its past (stored state), so it has memory.
Combinational Sequential
inputs ──► [ logic gates ] ──► outputs inputs ──► [ combinational ] ──► outputs
[ logic ]
same inputs → always same output ┌──► [ ]──┐
no clock, no memory │ │
└──── [ memory ] ◄──────┘
(flip-flops, clock)
Point | Combinational | Sequential |
|---|---|---|
Memory | None | Yes (latches / flip-flops) |
Feedback path | No | Yes |
Clock | Not needed | Usually (synchronous); some are asynchronous |
Described by | Truth table, Boolean expression | State table, state diagram |
Examples | Adder, multiplexer, decoder, comparator | Flip-flop, register, counter, vending machine controller |
A simple test: if the same inputs can give different outputs at different times, the circuit must be remembering something, so it is sequential. A calculator's "+" logic is combinational; the display that keeps showing your number after you lift your finger is sequential.
Integrated Circuits and Levels of Integration
Gates are built from transistors, and many gates are made together on a single piece of silicon called an integrated circuit (IC) or chip. A history in one line: the transistor (1947, Bell Labs) replaced vacuum tubes, and the IC (Jack Kilby at Texas Instruments in 1958 and Robert Noyce at Fairchild in 1959) put many transistors on one chip.
ICs are traditionally classified by how many gates they contain. Textbooks draw the boundaries slightly differently; a common version is:
Scale | Approx. gates per chip | Examples |
|---|---|---|
SSI (Small-Scale Integration) | up to about 10 | 7400 (four NAND gates), 7404 (six inverters) |
MSI (Medium-Scale) | about 10 to 100 | Adders, multiplexers, decoders, counters |
LSI (Large-Scale) | about 100 to 10,000 | Early microprocessors, small memories |
VLSI (Very Large-Scale) | about 10,000 to 100,000 | Microprocessors, large memories |
ULSI (Ultra Large-Scale) | above 100,000 | Modern processors and GPUs |
Today the term "VLSI" is used loosely for all large chip design, and modern processors contain billions of transistors. In a lab you will still use SSI/MSI chips such as the 74-series on a breadboard; in industry, designs are written in a hardware description language (Verilog or VHDL) and turned into gates automatically, or loaded into programmable chips (FPGAs). The ideas you learn here (gates, Boolean algebra, flip-flops) are exactly what those tools work with.
Levels of Abstraction
Digital design is manageable because we work in layers. Each layer hides the details of the one below:
Software / applications (C, Python, apps)
─────────────────────────────
Computer architecture (instructions, registers, memory)
─────────────────────────────
Digital building blocks ◄──┐ (adders, MUX, registers, counters, FSMs)
───────────────────────── │
Logic gates ◄──┤ this tutorial
───────────────────────── │
Boolean algebra ◄──┘ (the mathematics of 0 and 1)
─────────────────────────────
Transistors / electronics (CMOS, TTL, voltages, currents)
─────────────────────────────
Physics (semiconductors)
This tutorial lives in the middle three layers. We touch electronics only where it matters for a digital designer (logic levels, delays, logic families) and stop where computer architecture begins.
Roadmap of This Tutorial
Foundations: Number Systems & Binary Codes, Logic Gates, Universal Gates, Boolean Algebra Laws, De Morgan's Theorems, Canonical Forms.
Minimisation: Karnaugh Maps, don't-care conditions, the Quine-McCluskey method.
Combinational circuits: adders, subtractors, fast adders, multiplexers, demultiplexers, decoders, encoders, comparators, code converters, parity circuits, hazards.
Sequential circuits: latches, flip-flops, registers, counters, finite state machines, sequence detectors.
Hardware: memories and programmable logic (ROM, PLA, PAL), logic families (TTL, CMOS), DAC and ADC.
Common Mistakes
Thinking 1 means exactly 5 V. Logic 1 is a voltage range. A TTL input accepts anything from 2.0 V upward as HIGH.
Mixing up input and output thresholds in noise-margin questions. Noise margin always compares an output guarantee with an input requirement: NMH = VOH − VIH, NML = VIL − VOL.
Measuring rise time from 0% to 100%. The standard definition is 10% to 90%.
Calling any circuit with a clock "sequential" and any without a clock "combinational". The real test is memory (state). An SR latch made of two cross-coupled NOR gates has no clock but is sequential.
Forgetting units: 1 / 50 MHz is 20 ns, not 20 ms.
Assuming digital is always better. Digital systems still need analog front-ends, and converting adds cost, delay and quantisation error.
Interview and GATE Questions
Q1. A logic family has VOH(min) = 2.7 V, VOL(max) = 0.5 V, VIH(min) = 2.0 V, VIL(max) = 0.8 V. Find the noise margins.
NMH = 2.7 − 2.0 = 0.7 V; NML = 0.8 − 0.5 = 0.3 V. The circuit's overall noise immunity is the smaller one, 0.3 V. (These are the figures for the 74LS TTL family.)
Q2. A clock has a period of 250 ns and a duty cycle of 40%. Find its frequency and HIGH time.
f = 1 / 250 ns = 4 MHz. tH = 0.40 × 250 = 100 ns (and tL = 150 ns).
Q3. A gate has tPLH = 15 ns and tPHL = 9 ns. What is its average propagation delay?
tpd = (15 + 9) / 2 = 12 ns.
Q4. Is a circuit whose output depends on the input applied 1 ms ago combinational or sequential?
Sequential. It must store information about the past, so it has memory. Combinational outputs depend only on present inputs (after the propagation delay settles).
Q5. A physical gate outputs HIGH only when both inputs are LOW. What is it in positive logic and in negative logic?
Positive logic (H = 1): output 1 only when both inputs are 0, so it is a NOR gate. Negative logic (H = 0, L = 1): output 0 only when both inputs are 1, so it is a NAND gate. Changing the convention swaps a function with its dual.
Q6. Why are digital signals more immune to noise than analog ones?
Because each logic level is a range, and every gate re-drives a clean level at its output. Noise smaller than the noise margin is completely removed at the next gate, whereas in an analog system noise adds to the signal and accumulates through every stage.
Summary
Analog signals are continuous; digital signals take discrete values. Digital systems use binary because two levels are reliable, cheap and fit Boolean algebra.
Logic 0 and 1 are voltage ranges. Data sheets give VOH, VOL, VIH, VIL; noise margins NMH = VOH − VIH and NML = VIL − VOL (0.4 V each for standard TTL).
Positive logic: HIGH = 1. Negative logic swaps the meaning and turns a function into its dual.
Waveform terms: period, frequency f = 1/T, duty cycle tH/T, rise/fall time (10% to 90%), propagation delay tpd = (tPHL + tPLH)/2.
Combinational = no memory; sequential = memory/state.
ICs range from SSI (a few gates) to modern chips with billions of transistors.
Next, in Number Systems & Binary Codes, we learn how numbers and text are written using only 0s and 1s.