搜索
bottom↓
回复: 1

一个简单的状态机程序,感觉仿真波形有点问题呢

[复制链接]

出0入399汤圆

发表于 2013-3-2 15:12:32 | 显示全部楼层 |阅读模式
  1. --moore状态机
  2. --**************库定义、 包定义********************
  3. library IEEE;
  4. use IEEE.STD_LOGIC_1164.ALL;
  5. use IEEE.STD_LOGIC_ARITH.ALL;
  6. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  7. --**************实体定义********************
  8. entity moore IS
  9. port(
  10.         clk,ready,read_write : in std_logic;
  11.         reset          : in         std_logic;--复位输入
  12.         oe,we                                 : out std_logic
  13.         );
  14. end moore;
  15. --**************构造体定义********************
  16. architecture state_machine of moore is
  17.         type state_type is(idle,decision,read,write);--自定义信号类型
  18.         signal present_state,next_state:state_type;
  19. begin
  20.         state_comb : process(present_state,ready,read_write)
  21.         begin
  22.                 case present_state is
  23.                         when idle=>                                                        --空闲状态
  24.                                                 oe<='1';
  25.                                                 we<='1';
  26.                                                 if ready='1' then
  27.                                                         next_state<=decision;
  28.                                                 else
  29.                                                         next_state<=idle;
  30.                                                 end if;
  31.                         when decision=>                                                --判定状态
  32.                                                 oe<='0';
  33.                                                 we<='0';
  34.                                                 if read_write='1' then
  35.                                                         next_state<=read;
  36.                                                 else
  37.                                                         next_state<=write;
  38.                                                 end if;
  39.                         when read=>                                                        --读状态
  40.                                                 oe<='1';
  41.                                                 we<='0';
  42.                                                 if ready='1' then
  43.                                                         next_state<=idle;
  44.                                                 else
  45.                                                         next_state<=read;
  46.                                                 end if;
  47.                         when write=>                                                --写状态
  48.                                                 oe<='0';
  49.                                                 we<='1';
  50.                                                 if ready='1' then
  51.                                                         next_state<=idle;
  52.                                                 else
  53.                                                         next_state<=write;
  54.                                                 end if;
  55.                 end case;
  56. end process state_comb;

  57. state_clocked: process(clk,reset)
  58.         begin
  59.           if(reset = '0') then
  60.                         present_state<=idle;
  61.           elsif rising_edge(clk) then
  62.                         present_state<=next_state;
  63.           end if;
  64.         end process;
  65. end state_machine;
复制代码
下面是仿真前加入的信号,给reset两个复位信号,read_write一个低电平信号:

仿真结果:

前部分展开图:


比较疑惑的问题是,为何第二个reset信号完之后,后面就没有波形了,按住程序来说在还没到read_write的低电平来之前应该还重复前面的波形啊???

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

阿莫论坛20周年了!感谢大家的支持与爱护!!

知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)

出0入399汤圆

 楼主| 发表于 2013-3-2 19:13:10 | 显示全部楼层
顶一下。
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-7-24 07:10

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

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