Digital Circuits and Binary Data
From Analog Signals to Digital Systems
Digital electronics builds on a key idea: information can be represented using a limited number of clearly separated states. This makes digital systems easier to reproduce reliably, process mathematically, store in memory, and combine into complex devices.
Analog and Digital Representation
In analog electronics, a quantity can take any value within a continuous range. For example, a voltage might be 2.1 V, 2.11 V, or 2.111 V. In principle, infinitely many values are possible.
This flexibility also creates a problem: small disturbances can change the value. Noise, temperature changes, manufacturing differences, and measurement errors may cause two supposedly identical analog systems to behave slightly differently. This is a problem of repeatability—the ability to produce the same result consistently.
Digital circuits limit the number of possible values. The most basic digital system uses two states, commonly represented as:
- Low, usually represented by 0
- High, usually represented by 1
Because a digital signal only needs to be recognized as either low or high, small disturbances may not change its interpreted value. A signal that is slightly above or below its ideal level can still be recognized correctly. This gives digital systems greater resistance to certain errors and generally makes them easier to reproduce reliably than analog systems.
A digital system improves repeatability by replacing infinitely many possible signal values with a limited set of clearly distinguishable states.
Think About It
If an analog signal is supposed to be 3.00 V and noise changes it to 3.02 V, the measured value changes. If a digital circuit only needs to decide whether the signal is high or low, why might the same noise have less effect?
Bits and Words
The logic state of one digital element is called a bit. The word bit comes from “binary digit.” A bit can have only two possible values:
0or1A single bit is enough to represent one two-state condition, such as:
- Switch open or closed
- False or true
- Low or high
- No or yes
Digital devices often have many inputs and outputs. When several bits are considered together, they can represent many more states. A group of bits is called a word.
For a word containing n bits, the number of possible combinations is:
2nFor example:
- 1 bit gives 21=2 combinations
- 2 bits give 22=4 combinations
- 3 bits give 23=8 combinations
- 8 bits give 28=256 combinations
The source describes an example involving eight possible combinations for two digits; strictly speaking, eight combinations require three bits. Two bits provide only four combinations.
Each position in a binary word has a weight. The weight depends on the position of the bit.
Understanding Binary Numbers
The decimal system uses ten symbols, from 0 through 9. Each position in a decimal number has a power-of-ten weight:
- Units position: 100=1
- Tens position: 101=10
- Hundreds position: 102=100
Therefore, the decimal number 103 means:
1×100+0×10+3×1=103Binary uses only two symbols, 0 and 1. Each position has a power-of-two weight. The rightmost bit is called the least significant bit, or youngest bit in the source material. Its weight is:
20=1Moving left, the powers increase:
| Bit position from the right | Weight |
|---|---|
| First | 20=1 |
| Second | 21=2 |
| Third | 22=4 |
| Fourth | 23=8 |
| Fifth | 24=16 |
| Sixth | 25=32 |
| Seventh | 26=64 |
| Eighth | 27=128 |
The leftmost bit in a fixed-size word is the most significant bit because it has the greatest weight.
To convert a binary word into a decimal number, each bit is multiplied by its weight, and the results are added:
Decimal value=∑(bit×bit weight)Example: Converting 011001112 to Decimal
The binary word 011001112 contains 1s in the positions with weights 64, 32, 4, 2, and 1:
0×128+1×64+1×32+0×16+0×8+1×4+1×2+1×1Therefore:
64+32+4+2+1=103Thus:
011001112=10310The 128-weight bit must be 0 because 128 is already greater than $103`.
Example: Converting 100110002 to Decimal
The 1s occur at weights 128, 16, and 8:
128+16+8=152Therefore:
100110002=15210Converting Decimal Numbers to Binary
The repeated-division method converts a decimal number into binary.
- Divide the decimal number by 2.
- Record the remainder, which is always 0 or 1.
- Divide the quotient by 2 again.
- Continue until the quotient becomes 0.
- Read the remainders from bottom to top.
The reason the remainders work is that every division by 2 reveals the next binary digit, beginning with the least significant bit.
Example: Converting 152 to Binary
| Division | Quotient | Remainder |
|---|---|---|
| 152÷2 | 76 | 0 |
| 76÷2 | 38 | 0 |
| 38÷2 | 19 | 0 |
| 19÷2 | 9 | 1 |
| 9÷2 | 4 | 1 |
| 4÷2 | 2 | 0 |
| 2÷2 | 1 | 0 |
| 1÷2 | 0 | 1 |
Reading the remainders from bottom to top gives:
100110002This agrees with the earlier conversion:
128+16+8=152Think About It
Why are the remainders read from bottom to top rather than top to bottom? The first division identifies the smallest power of 2, while the final division identifies the largest one.
Boolean Algebra and Logic Gates
Digital systems use Boolean algebra to describe two-state logic. In Boolean algebra, a variable can have one of two values:
0or1These values may also be interpreted as:
- False and true
- Low and high
- Off and on
- An inactive and active logic state
The three basic Boolean operations are:
- Logical product, or AND
- Logical sum, or OR
- Negation, or NOT
The behavior of a logic operation can be shown in a truth table. A truth table lists every possible input combination and shows the resulting output.
The AND Gate
An AND gate performs logical conjunction. Its output is 1 only when every input is 1.
For two inputs A and B:
| A | B | A AND B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
AND resembles multiplication because the output is 1 only when all multiplied values are 1:
A⋅BFor example:
1⋅1=1but:
1⋅0=0The OR Gate
An OR gate performs logical addition, or alternative. Its output is 1 when at least one input is $1.
| A | B | A OR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
In Boolean notation, OR is often written using a plus sign:
A+BThe plus sign represents logical OR here, not ordinary arithmetic addition. The result of 1+1 in Boolean OR is 1, not decimal 2.
The NOT Gate
A NOT gate performs negation. It reverses the input:
| A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
The negation of A can be written as:
Aor:
¬AIf A=1, then A=0. If A=0, then A=1.
More Advanced Logic Gates
More complex gates are built from the basic operations.
NAND Gate
A NAND gate is an AND gate followed by NOT. Its output is the negation of A AND B:
A⋅BIt produces 0 only when all inputs are 1.
NOR Gate
A NOR gate is an OR gate followed by NOT:
A+BIt produces 1 only when all inputs are 0.
Exclusive OR Gate
An exclusive OR, or XOR, produces 1 when the inputs are different. For two inputs:
| A | B | A XOR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
XOR is different from ordinary OR because OR also produces 1 when both inputs are 1.
Exclusive NOR Gate
An exclusive NOR, or XNOR, is the negation of XOR. It produces 1 when the inputs are equal:
A⊕BMultiplexers and Demultiplexers
Some digital circuits do not simply calculate a Boolean result. They control the path taken by data.
Multiplexer
A multiplexer, often abbreviated MUX, has:
- Many data inputs
- One output
- Address or selection lines
The address lines identify which input should be connected to the output. A multiplexer can be compared with a railway switch: many possible tracks exist, but the switch selects one track for the train to follow.
A multiplexer is useful when several data sources must share one communication line. The selected input is transferred to the single output.
Demultiplexer
A demultiplexer, or DEMUX, performs the opposite function:
- One data input
- Many outputs
- Address or selection lines
The address lines specify which output receives the input data. A demultiplexer can take data arriving on one line and direct it to a selected destination.
Think About It
A multiplexer chooses one input from many. A demultiplexer chooses one output from many. The address lines are essential because they tell the circuit which path to select.
Combinational and Sequential Logic
Logic circuits can be divided into two important categories.
Combinational Systems
A combinational system has an output determined only by the current input values.
If the inputs are changed, the output changes according to the circuit’s logic. The circuit does not need to remember what happened earlier.
Examples include:
- AND, OR, and NOT gates
- Combinations of logic gates
- Multiplexers
- Demultiplexers
For a combinational system, the general relationship is:
Output=f(current inputs)Sequential Systems and Triggers
A more complex system can depend on both its current inputs and its previous internal condition. Such a system has memory and is called a sequential system.
The source refers to memory-producing logic systems as triggers. These are commonly built from logic gates and are used to memorize a current state.
A trigger often has an additional input used to synchronize state changes with a clock signal. The clock provides regularly timed events, allowing the system to update its stored state in an organized way.
For a sequential system:
Next state=f(current inputs,current state)This distinction is fundamental:
- Combinational logic calculates from present inputs.
- Sequential logic calculates from present inputs and remembers past conditions.
Karnaugh Maps and Logic Optimization
A circuit can be built directly from a truth table, but a direct implementation may require many gates. A large number of gates makes a circuit physically larger, more expensive, slower, and more difficult to manage.
The Karnaugh method, or Karnaugh map method, is a technique for simplifying Boolean functions before building the circuit.
From Truth Table to Boolean Equation
Suppose a truth table has inputs A, B, and C. Each row represents one input combination. A 0 means a false or negative state, and a 1 means a true or positive state.
For each row that produces output 1, a Boolean term can be written:
- If an input is 1, write the variable normally.
- If an input is 0, write the negated variable.
For example, for the input combination:
A=0,B=1,C=0the corresponding term is:
ABCIf several rows produce 1, their terms are combined with OR. A direct equation might therefore be:
F=ABC+ABC+ABCThis type of equation can become long when there are many inputs and many positive output states.
Structure of a Karnaugh Map
A Karnaugh map arranges the truth-table values in a grid. The rows and columns use Gray code ordering.
Gray code has the important property that neighboring entries differ in only one bit. This allows neighboring cells to be grouped because only one variable changes within the group.
For three inputs, there are:
23=8possible input combinations, so the map contains eight cells.
For four inputs, there are:
24=16possible combinations, so the map contains sixteen cells.
Each cell is filled with the output value for the corresponding input combination.
Grouping Ones
The simplification process groups neighboring cells containing 1. The key principle is:
Larger valid groups produce simpler Boolean expressions.
Groups may contain:
1, 2, 4, 8,…cells, as long as the group size is a power of two and the cells are adjacent according to the Karnaugh-map arrangement.
Within a group, any variable that changes between cells is eliminated. Only variables that remain constant are included in the simplified term.
Example of Variable Elimination
Suppose two neighboring cells differ only in the value of C, while A=0 and B=1 remain fixed. The two original terms are:
ABCand:
ABCThe simplified result is:
ABThe variable C disappears because both values of C are included in the group.
This explains why grouping is useful: it removes unnecessary conditions from the equation.
Building the Circuit from the Simplified Equation
After grouping the 1s, each group becomes a product term. The product terms are joined using OR.
For example, if the simplified equation is:
F=AB+BCthe circuit requires:
- A NOT gate to create A
- An AND gate to create AB
- An AND gate to create BC
- An OR gate to combine the two terms
The simplified circuit performs the same logical function as the original truth table but uses fewer gates.
Think About It
Why does a group of four usually produce a simpler expression than a group of two? A larger group contains more changing variables, so more variables can be removed from the equation.
Don’t-Care States
Some input combinations may never occur in the intended device. These states are called unknown, unused, or don’t-care states.
A don’t-care state may be treated as either 0 or 1‘,dependingonwhichchoiceproducesthesimplercircuit.Usually,treatingitas1$ is useful when it allows a larger group of ones to be formed.
Two-Input Example
Suppose a device has inputs A and B, and the output is 1 only when:
A=0,B=1The direct equation is:
F=ABNow suppose the state A=0, B=0 is unused and may be treated as 1. The two neighboring positive states can be grouped. Since B changes but A remains 0, B disappears:
F=AThe optimized circuit now needs only a NOT gate instead of a NOT gate and an AND gate.
The important lesson is that a don’t-care value should be selected to reduce the number of gates or simplify the circuit.
Four-Input Karnaugh Maps
With four inputs A, B, C, and D, the truth table contains:
24=16input combinations.
A four-variable Karnaugh map contains sixteen cells. Each cell corresponds to one four-bit input word, which can also be interpreted as a decimal number from 0 through 15.
For example:
00002=010and:
11112=1510The output values are placed into the corresponding cells. Positive states are grouped into the largest possible groups, and don’t-care states may be included when they help create larger groups.
The source’s larger example produces terms corresponding to groups such as:
AB ABDand:
CThese terms are combined with OR to form the final function:
F=AB+ABD+CThe resulting circuit can be constructed from AND gates for the product terms and an OR gate to combine them. Negated variables require NOT gates.
Integrated Digital Circuits
Individual gates are useful building blocks, but a practical machine would become enormous if every function had to be constructed from separate gates. A robot, for example, might require many gates, multiplexers, and memory elements. Constructing all of these individually would lead to a large and inefficient system.
Integrated circuits, or ICs, solve this problem by placing many electronic components into a compact device. Instead of connecting every elementary gate manually, a designer can use an IC that already contains a more advanced function.
Microprocessors
A microprocessor is a programmable state machine. It retrieves instructions from memory, decodes them, and executes them.
A simplified instruction cycle is:
- Retrieve an instruction from memory.
- Decode what the instruction means.
- Obtain the data needed by the instruction.
- Perform the requested operation.
- Store or output the result.
- Continue with the next instruction.
Instructions are elementary operations, such as:
- Moving data
- Adding values
- Modifying bits
- Making decisions
- Accessing memory addresses
Data may represent either actual values or addresses that identify locations in memory.
A processor receives instructions telling it what to do and obtains the required data from memory. It then produces a result according to the instruction.
Although a mathematical operation may appear simple to a person, a processor performs it through a sequence of binary operations. For example, a calculation may require several individual steps because the processor works with logic states and binary representations.
Memory Systems
Memory stores digital information. Depending on the type of memory, data may be:
- Written
- Read
- Overwritten
- Written only once
Memory is divided into two broad groups: volatile and non-volatile.
Volatile Memory
Volatile memory loses its stored data when power is removed. RAM and cache are examples of volatile memory.
Volatile memory is useful when a processor needs rapid access to temporary data during operation. Its contents are active while the system is powered.
Non-Volatile Memory
Non-volatile memory retains data when the power source is turned off. ROM and flash memory are examples.
Non-volatile memory is appropriate for storing information that must remain available, such as programs, settings, or files.
The source presents a general trade-off between the two types:
- Volatile memory is typically faster but may have lower capacity for a given price.
- Non-volatile memory is typically slower but may offer greater capacity for a given price.
A digital system therefore commonly uses both:
- Non-volatile memory for permanent storage
- Fast volatile memory for active calculations and temporary data
Think About It
A processor needs working space while performing calculations, but a program must remain available after the device is switched off. Why would a practical system use both volatile and non-volatile memory?
Analog-to-Digital and Digital-to-Analog Conversion
The physical world is largely analog. Temperature, sound, light, pressure, voltage, and current vary continuously. Digital processors, however, operate using bits. Converters provide the connection between these two domains.
Analog-to-Digital Converter
An analog-to-digital converter, or ADC, measures an analog quantity such as voltage or current and represents it with a binary number.
For example, an input voltage of 2 V may be converted into a specific digital word.
The ADC must divide the input range into a finite number of levels. The digital output identifies which level is closest to the measured input.
Digital-to-Analog Converter
A digital-to-analog converter, or DAC, performs the reverse operation. It receives a binary number and produces a corresponding analog voltage or current.
A larger digital input produces a larger analog output within the converter’s allowed range.
Reference Voltage
The reference voltage, written as Vref, establishes the maximum range of the converter.
For a DAC:
- Vref is approximately the maximum output voltage.
- The maximum binary input produces the maximum corresponding output.
For an ADC:
- Vref is the maximum input voltage within the intended range.
- An input near Vref produces the maximum digital code.
Applying a voltage greater than the reference voltage may produce an incorrect result or damage the system.
Signal Conditioning
Sometimes the signal does not fit the converter’s allowed range. A signal may be too large, too small, noisy, or otherwise unsuitable. Signal conditioning modifies the signal so that it matches the converter’s requirements.
For example, if a signal is 7 V but the converter accepts a maximum of 5 V, a voltage divider can reduce the signal.
A voltage divider made from two resistors can produce:
Vout=VinR1+R2R2Using suitable resistor values, the 7 V input can be reduced to a voltage no greater than 5 V.
Signal conditioning is important because exceeding the converter’s allowed range may damage the input or cause the digital value to be clipped at its maximum.
Resolution
Resolution describes how finely a converter can represent the input range. It is determined by the number of bits.
An n-bit converter has:
2npossible digital states.
For an 8-bit converter:
28=256possible states exist.
For an ideal converter with reference voltage Vref, the approximate step size is:
ΔV≈2nVrefA larger number of bits creates more levels and therefore a smaller voltage step. This allows the converter to represent the analog signal more accurately.
Example: A 10-Bit, 5-Volt Converter
A 10-bit converter has:
210=1024states.
With a reference voltage of 5 V, the approximate step size is:
ΔV≈10245 V ΔV≈4.88 mVA digital code of 0 corresponds approximately to 0 V. A code of 512 is approximately halfway through the range and corresponds to about:
2.5 VThe exact code-to-voltage relationship depends on the converter’s design and endpoint convention, but the step-size idea explains how resolution works.
Conversion Time
The process of changing between analog and digital forms is not instantaneous. Conversion time is the time required for the converter to complete the change.
A converter with higher resolution often requires more time because it must distinguish between more levels. This produces a design trade-off:
- Higher resolution improves accuracy.
- Faster conversion improves response time.
- High resolution and high speed together may increase cost.
Modern technology can produce converters that are both fast and accurate, but such devices are generally more expensive.
Four-Bit Converter Example
A 4-bit converter has:
24=16possible states.
If the voltage range is from 0 V to 5 V, the approximate step size is:
ΔV=165 V=0.3125 VThus:
00002represents approximately 0 V, while:
00012represents approximately:
0.3125 VThe next code,
00102represents approximately:
2×0.3125 V=0.625 VAs the input voltage changes over time, an ADC repeatedly assigns each sampled voltage to one of these digital levels. A DAC reverses the process by turning each digital code into its corresponding voltage.
Microcontrollers: Complete Programmable Systems
A processor, memory, and converters can be combined with other peripherals to form a complete programmable device.
A microcontroller is an integrated circuit containing a microprocessor system together with memory and a collection of peripherals. These peripherals may allow the microcontroller to interact with the outside world through inputs, outputs, timers, communication interfaces, and analog converters.
The important advantage is programmability. A single physical device can perform different functions depending on the program stored in its memory. The mechanical structure does not need to be redesigned for every new behavior.
For example, the same microcontroller-based hardware could be programmed to:
- Read sensors
- Control motors
- Display information
- Communicate with another device
- Make decisions based on stored instructions
Earlier microcontrollers were limited by small memory capacity and modest processing power. Modern microcontrollers are much faster, include more memory, and provide many useful peripherals at an affordable price. This makes them one of the most widespread families of digital integrated circuits.
Comprehensive Review
Digital electronics differs from analog electronics because it represents information using a limited number of states rather than infinitely many possible values. This limitation makes digital systems more resistant to certain disturbances and improves repeatability.
A bit is a single binary value, either 0 or 1. A group of bits forms a word, and an n-bit word can represent 2n combinations. Binary numbers use powers of two, beginning with 20=1 at the rightmost position. Decimal-to-binary conversion can be performed by repeated division by 2 and reading the remainders in reverse order.
Boolean algebra describes two-state logic. AND produces 1 only when all inputs are 1; OR produces 1 when at least one input is 1; and NOT reverses the input. NAND, NOR, XOR, and XNOR extend these basic operations.
Multiplexers select one input from many, while demultiplexers direct one input toward a selected output. Combinational circuits depend only on current inputs. Sequential circuits also depend on stored internal state and may use a clock to synchronize changes.
Karnaugh maps simplify Boolean functions. Their Gray-code arrangement places related combinations next to one another, allowing neighboring 1s to be grouped. Larger groups eliminate more variables and produce circuits requiring fewer gates. Unused input combinations can be treated as don’t-care states when doing so creates a simpler circuit.
Integrated circuits combine many electronic components into compact functional devices. Microprocessors retrieve, decode, and execute instructions, while memory stores the data and programs they use. Volatile memory is fast but loses its contents without power; non-volatile memory retains data and is used for permanent storage.
ADCs convert physical analog quantities into binary values, while DACs convert binary values into analog voltages or currents. Reference voltage defines the operating range, resolution depends on the number of bits, and conversion time creates a trade-off between speed and accuracy. Microcontrollers combine processing, memory, and peripherals into programmable systems capable of performing many different tasks through software.

Ask anything
We've read this whole study set, so questions about it get the best answers.