T
tringuyen858@gmail.com
Guest
Hi all,
I am trying to simulate a state machine that has a counter. Below is
the code. When I run the simulation, it gets stuck at BEGIN_COUNT and
start_flag_counter is X"01" throughout the whole simulation. I can't
figure out what is wrong. May be it is something obvious that I can't
see. thank you for your input.
SYNC_PROC: process (clk_100, SYS_RST_N)
begin
if (SYS_RST_N='0') then
state_count <= INIT;
clk_100_locked_reg <= '0';
lock_reg_int_reg <= '0';
elsif rising_edge(clk_100) then
state_count <= next_state;
clk_100_locked_reg <= clk_100_locked;
lock_reg_int_reg <= lock_reg_int;
end if;
end process;
start_sig: process(state_count, clk_100_locked_reg,
lock_reg_int_reg)
begin
case state_count is
when INIT =>
start_reg <= '0';
start_flag_counter <= X"00";
if clk_100_locked_reg = '1' and lock_reg_int_reg = '1'
then
next_state <= BEGIN_COUNT;
else
next_state <= INIT;
end if;
when BEGIN_COUNT =>
start_flag_counter <= start_flag_counter + 1;
start_reg <= '0';
if start_flag_counter = X"64" then
next_state <= START_FLAG;
else
next_state <= BEGIN_COUNT;
end if;
when START_FLAG =>
start_flag_counter <= start_flag_counter + 1;
start_reg <= '1';
if start_flag_counter = X"6A" then
next_state <= STOP_COUNT;
else
next_state <= START_FLAG;
end if;
when STOP_COUNT =>
start_flag_counter <= X"00";
start_reg <= '0';
next_state <= STOP_COUNT;
end case;
end process;
I am trying to simulate a state machine that has a counter. Below is
the code. When I run the simulation, it gets stuck at BEGIN_COUNT and
start_flag_counter is X"01" throughout the whole simulation. I can't
figure out what is wrong. May be it is something obvious that I can't
see. thank you for your input.
SYNC_PROC: process (clk_100, SYS_RST_N)
begin
if (SYS_RST_N='0') then
state_count <= INIT;
clk_100_locked_reg <= '0';
lock_reg_int_reg <= '0';
elsif rising_edge(clk_100) then
state_count <= next_state;
clk_100_locked_reg <= clk_100_locked;
lock_reg_int_reg <= lock_reg_int;
end if;
end process;
start_sig: process(state_count, clk_100_locked_reg,
lock_reg_int_reg)
begin
case state_count is
when INIT =>
start_reg <= '0';
start_flag_counter <= X"00";
if clk_100_locked_reg = '1' and lock_reg_int_reg = '1'
then
next_state <= BEGIN_COUNT;
else
next_state <= INIT;
end if;
when BEGIN_COUNT =>
start_flag_counter <= start_flag_counter + 1;
start_reg <= '0';
if start_flag_counter = X"64" then
next_state <= START_FLAG;
else
next_state <= BEGIN_COUNT;
end if;
when START_FLAG =>
start_flag_counter <= start_flag_counter + 1;
start_reg <= '1';
if start_flag_counter = X"6A" then
next_state <= STOP_COUNT;
else
next_state <= START_FLAG;
end if;
when STOP_COUNT =>
start_flag_counter <= X"00";
start_reg <= '0';
next_state <= STOP_COUNT;
end case;
end process;