# Machine states and its potential risks

#### GastonJam

Joined Jun 25, 2020
11 1.1 For the following state graph, a circuit of the Mealy type is to be developed using T flip-flops. Then the circuit should be outlined. (Done)
1.2 Develop VHDL code that describes the state graph (three - process description) (Done)
1.3 Draw the synthesis result for the VHDL code.(Done)

I don't have a big knowledge about the state machines so if there's an explanation for this question I would be glad .
1.4 What is the potential risk when implementing a 12-state machine? How can this danger be reduced or eliminated?

#### WBahn

Joined Mar 31, 2012
26,398
If you are using binary memory elements (such as T flip flps), how many flip flops would you need to represent 12 states? How many states are represented by that many T flip flops? Do you see the issue?

• GastonJam

#### GastonJam

Joined Jun 25, 2020
11
If you are using binary memory elements (such as T flip flps), how many flip flops would you need to represent 12 states? How many states are represented by that many T flip flops? Do you see the issue?
To represent 4 states I needed 1 T flip flop . So to represent 12 states I will probably need 4 T Flip flips or more . To eleminate the danger we could reduce the number of states right ? But the question is : Could the use of many flip flops be dangerous for the circuit ?

#### WBahn

Joined Mar 31, 2012
26,398
How did you represent 4 states with just 1 T flip flop? A flip flop is in just one of two states.

Reducing the number of states is not an option because the question specifically asks about implementing a machine with 12 states.

#### GastonJam

Joined Jun 25, 2020
11
Sorry I meant 2 Flip flops for 4 States which means 6 for 12

#### WBahn

Joined Mar 31, 2012
26,398
Sorry I meant 2 Flip flops for 4 States which means 6 for 12
How are you getting 6 flip flops for 12 states?

WHY does it require 2 flip flops for 4 states? Is it because 2+2 is 4? Or because 2*2 is 4? or because 2² is 4?

Consider how many possible combinations there are if you have N digits each of which can take on B different values. Think of a combination lock that has four wheels, each of which can be set to one of ten different values, 0 through 9, so N=4 and B=10. How many different combinations are there?

• djsfantasi

#### GastonJam

Joined Jun 25, 2020
11
Consider how many possible combinations there are if you have N digits each of which can take on B different values. Think of a combination lock that has four wheels, each of which can be set to one of ten different values, 0 through 9, so N=4 and B=10. How many different combinations are there?
[/QUOTE]

I think I get it . So in 4 states machines all of the states are used and combined to each other but in 12 states there will be some binary states that won't be used . So we should add the 3 binary states that are missing from the 12 states to reach 15 states :1101 1110 1111 . Is it correct ?

#### WBahn

Joined Mar 31, 2012
26,398
Consider how many possible combinations there are if you have N digits each of which can take on B different values. Think of a combination lock that has four wheels, each of which can be set to one of ten different values, 0 through 9, so N=4 and B=10. How many different combinations are there?
I think I get it . So in 4 states machines all of the states are used and combined to each other but in 12 states there will be some binary states that won't be used . So we should add the 3 binary states that are missing from the 12 states to reach 15 states :1101 1110 1111 . Is it correct ?
[/QUOTE]

You are on the right track. But why are you adding three states?

Again, go back to fundamentals.

How many states can a machine with N flip flops represent? Give me an equation such that if I tell you want N is, someone could plug that into the equation and the result is the number of states that can be represented.

• GastonJam

#### GastonJam

Joined Jun 25, 2020
11
The equation is 2^n states and n is the number of flip flops
4 States machine = 2 ^ 2 => 2 Flip flops needed
We can't use the formula for 12 states machine so we should use
2^4 = 16 states machine => 4 Flip flops needed

#### GastonJam

Joined Jun 25, 2020
11
The second part of the question was : How can this danger be reduced or eliminated?
So 4 states will be unused I guess . So how should they be taken care of ?

#### WBahn

Joined Mar 31, 2012
26,398
The equation is 2n states and n is the number of flip flops
4 States machine = 2 * 2 => 2 Flip flops needed
12 States machine = 2 * 6 => 6 Flip flops needed
You are being inconsistent. Here you are indicating that for 12 states you need 6 flip flops to exactly represent 12 states, but previously you said that with 12 states there would be 3 unused states (for a total of 15, which is an odd number, which makes no sense if the number of states is twice the number of flip flops).

If I have a state machine with 3 flip flops, you are claiming that it can represent 6 states. What are the states it can represent? List all of them.

Let's step back further.

If I have a combination lock that consists of four wheels, where each wheel can be in ten different positions (numbered 0 through 9), how many possible combinations do I have?

Huge hint: Every combination can be expressed as a four-digit base-10 number. So 8471 is one combination, 3922 is another. So is 0000 and so is 9999. How many different combinations are there?

How many difference combinations are there is I have a lock with N wheels?

What about if I have a lock with N wheels, but each wheel has B positions?

#### WBahn

Joined Mar 31, 2012
26,398
The second part of the question was : How can this danger be reduced or eliminated?
So 4 states will be unused I guess . So how should they be taken care of ?
What 4 states are being unused? You just got done claiming that if you use 6 flip flops that you have exactly the 12 states you need.

You are being extremely inconsistent in your reasoning.

#### GastonJam

Joined Jun 25, 2020
11
What 4 states are being unused? You just got done claiming that if you use 6 flip flops that you have exactly the 12 states you need.

You are being extremely inconsistent in your reasoning.
I take back what I said about the 3 states that should be added . Have a look again at the equation that I mentioned it's 2^n
You took my response before I edited the post

Last edited:

#### WBahn

Joined Mar 31, 2012
26,398
I take back what I said about the 3 states that should be added . Have a look again at the equation that I mentioned it's 2^n
You took my response before I edited the post
Okay, so if you have 2^n states, meaning that for 12 desired states you need four flip flops giving a total of 16 states meaning that 4 states are unused.

What are some of the problems you might envision in a system that can exist in 4 more states than are actually INTENDED to be used?

Consider why I might have capitalized that word in the previous sentence.

#### GastonJam

Joined Jun 25, 2020
11
Okay, so if you have 2^n states, meaning that for 12 desired states you need four flip flops giving a total of 16 states meaning that 4 states are unused.

What are some of the problems you might envision in a system that can exist in 4 more states than are actually INTENDED to be used?

Consider why I might have capitalized that word in the previous sentence.
The system can cause a state machine to jump states ?

#### WBahn

Joined Mar 31, 2012
26,398
The system can cause a state machine to jump states ?
You need to be a lot more specific than this -- this is far too generic for a grader to have any confidence that you understand the issue. After all, a state machine is useless if it isn't capable of "jumping" from one state to another.

How is the system being able to cause a state machine to jump states different for a machine that can exist in sixteen states but only uses twelve of them any different than if we use all sixteen of them?

If I have a machine that only uses twelve states but that has sixteen, what could I do to improve the situation?

#### GastonJam

Joined Jun 25, 2020
11
Maybe we can connect the 4 unused states to the others ? But random connections will make no sense :/

#### WBahn

Joined Mar 31, 2012
26,398
Maybe we can connect the 4 unused states to the others ? But random connections will make no sense :/
This is on the right track to how to mitigate the danger, but what danger is being mitigated. WHY does having unused states present a potential danger? WHAT bad thing could potentially happen?