O
Olaf
Hi,
I have the following state=output state machine:
architecture ...
....
signal pattern_match : std_ulogic;
signal delay_match : std_ulogic;
signal enable_delay : std_ulogic;
-- fsm states with one-hot encoding
subtype state_t is std_ulogic_vector(3 downto 0);
constant IDLE : state_t := "0001";
constant ARMED : state_t := "0010";
constant SHOT_DELAYED : state_t := "0100";
constant SHOT : state_t := "1000";
signal state, next_state : state_t;
begin
trigger_fsm : process (smpl_clk) is
variable fsm_enable_delay : std_ulogic;
variable fsm_match : std_ulogic;
begin
fsm_enable_delay := state(1); -- ARMED
fsm_match := state(3); -- SHOT
if rising_edge(smpl_clk) then
state <= next_state; -- avoid latches
if (reset = RESET_ACTIVE) then
next_state <= IDLE;
else
case state is
when IDLE => -- State: "0001"
if (arm = '1') then
-- go to capture trigger events
next_state <= ARMED;
end if;
when ARMED => -- State: "0010"
if (pattern_match = '1') and (reg_level =
global_level) then
if (or_reduce(reg_timer) = '0') then
-- no shoting delay timer needed
next_state <= SHOT;
else
-- before we can shot, wait until delay
next_state <= SHOT_DELAYED;
end if;
end if;
when SHOT_DELAYED => -- State: "0100"
if (delay_match = '1') then
next_state <= SHOT;
end if;
when SHOT => -- State: "1000"
-- set the shot and disabled itself
next_state <= IDLE;
when others =>
-- TODO: set status flags; should not be here
next_state <= IDLE;
end case;
end if; -- reset
end if; -- rising_edge
enable_delay <= fsm_enable_delay;
match <= fsm_match;
end process;
Unfortunately a register is inferred for enable_delay and match. Try &
Error doesn't help to remove it X-). E.g.:
_ _ _ _ _
clk: _| |_| |_| |_| |_| |
------- ------
state: X 0010 X 1000
------- ------
______
match: __| |___
wanted: ______
match: | |___
How to get this? state=output fsm are fast and glitch free following
Sjoholm and Lindth "VHDL for Designers".
Thanks
Olaf
I have the following state=output state machine:
architecture ...
....
signal pattern_match : std_ulogic;
signal delay_match : std_ulogic;
signal enable_delay : std_ulogic;
-- fsm states with one-hot encoding
subtype state_t is std_ulogic_vector(3 downto 0);
constant IDLE : state_t := "0001";
constant ARMED : state_t := "0010";
constant SHOT_DELAYED : state_t := "0100";
constant SHOT : state_t := "1000";
signal state, next_state : state_t;
begin
trigger_fsm : process (smpl_clk) is
variable fsm_enable_delay : std_ulogic;
variable fsm_match : std_ulogic;
begin
fsm_enable_delay := state(1); -- ARMED
fsm_match := state(3); -- SHOT
if rising_edge(smpl_clk) then
state <= next_state; -- avoid latches
if (reset = RESET_ACTIVE) then
next_state <= IDLE;
else
case state is
when IDLE => -- State: "0001"
if (arm = '1') then
-- go to capture trigger events
next_state <= ARMED;
end if;
when ARMED => -- State: "0010"
if (pattern_match = '1') and (reg_level =
global_level) then
if (or_reduce(reg_timer) = '0') then
-- no shoting delay timer needed
next_state <= SHOT;
else
-- before we can shot, wait until delay
next_state <= SHOT_DELAYED;
end if;
end if;
when SHOT_DELAYED => -- State: "0100"
if (delay_match = '1') then
next_state <= SHOT;
end if;
when SHOT => -- State: "1000"
-- set the shot and disabled itself
next_state <= IDLE;
when others =>
-- TODO: set status flags; should not be here
next_state <= IDLE;
end case;
end if; -- reset
end if; -- rising_edge
enable_delay <= fsm_enable_delay;
match <= fsm_match;
end process;
Unfortunately a register is inferred for enable_delay and match. Try &
Error doesn't help to remove it X-). E.g.:
_ _ _ _ _
clk: _| |_| |_| |_| |_| |
------- ------
state: X 0010 X 1000
------- ------
______
match: __| |___
wanted: ______
match: | |___
How to get this? state=output fsm are fast and glitch free following
Sjoholm and Lindth "VHDL for Designers".
Thanks
Olaf