Altera_Forum
Honored Contributor
9 years agoMoore Finite State Machine questions (VHDL and C)
Hello,
I am having some troubles with my Moore state machine. Is it actually possible to use an internal signal or variable dependancy in a IF-statement during a process? Im using a the next-state logic. It uses a case statement with the state-reg signal as the selection expression. The next state is determined by the current state and external input. It consists of segments for the state register, next-state logic, Moore output logic. Actually i like to check my internal signal X or variable X which is initialized with zero during a specific case in my state machine. Once i reach this case statement, im checking with my If statement. When this condition is true the next state of my state machine is determined while I m incrementing my checked signal or variable X so that I will never go in this state again expect some hard resets because the specfic IF-statementcheck is not fulfilled. Im not able to get this behaviour. I can get it to work when i am exclusivly using defined inputs from my entity in order to change the next state in my combinatorical block. Here an example of my issue ------------------------------------------------------- process(...) variable cnt: integer:=0; begin case current_fsm_state is when State_A => if(cnt=1)then cnt=cnt+1; -- check only once and never again expect resets next_fsm_state<=B; elsif(input_a='1')then next_fsm_state<=State_C; else next_fsm_state<=State_A; end if; ...... ----------------------------------------------------------------- I am using that integrated student waveformbuilder in quartus to test my system on correctness ....especially this special case with that internal signal or variable( I ve tried both) is messing my state machine up. I mean i know that variables get instantly updated when I enter a process...but does that also count for an expression within nested if statements? I thought here is the equivalence to C-programming style. So far i ve only seen finite state machines with external inputs in literature. Does someone have advice how to face this issue?