Image of eBits Academy fundamentals illustration

Introduction to Digital Circuits

  • March 08, 2023
  • |
  • Jonas Rothausen

Introduction


Computers think in a rather funny way. They think in binary, so all they think about is 0s and 1s. In digital circuits, binary means a system for representing information or data with only two possible values or states. These are typically represented as 0 and 1, corresponding to “off” and “on” states in a digital circuit.

Digital circuits, such as those in microcontrollers, use binary signals to communicate and process data. Binary signals are created by manipulating the voltage levels of electrical signals passing through the circuit.

For example, a microcontroller can use a binary signal to control an LED. A binary value of 1 can switch the LED on, while a value of 0 switches it off.

Binary Numbers


Binary data also represents numbers in digital circuits. Each binary digit can only be 0 or 1. How can you count using only 0 and 1? It is actually like counting in decimal, except binary has only two possible values!

Let’s learn to count to 15 in binary.
To count to 15 in binary, we need 4 positions for our 0s and 1s. We start with zero in every position, [0 0 0 0], which equals 0. So far, so good! Changing the rightmost digit to 1 gives [0 0 0 1], representing 1 in binary.

What about 2? We move the 1 one position left: [0 0 1 0]. The rightmost position now holds 0, as it did when representing zero. Changing that position to 1 counts up by one, so 3 is [0 0 1 1]. For 4, we cannot simply flip a 0 to 1 to count up: we replace the 1s in the fourth and third positions with 0 and put 1 in the second position. Thus 4 is [0 1 0 0]. (This is also the method we used when counting from 1 to 2.) This is how to count in binary. Try it yourself and see whether you understand the binary numbers in Figure 1:


Figure 1: Decimal numbers and their corresponding binary representations up to 15.

You may have guessed that representing a number greater than 15 requires more than 4 digit positions. This is how a computer counts and essentially receives and supplies all information, from screen pixels to the most complex calculations in your favourite computer game! Let’s just say computers count binary numbers very quickly.

 

Logic Gates


Logic gates are the basic building blocks of digital circuits. Like Lego, we can combine them in different structures for different purposes. Some gates are called AND, OR, NOT, NAND, NOR, XOR and XNOR.

The illustrated gates have two inputs and one output, except NOT, which has one input. Gates with more inputs also exist. NOT is also called an inverter because it changes 1s to 0s and vice versa. Each gate has a symbol representing it in digital circuits; see Figure 2:

Figure 2: Logic gates. The two lines entering from the left represent the inputs. The single line on the right is the output.



An AND gate only produces logic 1 when all inputs are logic 1. A gate’s output of 0 or 1 depends on the combination of its two inputs. Here are the combinations for the other gates mentioned:

OR: Produces logic 1 when at least one input is logic 1.

NOT: Produces the complement of its input: logic 1 becomes logic 0 and vice versa.

NAND: Combines AND and NOT. It only produces logic 0 when all inputs are logic 1.

NOR: Combines OR and NOT. It only produces logic 1 when all inputs are logic 0.

XOR: Produces logic 1 when exactly one of its two inputs is logic 1.

XNOR: Combines XOR and NOT. It produces logic 1 when its two inputs are the same.

Combining these gates in a digital circuit lets it make decisions based on the digital input signals. Using fewer gates can reduce area and power, but timing and reliability also depend on the implementation. Boolean algebra provides mathematical methods for simplifying logic expressions while preserving the required function.

 

 

Boolean Algebra

Let’s explore the AND gate further. Figure 3 below shows a circuit implementing an AND gate.


Figure 3: Illustrates an AND-gate circuit.
Voltage sources: Vin, A and B
Transistors: T1 and T2
Resistors: Ra, Rb and Rout


In the blog about [analogue circuits] we learned how transistor switches work. In the conceptual example, a 5 V supply is connected to T1 at Vin, while A and B control the transistors. With either transistor off, the output Vout is low. When both conduct, the output can be high. A real transistor circuit does not automatically output exactly 5 V: voltage drops, load and drive conditions matter. The figures illustrate logical behaviour and do not replace a complete electrical design.


Figure 4: The idealised AND behaviour gives a high output only when both A and B are high.

 

Digital electronics distinguishes high and low, or 1 and 0. Replacing the example’s 5 V and 0 V labels with 1s and 0s produces what are called truth tables. This is the beginning of digital electronics.

Figure 5: Truth table for an AND gate.

 

Truth tables can be described by equations. Every gate has a truth table and its own equation, although the mathematics of digital electronics differs from ordinary arithmetic. As mentioned earlier, it is called Boolean algebra.

 

Imagine a fairly complex digital circuit such as the one below. It has three inputs, A, B and C, and one output, Z.

Figure 6: A digital circuit.
Inputs: A, B and C
Output: Z

 

It may look clever and practical, but perhaps we can improve it. How? By using Boolean algebra. We start by writing the Boolean expression for Figure 6.


The expression for the circuit above is:

Figure 7: Boolean expression for the circuit in Figure 6.

 

Next, Boolean algebra reduces the complex expression to its simplest form.


Figure 8: Different expressions derived using Boolean algebra. Each describes the circuit in Figure 6.

 

All the expressions above are equivalent. Each can describe a different circuit construction, but all these circuits do exactly the same thing. Their behaviour can therefore be described by the same truth table below.

Figure 9: Truth table for the circuit in Figure 6 and all expressions in Figure 8.

 

We started with the large, complex circuit in Figure 6 and used Boolean algebra to reduce it to one with the same truth table but 2 gates instead of 7.

Figure 10: The reduced circuit from Figure 6.

The reduced circuit needs fewer components, which can reduce cost, power and delay. Actual timing and reliability must still be checked. This is why Boolean algebra is a powerful tool for designing digital circuits and computers.

 

 

Laws of Boolean Algebra

To use this useful tool, we need to learn its laws. That takes some practice, because there are quite a few:

  • Annulment
  • Identity
  • Idempotence
  • Complement
  • Double Negation
  • De Morgan’s Law
  • Associativity
  • Commutativity
  • Distributivity
  • Absorption

 

If you are ready to deepen your understanding of digital circuits by learning more Boolean algebra, this site is a good starting point. It explains everything from the basics and then gives a few Boolean algebra examples.

Computers often retain information about digital circuit operations in memory elements and registers.


Memory Elements and Registers
These circuits store binary information. Registers and memories such as RAM, ROM and EPROM have different structures and purposes. Think of a library that categorises and stores information in particular sections so it can be found and used easily. Designing such storage requires understanding digital logic and control. Why store data? We may want to process, compare or share information in memory elements and registers. This involves sequential circuits.

 

Sequential Circuits

Sequential circuits contain state: their outputs depend on inputs and stored previous information. Synchronous circuits update state according to a clock; asynchronous circuits do not require a common clock. They help organise sequences of operations and can be grouped into these two types.

 

Synchronous Sequential Circuits
In synchronous sequential circuits, state elements such as flip-flops update on specified clock edges. Combinational logic calculates next-state values and outputs from current inputs and stored state. The design must satisfy timing requirements so values are sampled reliably.

Asynchronous Sequential Circuits
Asynchronous sequential circuits change state without a common clock, in response to input changes and internal timing. They still contain state and may use feedback; they are not purely combinational circuits. Their current behaviour depends on inputs and previous state, so timing and hazards require careful design.

Arithmetic Circuits
These circuits perform arithmetic operations such as addition, subtraction, multiplication and division.

 

Data Converters

Data converters change digital signals to analogue signals and vice versa, including ADCs and DACs. They are useful for connecting the real analogue world to the digital world—think of them as translators. Ever wondered how a thermostat knows and displays the temperature? It measures temperature with a sensor and maps that reading through its calculations to display the correct temperature digitally.

Leave a comment

Please note, comments need to be approved before they are published.