T
Tom Neal
Guest
I get inconsistent simulation results using modelsim 3 XE when I
simulate the reseting of this simple state machine example at various
levels of simulation.
When I simulate at the behavior level, the state changes from S1 to S0
on the rising edge of the reset pulse.
When I simulate at the post translation level, the state changes from
S0 to S1 on the falling edge of the reset pulse.
When I simulate at the post map and post place & route level, the
state is at S1 before and after the reset puulse.
I am confused. Any help appreciated.
Tom
-------------------------------------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity test is
port (
Sysclk: in std_logic;
Reset: in std_logic;
Trigger: in std_logic;
state0 : out std_logic;
state1 : out std_logic;
state2 : out std_logic
);
end test;
architecture Behavioral of test is
type statetype is (S1,S0,S2);
signal state : statetype;
begin
process(sysclk,reset)
begin
if (Reset='1') then
state<=s0;
elsif (rising_edge(sysclk)) then
case state is
when s0 =>
if (trigger='1') then
state<=S1;
end if;
when S1 =>
state<=s2;
when S2 =>
state<=S0;
end case;
end if;
end process;
state0<='1' when (state=S0) else '0';
state1<='1' when (state=S1) else '0';
state2<='1' when (state=S2) else '0';
end Behavioral;
simulate the reseting of this simple state machine example at various
levels of simulation.
When I simulate at the behavior level, the state changes from S1 to S0
on the rising edge of the reset pulse.
When I simulate at the post translation level, the state changes from
S0 to S1 on the falling edge of the reset pulse.
When I simulate at the post map and post place & route level, the
state is at S1 before and after the reset puulse.
I am confused. Any help appreciated.
Tom
-------------------------------------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity test is
port (
Sysclk: in std_logic;
Reset: in std_logic;
Trigger: in std_logic;
state0 : out std_logic;
state1 : out std_logic;
state2 : out std_logic
);
end test;
architecture Behavioral of test is
type statetype is (S1,S0,S2);
signal state : statetype;
begin
process(sysclk,reset)
begin
if (Reset='1') then
state<=s0;
elsif (rising_edge(sysclk)) then
case state is
when s0 =>
if (trigger='1') then
state<=S1;
end if;
when S1 =>
state<=s2;
when S2 =>
state<=S0;
end case;
end if;
end process;
state0<='1' when (state=S0) else '0';
state1<='1' when (state=S1) else '0';
state2<='1' when (state=S2) else '0';
end Behavioral;