What are the potential risks when implementing a 12-states ?First of all I will need then 4 flip flops to draw my circuit giving a total of 16 states machines meaning that 4 states will be unused .

What are the problems I might envision in a system that can exist in 4 more states than are actually intended to be used ?

  • \$\begingroup\$ A machine with 12 states is not 12 state machines. Make those extra states do something benign. \$\endgroup\$
    – Andy aka
    Jul 2, 2020 at 16:17
  • \$\begingroup\$ you really need to edit your post ... it is still talking about 12 state machines \$\endgroup\$
    – jsotola
    Jul 2, 2020 at 16:25
  • \$\begingroup\$ This reads as a homework question with no attempt made to solve. One of your previous questions was the same. This is not a free homework-answering site and questions that appear to be as such are often closed. \$\endgroup\$
    – TonyM
    Jul 2, 2020 at 17:08
  • \$\begingroup\$ @TonyM well this ain't a a big problem to solve . If it was a coding problem then I would post my code and ask for help. but this is just a question that I want to have a right answer for , so that I could understand it . Please don't make a big deal about it. \$\endgroup\$
    – James
    Jul 2, 2020 at 17:21
  • 1
    \$\begingroup\$ Depends on what kind of system you intend to implement it with. In an HDL, it is vitally important to tell the compiler what to do with the unused states. There are also problems of faults with Single Event Upsets that can cause a state machine to jump states. \$\endgroup\$
    – Voltage Spike
    Jul 2, 2020 at 17:48

2 Answers 2


There are several ways to code state machines.

The simplest is 'one hot', where your 12 states would use 12 flip flops, only one of which would be active at any time. This is simple to debug, and avoids much decoding.

To save flip flops, you could use a binary code to use only four of them. What you save in flip flops, you may lose in decoding circuitry. If your state machine has a linear sequence through the states, then a Gray-type encoding could avoid race conditions decoding to unwanted output glitches.

With any coding scheme, what do you do if the SM ends up in an illegal state? One option is to decode all illegal states as a prompt transition to the idle state, or reset, or power-on. This would make recovery automatic, but would mask what happened. Another possibility would be for them to stick in the illegal state forever more, so you'd have something to debug.

It depends on whether this is a life-critical system, and whether failure would be merely inconvenient, or very important.


If you're doing this in code (e.g. a microcontroller), having unused states isn't a problem at all. Most of the time it's the cheapest/smallest/lowest consumption solution, as micros are getting smaller and cheaper, while discrete components (or LSI ICs) are bigger, and PCB plus the bigger box costs money.

If you're using hardware (or maybe an FPGA or something similar), encoding your states in a way to ignore e.g. the last bit sometimes (12 "real" states with 16 numbers) saves you some gates and helps with the "illegal" state problem.

E.g. Let's say your states are encoded like this: 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 100x, 101x, 110x, 111x. Now you can use fewer gates to check your state, because you know if your highest bit is 1, your lowest doesn't matter.


Not the answer you're looking for? Browse other questions tagged or ask your own question.