N
Noah
hi, all,
when I compile a desing, I met the following warning(part of all):
"Warning: Latch next_state.st_server has unsafe behavior
Warning: Ports D and ENA on the latch are fed by the same signal
pre_state.st_server
Warning: Latch b_s has unsafe behavior
Warning: Ports D and ENA on the latch are fed by the same signal
pre_state.st_6
Warning: Latch a_s has unsafe behavior
Warning: Ports D and ENA on the latch are fed by the same signal
pre_state.st_2"
I try to use clock to avoid the latch problem, and it works.
but I can't understand the meaning of the warnings.
what means that : ports D and ENA are fed by the same signal?
pre_state.st_server is just a state, a condition to enter the
corresponding state. and also, I can't understand which one is fed by
the same signal.
can anyone explain what a latch really works, and how many latchs are
there in the following code section? Thank you!!!
Regards!
-- Noah
the code section as bellow:
FSM: process(clk_in, pre_state, a_serve, b_serve)
begin
--if clk_in'event and clk_in = '0' then
ball_pos_temp <= (others => '0');
a_inc <= '0';
b_inc <= '0';
error <= '0';
case pre_state is
when st_server =>
if a_serve = '1' then
a_s <= '1';
b_s <= '0';
next_state <= st_0;
elsif b_serve = '1' then
b_s <= '1';
a_s <= '0';
next_state <= st_6;
else
next_state <= st_server;
error <= '1';
a_s <= '0';
b_s <= '0';
end if;
when st_0 =>
ball_pos_temp(0) <= '1';
if a_s = '1' then
next_state <= st_1;
if b_catch = '1' then -- b catch the ball over net.
next_state <= st_server;
a_inc <= '1';
a_s <= '0';
b_s <= '0';
elsif a_catch = '1' then -- a serve/catch the ball 2 times.
next_state <= st_server;
b_inc <= '1';
a_s <= '0';
b_s <= '0';
end if;
elsif b_s = '1' then
if a_catch = '1' then
next_state <= st_1;
a_s <= '1';
b_s <= '0';
else -- a doesn't catch the ball
next_state <= st_server;
b_inc <= '1';
a_s <= '0';
b_s <= '0';
end if;
end if;
when st_1 =>
ball_pos_temp(1) <= '1';
if a_s = '1' then
next_state <= st_2;
if b_catch = '1' then -- b catch the ball over net
next_state <= st_server;
a_inc <= '1';
a_s <= '0';
b_s <= '0';
elsif a_catch = '1' then -- a serve/catch the ball 2 times.
next_state <= st_server;
b_inc <= '1';
a_s <= '0';
b_s <= '0';
end if;
elsif b_s = '1' then
if a_catch = '1' then
next_state <= st_2;
a_s <= '1';
b_s <= '0';
else
next_state <= st_0;
end if;
end if;
when I compile a desing, I met the following warning(part of all):
"Warning: Latch next_state.st_server has unsafe behavior
Warning: Ports D and ENA on the latch are fed by the same signal
pre_state.st_server
Warning: Latch b_s has unsafe behavior
Warning: Ports D and ENA on the latch are fed by the same signal
pre_state.st_6
Warning: Latch a_s has unsafe behavior
Warning: Ports D and ENA on the latch are fed by the same signal
pre_state.st_2"
I try to use clock to avoid the latch problem, and it works.
but I can't understand the meaning of the warnings.
what means that : ports D and ENA are fed by the same signal?
pre_state.st_server is just a state, a condition to enter the
corresponding state. and also, I can't understand which one is fed by
the same signal.
can anyone explain what a latch really works, and how many latchs are
there in the following code section? Thank you!!!
Regards!
-- Noah
the code section as bellow:
FSM: process(clk_in, pre_state, a_serve, b_serve)
begin
--if clk_in'event and clk_in = '0' then
ball_pos_temp <= (others => '0');
a_inc <= '0';
b_inc <= '0';
error <= '0';
case pre_state is
when st_server =>
if a_serve = '1' then
a_s <= '1';
b_s <= '0';
next_state <= st_0;
elsif b_serve = '1' then
b_s <= '1';
a_s <= '0';
next_state <= st_6;
else
next_state <= st_server;
error <= '1';
a_s <= '0';
b_s <= '0';
end if;
when st_0 =>
ball_pos_temp(0) <= '1';
if a_s = '1' then
next_state <= st_1;
if b_catch = '1' then -- b catch the ball over net.
next_state <= st_server;
a_inc <= '1';
a_s <= '0';
b_s <= '0';
elsif a_catch = '1' then -- a serve/catch the ball 2 times.
next_state <= st_server;
b_inc <= '1';
a_s <= '0';
b_s <= '0';
end if;
elsif b_s = '1' then
if a_catch = '1' then
next_state <= st_1;
a_s <= '1';
b_s <= '0';
else -- a doesn't catch the ball
next_state <= st_server;
b_inc <= '1';
a_s <= '0';
b_s <= '0';
end if;
end if;
when st_1 =>
ball_pos_temp(1) <= '1';
if a_s = '1' then
next_state <= st_2;
if b_catch = '1' then -- b catch the ball over net
next_state <= st_server;
a_inc <= '1';
a_s <= '0';
b_s <= '0';
elsif a_catch = '1' then -- a serve/catch the ball 2 times.
next_state <= st_server;
b_inc <= '1';
a_s <= '0';
b_s <= '0';
end if;
elsif b_s = '1' then
if a_catch = '1' then
next_state <= st_2;
a_s <= '1';
b_s <= '0';
else
next_state <= st_0;
end if;
end if;