1  Intro

  The figure shows the block diagram of a single-phase state machine. The lower section contains sequential logic (flip-flops), while the upper section contains combinational logic.

  The combinational section has two inputs, pr_state (present state) and external input. It has also two outputs, nx_state (next state) and external output. The sequential section has three inputs (clock, reset, and nx_state), and one output (pr_state). Since all flip-flops are in this part of the system, clock and reset must be connected to it.

  If the output of the machine depends not only on the present state but also on the current input, then it is called a Mealy machine. Otherwise, if it depends only on the current state, it is called a Moore machine. Examples of both will be shown later.

  

2  Design style (recommended)

  1)  Sequential  

  process (reset, clock)
begin
  if (reset = '') then
    pr_state <= state0;
  elsif (clock'event and clock = '') then
    pr_state <= nx_state;
end if;
end process; 

  It consists of an asynchronous reset, which determines the initial state of the system (state0), followed by the synchronous storage of nx_state (at the positive transition of clock), which will produce pr_state at the lower section’s output (figure 8.1).

  One good thing is that the design of the lower section is basically standard. Another advantage is that the number of registers is minimum.

  

  2)  Combinational

  

 process (input, pr_state)
begin
  case pr_state is
    when state0 =>
      if (input = ...) then
        output <= <value>;
        nx_state <= state1;
      else ...
      end if;
    when state1 =>
      if (input = ...) then
        output <= <value>;
        nx_state <= state2;
      else ...
      end if;
16     when state2 =>
17       if (input = ...) then
        output <= <value>;
        nx_state <= state2;
      else ...
      end if;
    ...
  end case;
end process;

  As can be seen, this code is also very simple, and does two things:

   (a) assign the output value

   (b) establish the next state.

3  VHDL template 

 library ieee;
use ieee.std_logic_1164.all;
3 -----------------------------------------------------
entity <entity_name> is
port( input : in <data_type>;
reset, clock : in std_logic;
output : out <data_type>);
end <entity_name>;
9 -----------------------------------------------------
architecture <arch_name> of <entity_name> is
type state is (state0, state1, state2, state3, ...);
signal pr_state, nx_state: state; begin
15 ---------- Sequential ------------------------
process (reset, clock)
begin
if (reset='') then
pr_state <= state0;
elsif (clock'event and clock='') then
pr_state <= nx_state;
end if;
end process;
24 ---------- Combinational ------------------------
process (input, pr_state)
begin
case pr_state is
when state0 =>
if (input = ...) then
output <= <value>;
nx_state <= state1;
else ...
end if;
when state1 =>
if (input = ...) then
output <= <value>;
nx_state <= state2;
else ...
end if;
when state2 =>
if (input = ...) then
output <= <value>;
nx_state <= state3;
else ...
end if;
...
end case;
end process; end <arch_name>;

VHDL之FSM的更多相关文章

  1. 有限狀態機FSM coding style整理 (SOC) (Verilog)

    AbstractFSM在數位電路中非常重要,藉由FSM,可以讓數位電路也能循序地執行起演算法.本文將詳細討論各種FSM coding style的優缺點,並歸納出推薦的coding style. In ...

  2. FSM之三--代码风格

    FSM设计之一http://www.cnblogs.com/qiweiwang/archive/2010/11/28/1890244.html Moore型状态机与mealy型状态机相比,由于其状态输 ...

  3. 用FSM一键制作逐帧动画雪碧图 Vue2 + webpack

    因为工作需要要将五六十张逐帧图拼成雪碧图,网上想找到一件制作工具半天没有找到,就自己用canvas写了一个. 写成之后就再没有什么机会使用了,因此希望有人使用的时候如果遇到bug了能及时反馈给我. 最 ...

  4. FSM(状态机)、HFSM(分层状态机)、BT(行为树)的区别

    游戏人工智能AI中最常听见的就是这三个词拉: FSM 这个不用说拉,百度一大堆解释, 简单将就是将游戏AI行为分为一个一个的状态,状态与状态之间的过渡通过事件的触发来形成. 比如士兵的行为有“巡逻”, ...

  5. 有限状态机(FSM)

    在游戏开发中,AI是个永恒不变的话题,如果你要的AI只是很简单的一个逻辑 那么有限状态机是一个很好的解决方案,尽管在实际开发中,AI的设计并不是一个简单的逻辑, 如果用有限状态机,维护起来会非常麻烦, ...

  6. VHDL生成的ngc文件被verilog的工程调用的问题

    1. 问题的提出 工程a是一个soft core,用VHDL写的,综合的时候去掉了"Add I/O buffers" ,并将-iob(Pack I/O Registers into ...

  7. FSM 浅谈

    之前写过一篇关于状态机的,上一篇讲过的我也就不再罗嗦了,不知道欢迎去查看我的上一篇随笔,主要是感觉上次自己封装的还是不行,所以又进行修改了一番! 我本人是个菜鸟,最开始接触状态机的时候,状态机一个可厉 ...

  8. Atitit.java expression fsm 表达式词法分析引擎 v2 qaa.docx

    Atitit.java expression fsm 表达式词法分析引擎 v2 qaa.docx C:\0workspace\AtiPlatf_cms\src\com\attilax\fsm\Java ...

  9. 实现简易而强大的游戏AI——FSM,有限状态机

    http://blog.friskit.me/2012/05/introduction-of-fsm/ 在很久很久以前,受限于计算机性能和图形效果,游戏往往是以玩家为唯一主动对象的,玩家发出动作,游戏 ...

随机推荐

  1. Excel表格

    自己一个一个试出来,并写上解释. 还不熟练,待多写代码多练习. #!/usr/bin/python # -*- coding:utf-8 -*- import os import xlwt impor ...

  2. JavaScript初步学习----基本使用,简单事件,修改样式,数据类型

    JavaScript基本使用 JavaScript原名叫livescript,是一门动态类型,弱类型基于原型的脚本语言   用于页面特效,前后交替,后台开发(node)   JavaScript写在s ...

  3. elasticsearch 权威指南Mapping(映射)

    什么是映射 类似于数据库中的表结构定义,主要作用如下: 定义Index下字段名(Field Name) 定义字段的类型,比如数值型,字符串型.布尔型等 定义倒排索引的相关配置,比如是否索引.记录pos ...

  4. 【Developer Log】ProGuard扰码可执行JAR包

    在项目上线之前需要通过ProGuard来对java的class进行混淆,以避免反编译方式,来保护自己的代码.ProGuard网上有很多资料,可以参考:http://blog.csdn.net/zhan ...

  5. 神奇的幻方 noip2015day1 T1

     题目描述 Description 幻方是一种很神奇的N∗N矩阵:它由数字 1,2,3, … … ,N∗N构成,且每行.每列及两条对角线上的数字之和都相同. 当N为奇数时,我们可以通过以下方法构建一个 ...

  6. 网络流入门 Drainage Ditches

    Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) ...

  7. Ubuntu下调整时区时间

    Ubuntu下调整时区时间 学习了:http://blog.csdn.net/jintiaozhuang/article/details/38583031 进行了tzselect错误的修复 学习了:h ...

  8. [LeetCode]Valid Sudoku解题记录

    这道题考查对二维数组的处理,哈希表. 1.最自然的方法就是分别看每一个数是否符合三个规则.所以就须要对应的数据结构来 记录这些信息,判定是否存在.显然最先想到用哈希表. 2.学会把问题抽象成一个个的子 ...

  9. gradle打包android (实现外部导入签名文件、多渠道打包、导入ant脚本)

    近期一直在做android自己主动打包,之前已经完毕了用纯命令行的形式打包.原生态ant脚本打包.和基于android的SDK的打包.而且实现了多渠道打包,后来同事推荐了gradle,网上的资料说gr ...

  10. 从头认识java-15.2 Collection的经常用法(2)-注意点

    上一章节我们讲述了Collection的经常用法.还有之前的章节我们介绍了Collection的addAll方法,这一章节我们介绍一下它的注意点. 注意点就是,在经常用法里面,基本都是可选操作. 什么 ...