1. Home
  2. Explore
  3. Computer Science
  4. Digital Circuits and Binary Data

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

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 V2.1\ \text{V}2.1 V, 2.15 V2.15\ \text{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 000 or false

  • High, usually represented by 111 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:

  • 000

  • 111

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 222 combinations.

  • Two bits give 22=42^2 = 422=4 combinations.

  • Three bits give 23=82^3 = 823=8 combinations.

  • Eight bits give 28=2562^8 = 25628=256 combinations.

In general, a word containing nnn bits can represent:

2n2^n2n

different combinations.

Each bit position has a specific weight. The weight is determined by a power of 222.

Decimal and binary systems

The familiar decimal system uses ten digits, from 000 through 999. A decimal number’s position values are powers of 101010:

100, 101, 102, 103,…10^0,\ 10^1,\ 10^2,\ 10^3,\ldots100, 101, 102, 103,…

For example, the decimal number 103103103 means:

103=1×100+0×10+3×1103 = 1 \times 100 + 0 \times 10 + 3 \times 1103=1×100+0×10+3×1

A three-digit decimal number has 103=100010^3 = 1000103=1000 possible combinations, ranging from 000000000 to 999999999.

Binary uses only two digits, 000 and 111. Its position values are powers of 222:

20, 21, 22, 23,…2^0,\ 2^1,\ 2^2,\ 2^3,\ldots20, 21, 22, 23,…

Reading from right to left, the first binary positions have the following weights:

  • Rightmost bit: 20=12^0 = 120=1

  • Next bit: 21=22^1 = 221=2

  • Next bit: 22=42^2 = 422=4

  • Next bit: 23=82^3 = 823=8

  • Next bit: 24=162^4 = 1624=16

  • Next bit: 25=322^5 = 3225=32

  • Next bit: 26=642^6 = 6426=64

  • Next bit: 27=1282^7 = 12827=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:

  1. Identify the weight of each bit position.

  2. Multiply each weight by the bit value, either 000 or 111.

  3. Add the results.

For example, the eight-bit word 011001110110011101100111 represents:

0×128+1×64+1×32+0×16+0×8+1×4+1×2+1×10 \times 128 + 1 \times 64 + 1 \times 32 + 0 \times 16 + 0 \times 8 + 1 \times 4 + 1 \times 2 + 1 \times 10×128+1×64+1×32+0×16+0×8+1×4+1×2+1×1

Therefore:

011001112=64+32+4+2+1=1031001100111_2 = 64 + 32 + 4 + 2 + 1 = 103_{10}011001112​=64+32+4+2+1=10310​

The most significant bit is 000 because 27=1282^7 = 12827=128, which is greater than 103103103.

Another example is 100110001001100010011000:

100110002=128+16+8=1521010011000_2 = 128 + 16 + 8 = 152_{10}100110002​=128+16+8=15210​

Only the bits with value 111 contribute to the total.

Converting decimal to binary

The repeated-division method converts a decimal number to binary:

  1. Divide the decimal number by 222.

  2. Record the remainder, which is always 000 or 111.

  3. Divide the quotient by 222 again.

  4. Continue until the quotient becomes 000.

  5. Read the remainders from bottom to top.

For 152152152:

Division

Quotient

Remainder

152÷2152 \div 2152÷2

767676

000

76÷276 \div 276÷2

383838

000

38÷238 \div 238÷2

191919

000

19÷219 \div 219÷2

999

111

9÷29 \div 29÷2

444

111

4÷24 \div 24÷2

222

000

2÷22 \div 22÷2

111

000

1÷21 \div 21÷2

000

111

Reading the remainders upward gives:

15210=100110002152_{10} = 10011000_215210​=100110002​

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 111

  • False, usually represented by 000

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 nnn binary inputs, the truth table contains:

2n2^n2n

possible input combinations.

AND gate

An AND gate performs logical conjunction, sometimes described as Boolean multiplication.

The output is 111 only when all inputs are 111.

For two inputs AAA and BBB:

AAA

BBB

AND output

000

000

000

000

111

000

111

000

000

111

111

111

The Boolean expression is:

Y=A⋅BY = A \cdot BY=A⋅B

OR gate

An OR gate performs logical addition, also called logical alternative.

The output is 111 when at least one input is 111.

AAA

BBB

OR output

000

000

000

000

111

111

111

000

111

111

111

111

The Boolean expression is:

Y=A+BY = A + BY=A+B

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:

  • 000 becomes 111

  • 111 becomes 000

The negation of AAA can be written as A‾\overline{A}A or ¬A\neg A¬A.

AAA

NOT output

000

111

111

000

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:

Y=A⋅B‾Y = \overline{A \cdot B}Y=A⋅B

NOR gate

A NOR gate is an OR gate followed by a NOT gate. Its output is true only when all inputs are false:

Y=A+B‾Y = \overline{A + B}Y=A+B​

XOR gate

An exclusive OR, or XOR, produces 111 when the inputs are different. For two inputs, it is true when exactly one input is true:

Y=A⊕BY = A \oplus BY=A⊕B

AAA

BBB

XOR output

000

000

000

000

111

111

111

000

111

111

111

000

XNOR gate

An exclusive NOR, or XNOR, is the negation of XOR. It produces 111 when the inputs are equal:

Y=A⊕B‾Y = \overline{A \oplus B}Y=A⊕B​

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 nnn address lines, it can select among:

2n2^n2n

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=82^3 = 823=8 cells.

  • Four inputs, the map has 24=162^4 = 1624=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:

  • 111 means the function is true for that combination.

  • 000 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:

AAA

A variable with negation represents the false or complemented form:

A‾\overline{A}A

For example:

  • AAA means A=1A = 1A=1.

  • A‾\overline{A}A means A=0A = 0A=0.

  • A⋅BA \cdot BA⋅B means both AAA and BBB are true.

  • A+BA + BA+B means AAA or BBB is true.

Grouping rules

To simplify a Karnaugh map:

  1. Place the output values in the appropriate cells.

  2. Group adjacent cells containing 111s.

  3. Make each group as large as possible.

  4. Groups should contain 111, 222, 444, 888, or another power-of-two number of cells.

  5. Variables that change within a group are eliminated.

  6. Variables that remain constant appear in the simplified term.

  7. 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 AAA, BBB, and CCC. There are:

23=82^3 = 823=8

possible input combinations.

The cells are associated with the binary input combinations from 000000000 through 111111111, corresponding to decimal values from 000 through 777.

If two adjacent cells containing 111s differ only in the value of AAA, then AAA is eliminated from the simplified expression. The resulting term depends only on the variables that remain unchanged.

For example:

  • If AAA changes while B=1B = 1B=1 and C=0C = 0C=0 remain constant, the group simplifies to BC‾B\overline{C}BC.

  • If a group contains cells where A=0A = 0A=0 and B=1B = 1B=1, while CCC changes, the group simplifies to A‾B\overline{A}BAB.

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:

  1. NOT gates to create complemented inputs.

  2. AND gates to create each product term.

  3. An OR gate to combine the product terms.

For example, an expression of the form:

Y=A‾B+BCY = \overline{A}B + BCY=AB+BC

requires:

  • A NOT gate to produce A‾\overline{A}A

  • One AND gate for A‾B\overline{A}BAB

  • One AND gate for BCBCBC

  • 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 000 or 111, depending on which choice produces a simpler circuit.

If treating a don’t-care cell as 111 allows two neighboring 111s 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 A‾B\overline{A}BAB.

  • If the don’t-care is treated as 111, the group may simplify to only A‾\overline{A}A.

Using don’t-care conditions can reduce the required number of gates.

Four-input example

With four inputs AAA, BBB, CCC, and DDD, there are:

24=162^4 = 1624=16

possible input combinations. The Karnaugh map therefore contains sixteen cells, representing binary values from 000000000000 through 111111111111, or decimal values from 000 through 151515.

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 ABABAB

  • A group represented by A‾ B‾ D‾\overline{A}\,\overline{B}\,\overline{D}ABD

  • A large group represented by CCC

The resulting expression has the general form:

Y=AB+A‾ B‾ D‾+CY = AB + \overline{A}\,\overline{B}\,\overline{D} + CY=AB+ABD+C

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:

  1. Retrieves an instruction from memory.

  2. Decodes the instruction.

  3. Retrieves any required data.

  4. Performs the requested operation.

  5. Stores or outputs the result.

  6. 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 V2\ \text{V}2 V into a binary code.

The conversion process involves:

  1. Measuring the analog input.

  2. Comparing it with a set of discrete levels.

  3. 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 V5\ \text{V}5 V but the signal is 7 V7\ \text{V}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:

Vout=VinR2R1+R2V_{\text{out}} = V_{\text{in}} \frac{R_2}{R_1 + R_2}Vout​=Vin​R1​+R2​R2​​

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 nnn-bit converter has:

2n2^n2n

possible digital states.

Examples

An eight-bit converter has:

28=2562^8 = 25628=256

possible states.

A ten-bit converter has:

210=10242^{10} = 1024210=1024

possible states.

If a ten-bit converter has a reference voltage of 5 V5\ \text{V}5 V, the approximate voltage step is:

ΔV=5 V1024≈4.88 mV\Delta V = \frac{5\ \text{V}}{1024} \approx 4.88\ \text{mV}ΔV=10245 V​≈4.88 mV

Thus:

  • Digital code 000 corresponds approximately to 0 V0\ \text{V}0 V.

  • A code near 512512512 corresponds approximately to half the reference voltage, or 2.5 V2.5\ \text{V}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 V0\ \text{V}0 V to 5 V5\ \text{V}5 V and uses four bits. It has:

24=162^4 = 1624=16

possible states.

The approximate voltage interval per state is:

ΔV=5 V16=0.3125 V\Delta V = \frac{5\ \text{V}}{16} = 0.3125\ \text{V}ΔV=165 V​=0.3125 V

Under the simplified level interpretation:

  • Binary code 000100010001 corresponds to approximately 0.3125 V0.3125\ \text{V}0.3125 V.

  • Binary code 001000100010 corresponds to approximately 0.625 V0.625\ \text{V}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 nnn-bit word is 2n2^n2n.

  • 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.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent