夜带水果刀 发表于 2010-6-26 00:33:57

三段式状态机问题

本帖最后由 fpgaw 于 2010-11-19 06:38 编辑

sync_proc

ROCESS(RST,CLK)BEGIN
   IF RST = '0' THEN
current_state<=idle_state;
ELSIF CLK'EVENT and CLK='1' THEN
   current_state<=next_state;
END IF;
END PROCESS sync_proc;
comb_proc
       
ROCESS(current_state,counter0)
BEGIN
next_state<=current_state;
CASE current_state IS
WHEN idle_state =>   --idle stage
   next_state <= start_state;
WHEN start_state =>    --start stage
   IF counter0 = 2400 THEN --M2 run after M1 forwarding 2400 steps
      next_state <= work_state;
   ELSE
   next_state <= start_state;
   END IF;
WHEN work_state =>   --work stage   
   next_state <= work_state;
WHEN others =>
   next_state <= idle_state;
END CASE;   
END PROCESS comb_proc;

COUNTER:process(CLK1,next_state)begin
if(CLK1'event and CLK1='1') then
if next_state = start_state then
   if counter0 < 2400 then
    counter0 <= counter0+1;
   else
    counter0 <= 2400;
   end if;
end if;
end if;
end process COUNTER;

SPEED_CTRL:process(CLK,next_state)
begin
if CLK'event and CLK='1' then
case next_state is
when idle_state =>
    ...
when start_state =>
    ...
when others =>
    ...
end case;
end if;
end process SPEED_CTRL;

三段式状态机,在start_state延时2400个脉冲进入work_state,但是在第三段的输出信号时,在work_state中无输出信号,是因为状态机不能进入work_state的原因吗?我这样用counter0控制状态机进行状态转移可行吗?请高手指教,非常感谢

粉妮 发表于 2010-6-26 01:57:22

rst信号查查看

夜带水果刀 发表于 2010-6-26 03:33:36

BEGIN<br>
&nbsp; &nbsp;&nbsp;&nbsp;next_state&lt;=current_state;这句去掉看看

Sunlife 发表于 2015-4-7 11:05:32

三段式状态机,在start_state延时2400个脉冲进入work_state,但是在第三段的输出信号时,在work_state中无输出信号,是因为状态机不能进入work_state的原因吗?我这样用counter0控制状态机进行状态转移可行吗?请高手指教,非常感谢
页: [1]
查看完整版本: 三段式状态机问题