Boolean Circuits · NAND Game: Memory (Optional)
Lesson 5
You are now able to store a single bit of data. In this task, you are required to combine two data flip-flops (DFFs) in order to store and retrieve two bits of data within a single operation. Ultimately, the objective is to store and retrieve \(16\)-bit words simultaneously; however, once the mechanism for storing two bits has been established, extending the construction to larger bit-widths becomes straightforward.
Problem. Construct a 2-bit register. It should work like a data flip-flop, except that two bits \(\texttt{d1}\) and \(\texttt{d0}\) are stored and output instead of one. The four input bits are \(\texttt{st}\), \(\texttt{d1}\), \(\texttt{d0}\), and \(\texttt{cl}\). The output of your circuit must be two bits, in the order \(\texttt{d1 d0}\).
Your circuit will be tested on many sequences of input tuples \(\texttt{(st,d1,d0,cl)}\). The clock behavior is the same as for a single-bit DFF:
- when \(\texttt{cl}\)=0, the inputs may change;
- when \(\texttt{cl}\) changes from \(0\) to \(1\), if \(\texttt{st}\)=1, then the current values of \(\texttt{d1}\) and \(\texttt{d0}\) are stored;
- when \(\texttt{cl}\) changes from \(1\) to \(0\), the previously stored two-bit value is output.
You may use only the following functions: \[\begin{aligned}\operatorname{DFF}(st,d,cl) &= \text{the DFF output}, \\ \operatorname{NAND}(a,b) &= \neg(a \land b), \\ \operatorname{INV}(a) &= \neg a, \\ \operatorname{AND}(a,b) &= a \land b, \\ \operatorname{OR}(a,b) &= a \lor b, \\ \operatorname{XOR}(a,b) &= a \oplus b.\end{aligned}\] For example, a line \(\texttt{x st d1 cl DFF}\) means that \(\texttt{x}\) is a new label equal to the current output of a single-bit DFF with inputs \(\texttt{st}\), \(\texttt{d1}\), and \(\texttt{cl}\).
The authors' solution uses \(2\) gates.