Should the state table include the clock and reset button as possible inputs?

AI Thread Summary
The discussion revolves around whether to include the clock and reset button as inputs in a state table for a state machine. The user presents a state diagram and table detailing various states and transitions based on button presses. It is clarified that while the reset button can be included to set the state to zero, the clock is not an input for state determination but rather signals when to advance states. Concerns are raised about handling button presses that last longer than one clock cycle, which could lead to unintended state transitions. The user contemplates how to represent this in the state table and seeks guidance on managing edge-sensitive inputs in their VHDL code.
ineedmunchies
Messages
42
Reaction score
0

Homework Statement


28rf4va.jpg

219b9ef.jpg



Homework Equations



There aren't really any relevant equations.

The Attempt at a Solution



Ok so I just want to see if my idea for the state diagram seems ok, I'm going to give it in table form here but its the same info.

Code:
F  |  Bk  |  A  |  B  |  C  |  D  
--------------------------------------
0  |  0  |  A   |  B  |  C  |  D
0  |  1  |  D   |  A  |  A  |  D
1  |  0  |  B   |  C  |  C  |  A

The F is the forward button, the Bk the back button. A is the stop state, B is the forward state 1, C is the forward state 2, D is the backward state. I then put this into a state diagram with the 3 possible changes/inputs for each state. However should I have included the clock and the reset button in this? So that there would be 16 possible inputs?

P.S. I am not concerned about the VHDL problem at the moment although I may ask for help with it at another date.
 
Physics news on Phys.org
Your table looks fine, though including the reset wouldn't be a bad idea. The clock, however, simply tells the state machine when to advance to the next state; it's not an input for determining what the next state is.
 
Hmm ok, it was just the part in the question about holding down the buttons for more than one clock cycle that threw me. I guess that part may only be relevant when it comes to writing the VHDL.

I'm going to assume that the reset button sets everything to zero, and therefore the stop state. Ok thanks for your input, I'll post here again with my code to see if its ok.
 
I just realized there is a problem with your state machine, and it has to do with a button push lasting for more than one clock cycle. When you make a transition into the gear-I state, you don't want to leave it before the button has been released and pressed again, otherwise you'll just fly right through that state with a single button press if the clock cycle is short, as it very likely is.
 
Ahh very true, hmm how could I get around that then. I know how I could do it in the VHDL code
Code:
if ((clock = '1' and clock'event) and (SFW = '1' and SFW'event)) then 
state <= stateB;
end if;

Or something along those lines at least, but I'm unsure how I'd represent that in a state table? Could I just present the state table as is and say that state transitions can only occur at a push button event and it being equal to one?


EDIT::
So I've just read up on this a bit more and realized that a process generally can only have one edge sensitve input, therefore the code should be different.
Code:
seq:process(clock) is
begin 
if (clock = '1' and clock'event) then
present_state <= next_state;
end if;
end process seq;

com: process (SFW, SBW, reset_N);
CASE when A =>
   forwardgear1= '0';
   forwardgear2='0';
   backwardgear='0';
      if (SFW = '1' and SFW'event) then
      next_state <= B;
      elsif (SBW = '1' and SBW'event) then
      next_state <= D;
      else next_state <= A;
      end if;

when B=> ...etc

Hmm I thought I had worked it out there but realized the second process would still have more than one edge sensitive statement.
 
Last edited:
Back
Top