J
Jerker Hammarberg (DST)
Guest
Hello! I have noticed that if I add a "when others" branch in a state
machine case statement, the resulting FPGA becomes considerably smaller. To
be clear,
type state_type is (s0, s1);
signal state: state_type;
....
process(clk, rst)
begin
if (rst = '1') then
state <= s0;
elsif clk'event and clk = '1' then
case state of
when s0 =>
-- do something
state <= s1;
when s1 =>
-- do something else
state <= s0;
when others =>
state <= s0;
end case;
end if;
end process;
is smaller than if I remove the "when others" branch. What's the reason? My
second question is how this branch can be reached in the FPGA? It happens to
me. I understand that it can be reached during simulation if "state" is not
initialized, but how can it happen in reality?
I use Xilinx XST with FSM encoding set to "auto".
Thanks in advance for any help!
/Jerker
machine case statement, the resulting FPGA becomes considerably smaller. To
be clear,
type state_type is (s0, s1);
signal state: state_type;
....
process(clk, rst)
begin
if (rst = '1') then
state <= s0;
elsif clk'event and clk = '1' then
case state of
when s0 =>
-- do something
state <= s1;
when s1 =>
-- do something else
state <= s0;
when others =>
state <= s0;
end case;
end if;
end process;
is smaller than if I remove the "when others" branch. What's the reason? My
second question is how this branch can be reached in the FPGA? It happens to
me. I understand that it can be reached during simulation if "state" is not
initialized, but how can it happen in reality?
I use Xilinx XST with FSM encoding set to "auto".
Thanks in advance for any help!
/Jerker