EmbDev.net

Forum: FPGA, VHDL & Verilog FSM problems


von maurizio stefani (Guest)


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

von Dussel (Guest)


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.

von Maurizio S. (Company: progsel) (maurizio)


Rate this post
useful
not useful
HI,
thank you for your help, I will check asap

maurizio stefani

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.