I try to some how stuck my state machine. As you can see on pic I have state S0 and then when I pressed button (GPIO_SW_W) then i have all changes of states. when I press again in random moment then I get S5 which is results of mixing states.
I find some resulution on my problem- to do time delay, but it’s risky, because this program will be on board and i don’t know how fast or slowly someone will press button. I did debouncer and also shift register to this. I stuck in this problem and I don’t know how to fix it.
Here is screen of my simulation and also part of code.
process [..]
elsif rising_edge(sys_clock) then
if output = '1' then
state <= nstate;
[...]
end process;
process([..])
begin
case state is
when S0 =>
if output = '1'then
nstate <= S1;
else
nstate <= S0;
end if;
when S1 =>
if output = '1' then
nstate <= S2;
else
nstate <= S1;
end if;
when S2 =>
if output = '1' then
nstate <= S3;
else
nstate <= S2;
end if;
[...]
I will be really gratefull for your help!
enter image description here
All what I want is when I press button then will next state for example:
- started program is on S0
- button = ‘1’ -> S1
- button = ‘0’ -> S1
- button = ‘1’ -> S2
- button = ‘0’ -> S2
pdp is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.