FSM problems

Guest #6023190
Rate this post
• ▲ useful
▼ not useful
HI,
during the development of FSM sometimes I forget to declare the status 
of variable (i.e. std_logic). Just as example:
- state n: a<='1'; b<='0';
- state m: a<='0';
in the state m "b" is not declared and then it could assume any value.

Is there a way to chose the default value for a signal, in this way if I 
forget to set it in a state the value will be assumed as specified 
default?
thank you
maurizio stefani
Guest #6023261
Rate this post
• ▲ useful
▼ not useful
You probably describe the state machine inside a clocked process. Then 
an unassigned signal just keeps its value. If you go to state m from 
state n, b will still be '0'.

If you want to define a default value, assign the value at the beginning 
of the process. In a process only the last assigned value is assigned to 
a signal.
1
process(clk) begin
2
  wait until rising_edge(clk);
3
  a<='0';
4
  b<='1';
5
  case state is
6
    when n =>
7
      a<='1';
8
      b<='0';
9
    when m =>
10
      a<='1';
11
  end case;
12
end process;

When state is n, b will be '0', when state is m, b will be '1', because 
'1' is assigned to b and it is not overwritten later.

Just for clarification:
1
process begin
2
  a<='1';
3
  a<='0';
4
  a<='1';
5
  a<='0';
6
end process;
'a' will always be '0'. It will not toggle. Only the last assignment 
is executed.

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.