naught
Member level 3
i`m writing a state machine and have some problems.
I tried use a 3-bit counter to control the state machine and I want the project to start its work at "cnt =0", instead of "cnt = 1".
But after the "rst" disabled, the cnt simply jumps to "1", and i intend it to start at "0".
maybe i could set the value "cnt =111" when rst = '1', then i`ll get cnt="000" when the 1st clk rising eldge comes after the rst disabled.
could anyone help provide some other ways to make the cnt = 0 at the 1st clk uprising eldge after the rst disabled?
or did write the state machine in a wrong way? i try to set the system start at a certain state, say state0, then flows to state1, state2, then repeat. now it seems
it starts at state1, then state2, then state0, then repeat....anyway, plz help... the HDL is so different from software i wrote before and really puzzling.
thanks in advance.
I tried use a 3-bit counter to control the state machine and I want the project to start its work at "cnt =0", instead of "cnt = 1".
But after the "rst" disabled, the cnt simply jumps to "1", and i intend it to start at "0".
maybe i could set the value "cnt =111" when rst = '1', then i`ll get cnt="000" when the 1st clk rising eldge comes after the rst disabled.
could anyone help provide some other ways to make the cnt = 0 at the 1st clk uprising eldge after the rst disabled?
or did write the state machine in a wrong way? i try to set the system start at a certain state, say state0, then flows to state1, state2, then repeat. now it seems
it starts at state1, then state2, then state0, then repeat....anyway, plz help... the HDL is so different from software i wrote before and really puzzling.
thanks in advance.
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 process(rst,clk) begin if(rst = '1') then cnt <= "000"; elsif(clk'event and clk = '1') then cnt <= cnt + 1; end if; end process; process(cnt) begin case cnt is when "000" => data_tmp <= "001"; when "001" => data_tmp <= "010"; when "010" => data_tmp <= "011"; when "011" => data_tmp <= "100"; when "100" => data_tmp <= "101"; when "101" => data_tmp <= "110"; when "110" => data_tmp <= "111"; when "111" => data_tmp <= "000"; when others => NULL; end case; end process;
Last edited by a moderator: