C
Calvin T
Hi all,
I hope you folks can help settle a debate regarding statement position
from a legacy design.
My coworker thinks position of 2 statements right after the big ELSE
statement is okay as if.
I think such position makes these 2 staments concurrent to the case
statement and may cause unexpected result.
These 2 statements should be moved inside the case statement as shown
below and one statement, e_reset_b <= '1' ; added in event_mux state
if the intention is to keep e_reset_b signal staying HI at the end.
While simulations currently show the same result in both cases, which
approach is correct or more reliable ?
Thanks,
Calvin
=================================================================
process (clk, nreset)
begin
if nreset = '0' THEN
er_state <= idle;
e_reset_b <= '1' ;
e_mux <= '0' ;
elsif rising_edge( clk) then
IF nlfm = '0' THEN
er_state <= idle;
e_reset_b <= '1' ;
e_mux <= '0' ;
ELSE
e_reset_b <= '1' ; -- <---------------- should NOT be
here
e_mux <= '0' ; -- <---------------- should NOT
be here
case er_state is
when idle =>
e_reset_b <= '1' ; -- <---------------- should be here
e_mux <= '0' ; -- <---------------- should
be here
if event_reset = '1' then
er_state <= event_rst ;
end if;
when event_rst =>
if event_reset = '0' then
er_state <= event_mux ;
end if;
e_reset_b <= '0' ;
when event_mux =>
e_reset_b <= '1' ; -- Added to stay HI at the end
e_mux <= '1' ;
when others =>
er_state <= event_mux;
e_reset_b <= '1' ;
e_mux <= '1' ;
end case;
END IF;
end if;
end process;
I hope you folks can help settle a debate regarding statement position
from a legacy design.
My coworker thinks position of 2 statements right after the big ELSE
statement is okay as if.
I think such position makes these 2 staments concurrent to the case
statement and may cause unexpected result.
These 2 statements should be moved inside the case statement as shown
below and one statement, e_reset_b <= '1' ; added in event_mux state
if the intention is to keep e_reset_b signal staying HI at the end.
While simulations currently show the same result in both cases, which
approach is correct or more reliable ?
Thanks,
Calvin
=================================================================
process (clk, nreset)
begin
if nreset = '0' THEN
er_state <= idle;
e_reset_b <= '1' ;
e_mux <= '0' ;
elsif rising_edge( clk) then
IF nlfm = '0' THEN
er_state <= idle;
e_reset_b <= '1' ;
e_mux <= '0' ;
ELSE
e_reset_b <= '1' ; -- <---------------- should NOT be
here
e_mux <= '0' ; -- <---------------- should NOT
be here
case er_state is
when idle =>
e_reset_b <= '1' ; -- <---------------- should be here
e_mux <= '0' ; -- <---------------- should
be here
if event_reset = '1' then
er_state <= event_rst ;
end if;
when event_rst =>
if event_reset = '0' then
er_state <= event_mux ;
end if;
e_reset_b <= '0' ;
when event_mux =>
e_reset_b <= '1' ; -- Added to stay HI at the end
e_mux <= '1' ;
when others =>
er_state <= event_mux;
e_reset_b <= '1' ;
e_mux <= '1' ;
end case;
END IF;
end if;
end process;