Mealy machine to detect sequence of 2 inputs

flipflopmultiplexer

I have the following assignment for a project at college and I have a few questions regarding it.

You are to design a Mealy state diagram for a digital lock. Assume that two debounced push-buttons, A and B, are available to enter the combination. An electromechanical interlock guarantees that the buttons cannot be activated simultaneously. The lock should have the following features:

The combination is A-A-B-A-B-A. If this sequence is correctly entered, an output signal is asserted that causes the lock to open.

For any state, three B pulses in a row should guarantee to reset the control to its initial state.

When any out-of-sequence use of the A push-button occurs, an output is asserted that rings a bell to warn that the lock is being tampered with.

Once the lock is open, pressing either A or B will cause the lock to close without signaling an error. Draw a Mealy state diagram for this finite state machine. Indicate what each state represents and what input conditions cause state and output changes. Not everything may have been specified, so write down any assumptions you make.

I have to implement this using only MUX'es and JK flip-flops. My progress so far:

-I have 10 states the machine can be in:

S0 -> nothing happened yet

S1 -> input = A

S2 -> input = AA

S3 -> input = AAB

S4 -> input = AABA

S5 -> input = AABAB

S6 -> input = AABABA (the output should be 1 when we get to this state)

S7 -> input = B

S8 -> input = BB

S9 -> input = A(this would set off the alarm)

-I now have to use 4 JK flip-flops(since the states would be written as Q3,Q2,Q1,Q0) so I have a giant truth table for the current state(Q3,2,1,0), input(A and B), next state and each JK flip flop

-I then proceeded to draw Karnaugh diagrams for each of the J and K functions and minimize them as much as I can(but they are still really REALLY long).

Now the only thing left would be to make the circuit and this is the part where I'm stuck. Having so many variables (Q3,2,1,0, A and B) how should I start making the equivalent circuit? Any help would be greatly appreciated 🙂

EDIT2: removed a question

Best Answer

No, an XOR gate will not help. In this type of state diagram, it's implicit that in any state, there are three possible inputs: no button, button A or button B. When there's no button press, you always stay in the current state, but for either button press, you need to advance to some other state that depends on which button it is.

As far as implementation with muxes, it's actually quite straightforward. I would just use four 2:1 muxes to turn the JK FFs into D FFs (drive the K input with the negation of the J input), and then use four 64:1 muxes to implement the state transition table directly — i.e., create a 64×4 ROM out of them — where the select inputs to the muxes are Q3, Q2, Q1, Q0, B and A.