集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2099|回复: 1

状态机的问题

[复制链接]
绿豆宝贝 发表于 2010-6-25 23:40:24 | 显示全部楼层 |阅读模式
本帖最后由 fpgaw 于 2010-11-19 09:14 编辑

library IEEE;
use IEEE.std_logic_1164.all;

entity control is
Port (clk,done,reset,set_time,start_cook,test:in std_logic;
  cook,load_8888,load_clk,load_done: out std_logic);
end control;
architecture A of control is
type STATE_TYPE is (idle,lamp_test,set_clock,timer,done_msg);
signal NEXT_STATE,PRESENT_STATE: STATE_TYPE;

begin

process (clk,reset)
begin
if reset='1' then
present_state<=idle;
elsif clk'event and clk='1' then
present_state<=next_state;
end if;
end process;
process (present_state,set_time,start_cook,test,done)
begin
next_state<=idle;
load_8888<='0';
load_done<='0';
load_clk<='0';
cook<='0';

case present_state is
when lamp_test=>
load_8888<='1';
when set_clock=>
load_clk<='1';
when done_msg=>
load_done<='1';
when idle=>
if test='1' then
  next_state<=lamp_test;
  load_8888<='1';
elsif set_time='1' then
  next_state<=set_clock;
  load_clk<='1';
elsif start_cook='1' and done='0' then
  next_state<=timer;
  cook<='1';
end if;
when timer=>
if done='1' then
  next_state<=done_msg;
  load_done<='1';
else
  next_state<=timer;
  cook<='1';
end if;
end case;
end process;
end A;
七郎仔 发表于 2010-6-26 01:14:08 | 显示全部楼层
生活啊~~~<br>
就像一坨屎
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2024-11-23 15:42 , Processed in 0.060629 second(s), 24 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表