Table of Contents
From Logic Gates to Working Circuits
Basic digital circuits are built by connecting logic gates so that they perform useful tasks. A single gate can make a simple decision, but a circuit made from many gates can store information, count pulses, choose between inputs, or carry out arithmetic. In this chapter, the focus is on the most common small building blocks that appear again and again in digital systems.
A digital circuit usually works with two logic levels, often called 0 and 1. These levels represent low and high voltage ranges. A circuit does not need an exact voltage value for 0 or 1, it only needs the voltage to fall inside the allowed range for each logic state.
A basic digital circuit treats signals as discrete logic states, not as continuously varying values. In most introductory contexts, 0 means LOW and 1 means HIGH.
Combinational and Sequential Circuits
A useful first classification is based on whether the output depends only on the present inputs, or also on past inputs.
Combinational circuits have outputs determined only by the current input values. If the inputs change, the outputs respond accordingly after a short delay. Examples include adders, multiplexers, decoders, and comparators.
Sequential circuits have outputs that depend on the current inputs and on the stored state of the circuit. They contain memory. Examples include latches, flip flops, registers, and counters.
The difference is central because combinational circuits compute, while sequential circuits compute and remember.
| Circuit type | Output depends on | Memory present |
|---|---|---|
| Combinational | Current inputs only | No |
| Sequential | Current inputs and previous state | Yes |
Half Adders and Full Adders
One of the most important basic digital circuits is the adder. It performs binary addition.
A half adder adds two one bit inputs, usually called $A$ and $B$. It produces two outputs, the sum bit $S$ and the carry bit $C$.
The logic is:
$$
S = A \oplus B
$$
$$
C = A \cdot B
$$
Here $\oplus$ means XOR and the dot means AND.
| $A$ | $B$ | $S$ | $C$ |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
A half adder is useful, but it cannot include a carry coming from a previous stage. For that, we use a full adder.
A full adder adds three one bit inputs, $A$, $B$, and carry in $C_{in}$. It produces a sum bit $S$ and a carry out $C_{out}$.
$$
S = A \oplus B \oplus C_{in}
$$
$$
C_{out} = AB + AC_{in} + BC_{in}
$$
A full adder can be built from two half adders and one OR gate. This makes it a practical building block for larger arithmetic circuits.
For a full adder, the sum output is 1 when an odd number of inputs are 1. The carry output is 1 when at least two inputs are 1.
Multi Bit Addition
To add numbers with more than one bit, several full adders are connected in a chain. The carry out of one stage becomes the carry in of the next stage. This arrangement is called a ripple carry adder.
For a two bit addition, the least significant bits are added first. Then the carry moves to the next stage.
If the bits are written as
$$
A = A_1A_0, \qquad B = B_1B_0
$$
then the first stage adds $A_0$ and $B_0$, and the second stage adds $A_1$, $B_1$, and the carry from the first stage.
The ripple carry adder is simple, but the carry must pass through each stage one after another. This causes delay in larger adders.
In a ripple carry adder, the carry signal propagates stage by stage. This makes the total response time increase with the number of bits.
Subtractors
Subtraction is another basic operation. A half subtractor subtracts one bit $B$ from one bit $A$. It gives a difference bit $D$ and a borrow bit.
For a half subtractor,
$$
D = A \oplus B
$$
$$
Borrow = \overline{A}B
$$
A full subtractor includes an input borrow from a previous stage. Just like addition, multi bit subtraction can be built by connecting stages together.
In practical digital systems, subtraction is often done using adders by representing negative numbers in a suitable binary form. The full treatment of that belongs to more advanced digital design, but it is useful to know that the same hardware can often perform both addition and subtraction.
Multiplexers
A multiplexer selects one input from several possibilities and sends it to the output. It acts like a digital selector.
A common example is the 2 to 1 multiplexer. It has two data inputs, $I_0$ and $I_1$, one select input $S$, and one output $Y$.
If $S = 0$, the output is $I_0$. If $S = 1$, the output is $I_1$.
Its Boolean expression is
$$
Y = \overline{S}I_0 + SI_1
$$
This kind of circuit is widely used when one of several signals must be chosen.
| $S$ | Output |
|---|---|
| 0 | $I_0$ |
| 1 | $I_1$ |
Decoders
A decoder takes a binary input and activates one output corresponding to that input. For example, a 2 to 4 decoder has two input bits and four output lines.
If the inputs are $A$ and $B$, then only one output is active at a time:
$$
Y_0 = \overline{A}\,\overline{B}
$$
$$
Y_1 = \overline{A}B
$$
$$
Y_2 = A\overline{B}
$$
$$
Y_3 = AB
$$
This circuit converts a binary code into a one of many form. Decoders are used for memory selection, display driving, and address recognition.
| $A$ | $B$ | Active output |
|---|---|---|
| 0 | 0 | $Y_0$ |
| 0 | 1 | $Y_1$ |
| 1 | 0 | $Y_2$ |
| 1 | 1 | $Y_3$ |
Encoders
An encoder performs the opposite task of a decoder. It takes one active input line and produces the corresponding binary code at the output.
For example, a 4 to 2 encoder has four inputs and two output bits. If only one input is active, the outputs represent its number in binary.
Encoders are useful when a system must convert a position or a selected line into binary form.
In more advanced circuits, priority encoders are used when more than one input may be active at the same time. They decide which input has priority.
Comparators
A comparator checks whether two binary values are equal, or whether one is larger than the other. The simplest case is a one bit comparator.
For one bit inputs $A$ and $B$,
$$
A = B \quad \text{when} \quad A \odot B = 1
$$
where $\odot$ means XNOR, the inverse of XOR.
The equality output can be written as
$$
E = AB + \overline{A}\,\overline{B}
$$
A comparator is useful in control systems, digital measurement devices, and decision circuits.
Latches and Flip Flops
To store one bit of information, a circuit must have memory. The simplest memory elements are latches and flip flops.
An SR latch can be made from cross connected NOR gates or NAND gates. It has two stable states, so it can remember one bit.
For a NOR based SR latch, the inputs are Set, $S$, and Reset, $R$.
If $S$ is activated, the output becomes 1. If $R$ is activated, the output becomes 0. If both are inactive, the previous state remains stored.
There is an invalid condition when both inputs are active at the same time in the simple SR latch. That condition should be avoided.
A latch stores one bit. In an SR latch, activating both control inputs at the same time can produce an invalid or undefined condition.
A flip flop is a more controlled memory element, usually triggered by a clock. This means its state changes only at particular times. The clock organizes the behavior of sequential circuits.
Common types include D flip flops, JK flip flops, and T flip flops. At beginner level, the key idea is that a flip flop stores a bit and updates it under clock control.
Registers
A register is a group of flip flops used to store several bits together. For example, a 4 bit register stores 4 bits. Each flip flop stores one bit, and all of them usually share a common clock.
Registers are used in processors, counters, memory systems, and communication circuits. They can temporarily hold data while it is being processed.
If a register stores bits $Q_3Q_2Q_1Q_0$, then it represents a 4 bit binary number or a 4 bit data word.
Counters
A counter is a sequential circuit that steps through a sequence of binary states. Each clock pulse changes the stored value.
A 2 bit counter can go through the sequence
$$
00 \to 01 \to 10 \to 11 \to 00 \to \cdots
$$
Counters are used for timing, frequency division, event counting, and digital clocks.
A modulo $N$ counter returns to its starting state after $N$ counts. For a binary counter with $n$ flip flops, the maximum number of states is
$$
N = 2^n
$$
An $n$ bit binary counter can represent up to $2^n$ distinct states.
Shift Registers
A shift register is a register designed so that data moves from one flip flop to the next when clock pulses arrive. This allows bits to be shifted left or right.
Shift registers are useful for serial communication, temporary storage, and data conversion between serial and parallel forms.
For example, in a right shift operation, the bit in each position moves one place to the right at each clock pulse.
Clock and Timing
Many digital circuits rely on a clock signal, a repeating pattern of high and low levels. The clock provides timing so that operations happen in an organized way.
The clock period is the time for one complete cycle. The clock frequency is the number of cycles per second.
They are related by
$$
f = \frac{1}{T}
$$
where $f$ is frequency and $T$ is period.
In sequential circuits, outputs do not usually change instantly. There is a small propagation delay. This matters when circuits operate at high speed.
Clocked digital circuits change state at specific times determined by the clock. Real circuits also have propagation delay, so outputs are never truly instantaneous.
A Simple Example of a Basic Digital System
A very small digital system can combine several of these blocks. Imagine a circuit that accepts two one bit inputs, adds them, stores the result, and displays whether a carry occurred. The adder performs the computation, the flip flop or register stores the output, and the indicator logic reports the carry bit.
This shows a central idea of digital electronics. Complex systems are built from a few simple circuit types connected in an organized way. Arithmetic blocks process data, selector blocks choose data paths, and memory blocks store state.
Summary of Common Basic Digital Circuits
| Circuit | Main function |
|---|---|
| Half adder | Adds two one bit numbers |
| Full adder | Adds two bits and a carry input |
| Subtractor | Performs binary subtraction |
| Multiplexer | Selects one input from many |
| Decoder | Converts binary input into one active output |
| Encoder | Converts one active input into binary code |
| Comparator | Compares binary values |
| Latch | Stores one bit, level sensitive |
| Flip flop | Stores one bit, clock controlled |
| Register | Stores several bits |
| Counter | Counts clock pulses |
| Shift register | Shifts stored bits left or right |
These circuits form the foundation of digital systems. Once they are understood, it becomes much easier to see how calculators, computers, clocks, and control devices are built from simple logic elements.
KAHIBARO