# Combinational Logic Design

> In this chapter, we will focus on the **Logic** and **Digital Circuits** level abstraction.

## Introduction

In digital electronics, a *circuit* is a network that processes discrete-valued variables. And a circuit can be viewed as a black box, shown in Figure 2.1, with

* one or more discrete-valued *input terminals*
* one or more discrete-valued *output terminals*
* a *functional specification* describing the relationship between inputs and outputs
* a *timing specification* describing the delay between inputs changing and outputs responding.

<figure><img src="https://4009084806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjTJFBPtKk6NwweAooH53%2Fuploads%2FMJn3187VvFwbZNAriGSU%2Fimage.png?alt=media&#x26;token=3fa16e63-ee2c-4471-a656-47ef091d1e41" alt="" width="563"><figcaption></figcaption></figure>

Peering inside the black box, circuits are composed of nodes and elements.

* An *element* is itself a circuit with inputs, outputs, and a specification.
* A *node* is a wire, whose voltage conveys a discrete-valued variable. Nodes are classfied as *input, output,* or *internal*.
  * Inputs receive values from the external world.
  * Outputs deliver values to the external world.
  * Wires that are not inputs and outputs are called internal nodes.

Figure 2.2 illustrates a circuit with three elements, E1, E2 and E3, and six nodes, Nodes A, B, and C are inputs. Y and Z are outputs. n1 is an internal node between E1 and E3.

<figure><img src="https://4009084806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FjTJFBPtKk6NwweAooH53%2Fuploads%2FRdnA2v9gRjfUazRCu6Qn%2Fimage.png?alt=media&#x26;token=6b259c56-fb75-46a6-8452-411105d7c55c" alt="" width="383"><figcaption></figcaption></figure>

## Combinational vs. Sequential Circuits

Digital circuits are classified as *combinational* or *sequential.*

* A *combinational circuit*'s outputs depend **only** on the current values of the inputs; in other words, it combines the current input values to compute the output. For example, a logic gate is a combinational circuit.
* A *sequential circuit's* outputs depend on both current and previous values of the inputs (which you will see later, this is called the *current state*); in other words, it depends on the input sequence.

A combinational circuit is *memoryless*, but a sequential circuit has *memory*.

## Rules of Combinational Composition

This rule states that

> We can build a large combinational circuit from smaller combinational circuit elements.

A circuit is combinational if it consists of interconnected circuit elements such that

* Every circuit element is itself **combinational**.
* Every node of the circuit is either designated as **an input** to the circuit or connects to **exactly one output** terminal of a circuit element.
* The circuit contains **no cyclic paths**: every path through the circuit visits each circuit node at most once.

## Sum up

Large circuits such as microprocessors can be very complicated, so we use the principles from the [last chapter](https://wenbo-notes.gitbook.io/ddca-notes/textbook/from-zero-to-one) to manage the complexity. Viewing a circuit as a black box with a well-defined interface and function is an application of **abstraction** and **modularity**. Building the circuit out of smaller circuit elements is an application of **hierarchy**. The rules of combinational composition are an application of discipline.

* The *function specification* of a combinational circuit expresses the output values in terms of the current input values. And it is usually expressed as a truth table or a Boolean equation.
* The *timing specification* of a combinational circuit consists of lower and upper bounds on the delay from input to output.
