Digital Circuits and Binary Data
Digital Electronics Study Notes
Analog and Digital Systems
Analog electronics
In analog electronics, component values and signals can take any value within a continuous range. For example, a voltage could theoretically be 2.1 V, 2.15 V, or any other value in its permitted range.
This creates challenges:
Small changes caused by noise, temperature, component tolerances, or interference can affect the result.
Two supposedly identical analog circuits may not behave exactly alike.
Reproducing the same result reliably can be difficult.
Digital electronics
Digital electronics uses a limited number of distinct signal values. In the simplest digital systems, only two logic states are used:
Low, usually represented by 0 or false
High, usually represented by 1 or true
Because digital circuits distinguish between a small number of states, minor disturbances often do not change the interpreted value. This gives digital systems greater resistance to noise and generally improves repeatability.
Digital systems are easier to reproduce reliably because their signals are interpreted as discrete states rather than as infinitely many possible values.
Bits, Words, and Binary Numbers
Bits
A bit is the smallest unit of digital information. The word bit comes from binary digit.
A bit can have only two possible values:
0
1
A single bit can therefore represent one of two states. Digital devices, however, usually contain many inputs and outputs, so multiple bits are combined to represent more information.
Words
A group of bits is called a word. A word can represent a number, a character, an instruction, or another type of information.
The number of possible combinations depends on the number of bits:
One bit gives 2 combinations.
Two bits give 22=4 combinations.
Three bits give 23=8 combinations.
Eight bits give 28=256 combinations.
In general, a word containing n bits can represent:
different combinations.
Each bit position has a specific weight. The weight is determined by a power of 2.
Decimal and binary systems
The familiar decimal system uses ten digits, from 0 through 9. A decimal number’s position values are powers of 10:
For example, the decimal number 103 means:
A three-digit decimal number has 103=1000 possible combinations, ranging from 000 to 999.
Binary uses only two digits, 0 and 1. Its position values are powers of 2:
Reading from right to left, the first binary positions have the following weights:
Rightmost bit: 20=1
Next bit: 21=2
Next bit: 22=4
Next bit: 23=8
Next bit: 24=16
Next bit: 25=32
Next bit: 26=64
Next bit: 27=128
The rightmost bit is called the least significant bit, or youngest bit. The leftmost bit is the most significant bit.
Converting binary to decimal
To convert a binary word into decimal:
Identify the weight of each bit position.
Multiply each weight by the bit value, either 0 or 1.
Add the results.
For example, the eight-bit word 01100111 represents:
Therefore:
The most significant bit is 0 because 27=128, which is greater than 103.
Another example is 10011000:
Only the bits with value 1 contribute to the total.
Converting decimal to binary
The repeated-division method converts a decimal number to 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.
For 152:
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 upward gives:
Boolean Algebra and Logic Gates
Boolean algebra
Digital systems with two states are described using Boolean algebra. Boolean variables can have only two values:
True, usually represented by 1
False, usually represented by 0
The three fundamental Boolean operations are:
Logical product, corresponding to AND
Logical sum, corresponding to OR
Negation, corresponding to NOT
Truth tables
A truth table lists every possible combination of input states and shows the resulting output state.
Truth tables are useful because they provide a complete description of a logic operation. For a circuit with n binary inputs, the truth table contains:
possible input combinations.
AND gate
An AND gate performs logical conjunction, sometimes described as Boolean multiplication.
The output is 1 only when all inputs are 1.
For two inputs A and B:
A | B | AND output |
|---|---|---|
0 | 0 | 0 |
0 | 1 | 0 |
1 | 0 | 0 |
1 | 1 | 1 |
The Boolean expression is:
OR gate
An OR gate performs logical addition, also called logical alternative.
The output is 1 when at least one input is 1.
A | B | OR output |
|---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 1 |
The Boolean expression is:
The plus sign represents logical OR in this context, not ordinary arithmetic addition.
NOT gate
A NOT gate performs logical negation. It reverses the input state:
0 becomes 1
1 becomes 0
The negation of A can be written as A or ¬A.
A | NOT output |
|---|---|
0 | 1 |
1 | 0 |
Derived logic gates
More advanced gates are created by combining the basic operations.
NAND gate
A NAND gate is an AND gate followed by a NOT gate. Its output is false only when all inputs are true:
NOR gate
A NOR gate is an OR gate followed by a NOT gate. Its output is true only when all inputs are false:
XOR gate
An exclusive OR, or XOR, produces 1 when the inputs are different. For two inputs, it is true when exactly one input is true:
A | B | XOR output |
|---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
XNOR gate
An exclusive NOR, or XNOR, is the negation of XOR. It produces 1 when the inputs are equal:
Multiplexers and Demultiplexers
Multiplexer
A multiplexer, or MUX, has:
Multiple data inputs
One output
Address or selection lines
The selection lines determine which input is connected to the output. A multiplexer can therefore send one selected signal through a single communication line.
For example, a multiplexer can receive several data sources and transmit only the source whose address is selected.
Demultiplexer
A demultiplexer, or DEMUX, has:
One input
Multiple outputs
Address or selection lines
The address lines determine which output receives the input signal.
Relationship between address lines and inputs or outputs
If a device has n address lines, it can select among:
different inputs or outputs.
Multiplexers and demultiplexers are useful when several signals must share a communication path.
Combinational and Sequential Logic
Combinational systems
A combinational logic system has an output that depends only on the current input values.
Examples include:
AND, OR, and NOT circuits
Multiplexers
Demultiplexers
Arithmetic logic circuits
If the inputs change, the output changes according to the circuit’s logic function. The previous history of the circuit does not affect the result.
Sequential systems and triggers
A sequential logic system has an output that depends on:
The current input values
The system’s internal state
Often, the previous input or output history
Such systems are commonly built from logic gates and memory elements. The source refers to these memory elements as triggers, which correspond to devices such as latches and flip-flops.
Triggers are used to:
Store a current state
Remember information
Synchronize state changes with a clock signal
A clock provides regularly timed transitions, allowing a sequential circuit to update its state in a controlled way.
Combinational logic calculates from current inputs; sequential logic also remembers a previous state.
Karnaugh Maps and Logic Optimization
Purpose of Karnaugh maps
A complex logic device may require many gates if its function is implemented directly from a complete truth table. The Karnaugh map, or K-map, is a graphical method for simplifying Boolean expressions.
The goals of K-map simplification are to:
Reduce the number of logic gates
Reduce the number of inputs required by each gate
Make the circuit smaller and less expensive
Improve speed and efficiency
Reduce power consumption and wiring complexity
Structure of a Karnaugh map
A Karnaugh map contains one cell for each possible combination of input values.
For:
Three inputs, the map has 23=8 cells.
Four inputs, the map has 24=16 cells.
Rows and columns are labeled using Gray code. In Gray code, adjacent labels differ in only one bit. This makes it possible to group neighboring cells whose Boolean terms differ by only one variable.
Each cell contains the output value corresponding to a particular input combination:
1 means the function is true for that combination.
0 means the function is false.
An unknown or unused combination may be marked as a don’t-care condition.
Boolean notation
A variable without negation represents the true or positive form:
A variable with negation represents the false or complemented form:
For example:
A means A=1.
A means A=0.
A⋅B means both A and B are true.
A+B means A or B is true.
Grouping rules
To simplify a Karnaugh map:
Place the output values in the appropriate cells.
Group adjacent cells containing 1s.
Make each group as large as possible.
Groups should contain 1, 2, 4, 8, or another power-of-two number of cells.
Variables that change within a group are eliminated.
Variables that remain constant appear in the simplified term.
Combine the resulting terms using OR.
Groups may often wrap around the edges of the map because the edges are logically adjacent.
Three-input example
Suppose a three-input device uses inputs A, B, and C. There are:
possible input combinations.
The cells are associated with the binary input combinations from 000 through 111, corresponding to decimal values from 0 through 7.
If two adjacent cells containing 1s differ only in the value of A, then A is eliminated from the simplified expression. The resulting term depends only on the variables that remain unchanged.
For example:
If A changes while B=1 and C=0 remain constant, the group simplifies to BC.
If a group contains cells where A=0 and B=1, while C changes, the group simplifies to AB.
A larger group produces a shorter expression because more variables are eliminated.
Converting the simplified expression into a circuit
A simplified sum-of-products expression can be implemented using:
NOT gates to create complemented inputs.
AND gates to create each product term.
An OR gate to combine the product terms.
For example, an expression of the form:
requires:
A NOT gate to produce A
One AND gate for AB
One AND gate for BC
One OR gate to combine the two terms
Don’t-care conditions
A don’t-care condition represents an input combination that does not occur or whose output is irrelevant.
It can be treated as either 0 or 1, depending on which choice produces a simpler circuit.
If treating a don’t-care cell as 1 allows two neighboring 1s to form a larger group, the resulting expression may become much shorter. For example:
Without using the don’t-care condition, the function may require AB.
If the don’t-care is treated as 1, the group may simplify to only A.
Using don’t-care conditions can reduce the required number of gates.
Four-input example
With four inputs A, B, C, and D, there are:
possible input combinations. The Karnaugh map therefore contains sixteen cells, representing binary values from 0000 through 1111, or decimal values from 0 through 15.
The positive output states are grouped into large adjacent regions. In the example described, the simplified function contains terms corresponding to:
A group represented by AB
A group represented by ABD
A large group represented by C
The resulting expression has the general form:
The exact grouping depends on the values placed in the map. The important principle is that larger groups produce fewer variables and simpler hardware.
Integrated Digital Circuits
Need for integration
A large digital system built from individual gates, multiplexers, and triggers could require a very large number of separate components. Such a system would be:
Physically large
Difficult to wire
Less efficient
More expensive
More difficult to maintain
Integrated circuits, or ICs, place many electronic components and logic functions on a single semiconductor chip.
Integrated circuits provide compact functional blocks that can perform complex operations while reducing wiring and improving reliability.
Microprocessors
A microprocessor is a programmable digital system that performs instructions using binary logic.
It can be viewed as a state machine that repeatedly:
Retrieves an instruction from memory.
Decodes the instruction.
Retrieves any required data.
Performs the requested operation.
Stores or outputs the result.
Moves to the next instruction.
Instructions and data
Processor instructions are elementary operations such as:
Moving data
Adding values
Comparing values
Setting or clearing bits
Making decisions
Jumping to another part of a program
Data may consist of:
Numerical values
Bit patterns
Addresses identifying locations in memory
A microprocessor receives instructions that specify what to do and obtains the data on which those instructions operate.
Binary arithmetic
Microprocessors use logic states and therefore represent arithmetic using binary operations. Even complicated mathematical calculations are carried out as sequences of simpler operations.
For example, a processor may need several individual steps to:
Add two numbers
Shift a bit
Compare two values
Store an intermediate result
Continue the calculation in the correct order
The order of these operations is important because complex calculations are built from simpler binary instructions.
Memory
Memory stores digital information for later use. Depending on its type, memory can allow data to be:
Written
Read
Overwritten
Written only once
Volatile memory
Volatile memory loses its stored data when the power supply is removed.
Examples include:
RAM
Cache memory
Volatile memory is generally fast and is used while the processor is actively performing operations.
Typical uses include:
Holding currently running programs
Storing temporary results
Keeping data immediately needed by the processor
Non-volatile memory
Non-volatile memory retains its data even when power is removed.
Examples include:
ROM
Flash memory
Non-volatile memory is useful for permanent or long-term storage, including:
Program instructions
Configuration data
Stored user information
The source describes non-volatile memory as generally slower but capable of providing greater capacity for a similar cost.
Memory trade-offs
A system often balances speed, capacity, and cost:
Fast volatile memory may have lower capacity.
Slower non-volatile memory may have greater capacity.
Volatile memory is used for active processing.
Non-volatile memory is used for retaining information.
Fast volatile memory supports calculations and program execution, while non-volatile memory preserves data and programs.
Analog-to-Digital and Digital-to-Analog Conversion
Digital systems process bits, while many physical signals—such as temperature, sound, light, and electrical voltage—are analog. Converters allow analog and digital systems to interact.
Analog-to-digital converter
An analog-to-digital converter, or ADC, measures an analog voltage or current and represents it as a digital number.
For example, an ADC could convert an input of 2 V into a binary code.
The conversion process involves:
Measuring the analog input.
Comparing it with a set of discrete levels.
Selecting the digital code corresponding to the nearest level.
Digital-to-analog converter
A digital-to-analog converter, or DAC, converts a digital code into an analog voltage or current.
For example, a DAC could receive a binary number and produce a proportional output voltage.
DACs are used when a digital system must control or generate a physical analog signal.
Reference Voltage and Signal Conditioning
Reference voltage
The reference voltage defines the operating range of a converter.
For a DAC:
The reference voltage is approximately the maximum output voltage.
The maximum digital input code produces the maximum output voltage.
For an ADC:
The reference voltage is approximately the maximum input voltage that can be converted within the selected range.
An input at or near the reference voltage produces the maximum digital code.
Applying a voltage greater than the permitted reference range can:
Produce an incorrect measurement
Cause saturation
Damage the converter or related circuitry
Signal conditioning
Signal conditioning modifies a signal so that it fits the converter’s safe and useful input range.
Common signal-conditioning methods include:
Voltage division
Amplification
Attenuation
Filtering
Level shifting
Protection against excessive voltage
For example, if a converter accepts a maximum of 5 V but the signal is 7 V, a voltage divider can reduce the signal before it reaches the converter.
A voltage divider made from two resistors produces an output voltage determined by:
The resistor values must be selected so that the converter input never exceeds its safe range. Signal conditioning is also important when a signal is too small to use the converter’s available resolution effectively.
Converter Resolution
Resolution indicates how many discrete levels a converter can represent. It is determined by the number of bits.
An n-bit converter has:
possible digital states.
Examples
An eight-bit converter has:
possible states.
A ten-bit converter has:
possible states.
If a ten-bit converter has a reference voltage of 5 V, the approximate voltage step is:
Thus:
Digital code 0 corresponds approximately to 0 V.
A code near 512 corresponds approximately to half the reference voltage, or 2.5 V.
The maximum code corresponds approximately to the upper end of the input range.
A higher bit count gives smaller voltage steps and therefore better ability to distinguish nearby voltage values.
Quantization
Because an ADC represents a continuous voltage using discrete codes, the measured value is rounded to the nearest available level. This difference between the actual analog value and the represented value is called quantization error.
Higher resolution reduces the size of each step and usually reduces quantization error.
Conversion Time and Speed
Conversion time is the time required for an ADC or DAC to change between values or complete a conversion.
Converter speed is affected by:
Resolution
Internal circuit design
Required accuracy
Sampling and processing requirements
There is often a trade-off:
Higher resolution generally requires more processing and may be slower.
Faster conversion may require lower resolution or more expensive hardware.
High-resolution, high-speed converters are available, but they are typically more costly.
The design must therefore balance:
Accuracy
Speed
Cost
Power consumption
Discrete voltage example
Suppose a converter operates from 0 V to 5 V and uses four bits. It has:
possible states.
The approximate voltage interval per state is:
Under the simplified level interpretation:
Binary code 0001 corresponds to approximately 0.3125 V.
Binary code 0010 corresponds to approximately 0.625 V.
The exact endpoint convention depends on the converter design, but the central idea is that each additional digital code corresponds to a discrete voltage level.
Microcontrollers
A microcontroller combines several digital-system components into one integrated circuit. It typically includes:
A microprocessor core
Memory
Input and output interfaces
Timers and counters
Communication peripherals
Analog-to-digital converters
Other specialized peripherals
A microcontroller can be programmed to perform different functions without changing the physical hardware.
For example, the same microcontroller-based device could perform different operations depending on the program stored in its memory.
Advantages of microcontrollers
Microcontrollers make it possible to build systems that are:
Compact
Programmable
Flexible
Relatively inexpensive
Capable of controlling many external devices
They are used in appliances, robots, measurement systems, vehicles, industrial controllers, and many other embedded systems.
Modern microcontrollers generally provide much greater performance, memory capacity, and peripheral functionality than earlier generations while remaining affordable.
Key Relationships
Bits are individual binary values; words are groups of bits.
The number of states in an n-bit word is 2n.
Boolean algebra describes operations on binary states.
Logic gates implement Boolean operations.
Combinational circuits depend only on current inputs.
Sequential circuits also depend on stored internal state.
Karnaugh maps simplify Boolean expressions and reduce hardware complexity.
Microprocessors execute instructions and process binary data.
Memory stores instructions and data.
ADC circuits convert analog signals into digital codes.
DAC circuits convert digital codes into analog signals.
Reference voltage establishes a converter’s operating range.
Resolution determines the number and spacing of available digital levels.
Conversion time measures how quickly a converter changes or completes a conversion.
Microcontrollers combine processing, memory, and peripherals into one programmable integrated circuit.

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