There are two basic types of logic circuitry: combinational circuitry and state circuitry.

• Combinational circuitry behaves like a simple function. The output of combinational circuitry depends only on the current values of its input.
• State circuitry behaves more like an object method. The output of state circuitry does not just depend on its inputs — it also depends on the past history of its inputs. In other words, the circuitry has memory.

This is much like an object method whose value is dependent on the object's state: its instance variables.

Logic Circuits

Logic circuits use two different values of a physical quantity, usually voltage, to represent the boolean values true (or 1) and false (or 0). Logic circuits can have inputs and they have one or more outputs that are, at least partially, dependent on their inputs. In logic circuit diagrams, connections from one circuit's output to another circuit's input are often shown with an arrowhead at the input end.

In terms of their behavior, logic circuits are much like programming language functions or methods. Their inputs are analogous to function parameters and their outputs are analogous to function returned values. However, a logic circuit can have multiple outputs.

There are two basic types of logic circuitry: combinational circuitry and state circuitry.

• Combinational circuitry behaves like a simple function. The output of combinational circuitry depends only on the current values of its input.
• State circuitry behaves more like an object method. The output of state circuitry does not just depend on its inputs — it also depends on the past history of its inputs. In other words, the circuitry has memory.

This is much like an object method whose value is dependent on the object's state: its instance variables.

These two types of circuitry work together to make up a processor datapath.

Processor Datapath

A processor's datapath is conceptually organized into two parts:

• State elements hold information about the state of the processor during the current clock cycle. All registers are state elements.
• Combinational logic determines the state of the processor for the next clock cycle. The ALU is combinational logic.

This diagram, like most diagrams on this web site, adheres to the following conventions:

• Clock signals are colored orange.
• Control signals are colored blue.

Combinational Circuitry

The output of combinational circuitry depends only on the current values of its input. Combinational circuitry is conceptually constructed from basic logic gates: AND gates, OR gates, XOR gates, and inverters. The outputs of gates in combinational circuitry is never fed back directly to earlier inputs.

Basic logic gates can be combined to form a variety of higher-level units:

• Routing
• multiplexers — have several data input signals and a control input. The output is identical to one of the inputs. The value of the control signal determines which one.
• demultiplexers — have one data input signal, a control input and several output signals. All of the output signals are 0 (false) except for the one selected by the control input. The selected output is identical to the data input.
• Computational
• full adders — perform a single column of a binary addition. They are the primary building block for multi-bit adders and subtracters.
• adders and subtracters — add or subtract two binary or two's complement numbers. A subtracter is just an adder with extra circuitry to do a two's complement operation on one of the inputs. Usually they are designed to do either addition or subtraction as directed by a control signal.
• comparators — compare two binary or two's complement numbers.

Adders, subtracters, and comparators are not described here. They are described in Integer Addition and Subtraction.

State Circuitry

The output of state circuitry does not just depend on its input — it also depends on the past history of its inputs. In other words, the circuitry has memory.

State circuitry includes anything that can "remember" bits of information. This includes memory, registers, and the program counter.

The basic element of state circuitry is a flip-flop. A flip-flop stores one bit of data. Multiple flip-flops can be combined to form a multi-bit state element called a register. Multiple registers can be combined into a register bank.

Flip-Flops

The flip-flop is the basic element of state circuitry. It has three inputs:

• D - data to be written into the flip-flop
• En - enables data to be written into the flip-flop
• Cl - clock that determines when data is written into the flip-flop

A flip-flop has a single output:

• Q - data out, the most recent data value written into the flip-flop

Registers

A register is just a multi-bit analog of flip-flop. It has three inputs:

• D - data to be written into the register
• En - enables data to be written into the register
• Cl - clock that determines when data is written into the register

A register has a single output:

• Q - data out, the most recent data value written into the register

These are the same inputs and output that a flip-flop has. The only difference is that the `D` input and the `Q` output are multi-bit signals.

As shown to the left, a register is implemented as a group of flip-flops that share their clock and enable signals.

Register Implementation

A register is implemented as a group of flip-flops that share their clock and enable signals.

Processor Datapath Control

Processor datapath control signals can be classified according to which part of the processor they control:

• State controls
• Combinational controls

State Controls

All of the state elements are connected to the processor clock. Their state only changes at the start of a clock period. Control circuitry must generate the enable signals that control whether or not a state element changes state.

For example, many instructions write data to a destination register. The control signals need to enable a write to that register, but not enable a write to any of the other registers.

Combinational Logic Controls

The control signals for the combinational logic are frequently just controlling routing. Often these signals are applied to multiplexers.

For example, many instructions write a result to a register. A multiplexer is needed to select whether that data comes from a calculation (arithmetic and logic instructions) or from memory (load instructions).