# DigSim Assignment 2: A Finite State Machine

Also available in PDF.

### Objective

The objective of this assignment is to design and implement a simple finite state machine.

### Assignment

Design a finite state machine with two inputs X1 X0 and two outputs Z1, Z0. We will think of X1 X0 and Z1 Z0 also as unsigned 2-bit binary numbers. The output Z1 is 1 if X1 X0 as a binary number is less than the previous cycle's output Z1 Z0. If X1 X0 is greater than or equal to the previous Z1 Z0, then the output Z1 is 0. Similarly, Z0 is 1 if X1 X0 is greater than the previous Z1 Z0; and Z0 is 0 if X1 X0 is less than or equal to the previous Z1 Z0. Note that Z1 and Z0 are not complements of each other, since they can both be zero.

### Implementation Notes

1. You may assume that during the first cycle of operation that the "previous" outputs were zeroes.

2. Write out the truth table for a Boolean function with 4 inputs X1, X0 and Q1, Q0 and two outputs Z1, Z0 such that Z1 and Z0 are as defined above with Q1 and Q0 in place of the previous cycle's Z1 and Z0.

3. Produce the sum-of-products Boolean formulas for Z1 and Z0. Simplify the Boolean formulas for Z1 and Z0 using the properties of Boolean Algebra in Table A-1 of Murdocca & Heuring. (Dont expect a very simple result.)

4. Implement a combinational circuit in DigSim using the simplified Boolean formulas.

5. Transform the combinational circuit into a finite state machine by connecting the outputs Z1Z0 to the inputs Q1 Q0 through two D flip-flops. Recall that the D flip-flops have an output pin Q as well as the complement of Q. This might simplify your design somewhat.

6. Connect manual switches (powered & grounded) to the inputs X1 and X0. Use another manual switch to simulate a clock for the D flip-flops.

7. Test your finite state machine to make sure that it conforms to the specifications above.