The registers and memory we’ve built only hold the values we put in; they don’t change on their own. Now that we have parts that remember, let’s build a machine that works on its own as long as it gets a clock. First, let’s split the circuits we’ve built so far into two kinds.
In an adder, a MUX, or a decoder, the output is decided by the current inputs alone. When the inputs change, the output changes right away, and nothing of the earlier inputs remains. Such a circuit is called a combinational logic circuit.
Latches and registers are different. Even with the same inputs, the output depends on what they remember. A circuit whose output is decided by the current inputs and a remembered value is called a sequential logic circuit, and the remembered value is called its state.
A useful sequential circuit usually has three parts: a register that holds the state, a combinational circuit that decides the next state from the current state and inputs, and a combinational circuit that decides the output from the current state. Each time the clock comes, the register takes the next state.
The simplest example is a circuit that counts. The next state is the current state + 1, and the output is the state itself, so there is no separate combinational circuit for the output.
Let’s start with the combinational circuit that decides the next state. Adding 1 can be done with half adders. We add 1 to the lowest digit C0, and each half adder’s CARRY passes the carry to the next digit.
Now let’s attach a 4-bit register to hold the state. Fold the circuit above into a “Next State” box, feed the register’s outputs into the box’s C3~C0, and feed the box’s N3~N0 back into the register. When the clock comes, the register takes N, and that value goes back into the box to make the next N. A circuit that goes up by 1 each clock is called a counter. Below is a 4-bit counter.
A real computer’s clock changes on its own billions of times per second, so a counter counts that fast too.
From now on, we’ll draw this circuit as a single COUNTER box. Each time CLK goes from 0 to 1, the value inside goes up by 1, and it sends that value out to the right.
A counter is the simplest sequential circuit: its next state is always + 1, and its output is the state itself. In the next post, let’s decide the next state and the output ourselves to build a traffic light.
The post's 4-bit counter starts at 0. If CLK goes from 0 to 1 twenty times, what number do C3~C0 show? Answer in decimal.