BitFlow
← Academy·What Is Digital?
01Beginner~20 min

What Is Digital?

Why computers use only two levels, what a bit is, and how switches turn into logic. Start here if this is all new.

Smooth signals and stepped signals

A signal is a quantity that carries information, and in electronics it is usually a voltage on a wire. A microphone turns your voice into a voltage that rises and falls smoothly. Every tiny change in that voltage means something. This is an analog signal: it can take any value in a range.

A digital signal only cares which of two ranges the voltage is in. We call the ranges low and high, and write them as 0 and 1. Whether the wire is at 3.1 V or 3.2 V makes no difference, because both are simply high.

Think of a dimmer knob against a light switch. The knob has endless positions, and it is hard to set it to exactly the same brightness twice. The switch is on or off, and anybody can read it correctly from across the room.

NoteThe physical world is analog: sound, temperature, light. Digital systems measure it, turn it into numbers, work on the numbers, and turn the result back. Chapter 19 covers those conversions.

Why only two levels

A real wire is noisy. Nearby wires, heat and the power supply all push its voltage around. If we stored meaning in the exact voltage, that noise would damage the information. With two widely separated ranges, a small push changes nothing.

Each logic family publishes what counts as low and high. These are the typical figures for classic 5 V TTL chips:

Low (0)High (1)
A gate's output is guaranteed to beat most 0.4 Vat least 2.4 V
A gate's input will acceptup to 0.8 Vfrom 2.0 V
An input voltage between 0.8 V and 2.0 V has no defined meaning. Circuits are designed so that wires only pass through this range while switching.

Notice the outputs are stricter than the inputs. That gap is the noise margin: how much noise a signal can pick up on its way from one gate to the next and still be read correctly.

high margin = 2.4 − 2.0 = 0.4 V low margin = 0.8 − 0.4 = 0.4 V

There is one more trick. Every gate drives its output to a clean level again, however messy its input was, as long as the input stayed in range. So noise doesn't build up along a chain of gates. In an analog chain each stage adds its noise to the signal for good, which is why a photocopy of a photocopy looks worse, while a copied file is identical to the original.

Loading the animation…

Practice

A family guarantees outputs of at most 0.2 V for low and at least 3.0 V for high. Its inputs accept up to 0.7 V as low and from 2.2 V as high. What is its low noise margin?

Bits and how many you need

One wire carrying a 0 or 1 holds one bit (binary digit). Group bits together and they can stand for more: 4 bits make a nibble and 8 bits make a byte.

Every extra bit doubles the number of different patterns, so n bits give 2ⁿ patterns.

BitsPatternsEnough for
12yes or no
38the days of the week
532the 26 letters of the alphabet
8256a byte: English text, one colour channel
1010240 to 999, with some patterns left over
1665,536CD-quality audio samples
Worked example: How many bits for the alphabet?

You want a different pattern for each of the 26 capital letters. What is the smallest number of bits that works?

  1. 4 bits give 2⁴ = 16 patterns, which is too few.
  2. 5 bits give 2⁵ = 32 patterns, which is enough. Six patterns stay unused.

Answer:5 bits. In general, the bits needed for N different things is the smallest n with 2ⁿ ≥ N.

Practice

A sensor reports one of 1000 different readings. How many bits does each reading need?

From switches to logic

Here is the key idea of the whole subject: a transistor is a switch controlled by a voltage. A 1 on its control pin lets current through, or blocks it, depending on the type. That means the output of one switch can control another, so bits can make decisions about other bits.

Connect two switches in series and current flows only if the first and the second are closed. Connect them in parallel and current flows if either is closed. Those two wirings are the two most basic operations in logic, called AND and OR.

Loading the circuit…

This circuit is live. Click the switches a and b, and watch the wires and lights.
  • Turn on only a. Which light comes on, and why not the other?
  • Press Slow motion, then flip a switch and watch the change travel through the gate.
  • Turn on both. Now every wire is green.
  • Can you make both light up without either? Try it, then think about why not.

You can list everything a circuit does in a truth table: one row for every combination of inputs. Two inputs make 2² = 4 rows.

abboth (AND)either (OR)
0000
0101
1001
1111
TipReal chips build these gates from a few transistors each, and Chapter 9 shows how. You don't need that yet. For now a gate is a small box with a truth table.

Circuits that decide and circuits that remember

Every digital circuit falls into one of two families.

  • Combinational circuits decide. The output depends only on the inputs right now, as in the circuit above. An adder is combinational.
  • Sequential circuits remember. The output also depends on what happened earlier, because the circuit stores some bits. A counter must remember the last count to know the next one.

Memory brings up the question of when to store. Most sequential circuits follow a clock, a signal that ticks between 0 and 1 forever. The storage parts, called flip-flops, take in a new value only at the instant the clock rises, and hold it until the next rise.

A flip-flop following a clock01234567clkdq
A flip-flop in action. At each rising edge of clk, q takes the value d had just before the edge, so q follows d one cycle later. Between edges, q doesn't move.

The clock's speed is measured in hertz: a 1 GHz clock ticks a billion times a second. Each tick, all the flip-flops in a chip update together, which keeps billions of transistors in step.

How it all stacks up

A processor is too big to understand all at once, so engineers build in layers. Each layer uses the one below it and hides the details.

  1. Transistors act as switches.
  2. Gates (AND, OR, NOT) are built from a few transistors.
  3. Building blocks such as adders, multiplexers and flip-flops are built from gates.
  4. Units such as registers, counters, memories and an ALU are built from blocks.
  5. A processor connects those units and follows a list of instructions.

This course climbs that stack. Chapters 2 to 4 cover how bits represent numbers and text. Chapters 5 to 8 cover gates and the algebra for simplifying them. Chapters 9 to 12 build combinational blocks. Chapters 13 to 17 add memory and timing, Chapters 18 and 19 cover large memories and the link to the analog world, and Chapter 20 moves from drawing circuits to describing them in Verilog.

TipEach chapter is tagged Beginner, Core or GATE. Sections marked GATE go beyond a first course, so skip them on your first pass and come back when you're preparing for university exams or the GATE paper.
Open the circuit editor →Every live circuit in this course has an Open in the editor button, so you can take it apart. You can also start from a blank page.
Was this chapter helpful?