It’s just interesting if I implement a finite state machine in VHDL, do I need to indicate which all outputs are in any possible state? Even if I know that some outputs will not change from one state to another, and I know that the order of states will also be in the same order?
For example, in this (forced) example:
entity test is port ( clk : in std_logic; a : in std_logic; b: out std_logic; c: out std_logic; ); end test; architecture Behavioral of test is type executionStage is (s1,s2,s3); signal currentstate, nextstate: executionStage; begin process (clk) begin if(rising_edge(clk)) then currentstate <= nextstate; else currentstate <= currentstate; end if; end process; process(currentstate) begin case currentstate is when s1 => if (a = '1') then b <= '1'; c <= '0'; else b <= '1'; c <= '1'; end if; nextstate <= s2; when s2 => -- b doesnt change state from s1 to here, do I need to define what it is here? if (a = '1') then b <= '1'; c <= '1'; else b <= '1'; c <= '0'; end if; nextstate <= s3; when s3 => if (a = '1') then b <= '0'; c <= '0'; else b <= '1'; c <= '1'; end if; nextstate <= s1; end case; end process; end Behavioral;
From my understanding, if I do not, then the latches are created?
This is not very similar to this example, but if I have a machine with more than 10 outputs and more than 10 states, then my VHDL files start to look incredibly dirty, and I'm sure it should be a bad practice to copy and paste one and the same thing over and over. Is there a better way to do this?
edit: Can I determine the default state for output? IE set b to be 1 outside of all processes, and then only determine what it is in cases where it is 0? Will this work?
source share