目录

Fsm1

Fsm1s

Fsm2

Fsm3comb


Fsm1

This is a Moore state machine with two states, one input, and one output. Implement this state machine. Notice that the reset state is B.

This exercise is the same as fsm1s, but using asynchronous reset.

Module Declaration

module top_module(input clk,input areset,    // Asynchronous reset to state Binput in,output out);

这个题目给出了一个最简单的摩尔型的有限状态机,仅仅有两个状态,让你描述这个有限状态机:

采用三段式,给出设计如下:

module top_module(input clk,input areset,    // Asynchronous reset to state Binput in,output out);//  parameter A=0, B=1; reg state, next_state;always @(posedge clk, posedge areset) begin    // This is a sequential always block// State flip-flops with asynchronous resetif(areset) state <= B;else state <= next_state;endalways @(*) begin    // This is a combinational always block// State transition logiccase(state)B: beginif(in == 1) next_state = B;else next_state = A;endA: beginif(in == 1) next_state = A;else next_state = B;endendcaseend// Output logic// assign out = (state == ...);assign out = (state == A)?0:1;endmodule


Fsm1s

This is a Moore state machine with two states, one input, and one output. Implement this state machine. Notice that the reset state is B.

This exercise is the same as fsm1, but using synchronous reset.

Module Declaration

// Note the Verilog-1995 module declaration syntax here:
module top_module(clk, reset, in, out);input clk;input reset;    // Synchronous reset to state Binput in;output out;

这个题目和上一句几乎一模一样,就是复位方式变成了同步复位;

可恨的是,题目还给了模板提示,提示用的是一段式,并且是Verilog1995,天了噜,这种风格,告辞了,三段式继续走起:

module top_module(input clk,input reset,    // Asynchronous reset to state Binput in,output out);//  parameter A=0, B=1; reg state, next_state;always @(posedge clk) begin    // This is a sequential always block// State flip-flops with asynchronous resetif(reset) state <= B;else state <= next_state;endalways @(*) begin    // This is a combinational always block// State transition logiccase(state)B: beginif(in == 1) next_state = B;else next_state = A;endA: beginif(in == 1) next_state = A;else next_state = B;endendcaseend// Output logic// assign out = (state == ...);assign out = (state == A)?0:1;endmodule

Fsm2

This is a Moore state machine with two states, two inputs, and one output. Implement this state machine.

This exercise is the same as fsm2s, but using asynchronous reset.

Module Declaration

module top_module(input clk,input areset,    // Asynchronous reset to OFFinput j,input k,output out); 
module top_module(input clk,input areset,    // Asynchronous reset to OFFinput j,input k,output out); //  parameter OFF=0, ON=1; reg state, next_state;always @(*) begin// State transition logiccase(state)OFF: beginif(j == 1) next_state = ON;else next_state = OFF;endON: beginif(k == 1) next_state = OFF;else next_state = ON;endendcaseendalways @(posedge clk, posedge areset) begin// State flip-flops with asynchronous resetif(areset) state <= OFF;else state <= next_state;end// Output logic// assign out = (state == ...);assign out = (state == ON)? 1 : 0;endmodule

Fsm3comb

The following is the state transition table for a Moore state machine with one input, one output, and four states. Use the following state encoding: A=2'b00, B=2'b01, C=2'b10, D=2'b11.

Implement only the state transition logic and output logic (the combinational logic portion) for this state machine. Given the current state (state), compute the next_state and output (out) based on the state transition table.

State Next state Output
in=0 in=1
A A B 0
B C B 0
C A D 0
D C B 1

Module Declaration

module top_module(input in,input [1:0] state,output [1:0] next_state,output out); 

本题和写全状态机没什么区别,只不过少了一个always时序逻辑块,当前状态由顶层模块给出,作为输入,下一个状态作为输出。

module top_module(input in,input [1:0] state,output [1:0] next_state,output out); //parameter A=0, B=1, C=2, D=3;// State transition logic: next_state = f(state, in)always@(*) begincase(state)A: beginif(in == 0) next_state = A;else next_state = B;endB: beginif(in == 0) next_state = C;else next_state = B;endC: beginif(in == 0) next_state = A;else next_state = D;endD: beginif(in == 0) next_state = C;else next_state = B;endendcaseend// Output logic:  out = f(state) for a Moore state machineassign out = (state == D) ? 1:0;endmodule

HDLBits 系列(24)进入FSM(有限状态机)的世界入口相关推荐

  1. HDLBits 系列(0)专题目录

    本篇博文是近来总结HDLBits系列的目录,点击蓝色字体即可进入查看具体内容. HDLBits 系列(1)从HDLBits中获取灵感,整顿自己,稳步前行 HDLBits 系列(2)如何避免生成锁存器? ...

  2. HDLBits 系列(31)Serial Receiver and Datapath

    目录 序言 原题复现 我的设计 序言 上篇博文: HDLBits 系列(30)Serial Receiver 写了串行接收器如何接收8位串行数据,正确接收8位串行数据后给一个接收完毕标志信号,这篇博文 ...

  3. HDLBits 系列(29)PS/2 mouse protocol(PS/2 packet parser and datapath)

    目录 序言 原题传送 题目解释 我的设计 序言 上篇博客: HDLBits 系列(28)PS/2 mouse protocol(PS/2 packet parser) 只对PS/2 mouse pro ...

  4. 游戏 AI 设计之 FSM 有限状态机

    FSM 有限状态机 一.概述 有限状态机(finite-state machine,缩写:FSM)又称有限状态自动机(finite-state automaton,缩写:FSA),简称状态机,是表示有 ...

  5. SAP PM 初级系列24 - 发料到维修工单

    SAP PM 初级系列24 - 发料到维修工单 SAP PM模块里,对于维修工单的发料,跟对于生产订单的发料操作类似的,也是使用MIGO事务代码,移动类型261. 执行MIGO,选A07(Goods ...

  6. SAP PM入门系列24 - IK07 Display Measuring Points

    SAP PM入门系列24 - IK07 Display Measuring Points SAP PM的基础报表里,对于计量点(Measuring Points)这个技术对象,也提供了标准的查询报表. ...

  7. python3爬虫系列24之重庆微博地铁客运量爬取且可视化输出

    python3爬虫系列24之重庆微博地铁客运量爬取和可视化 1.前言 在python3爬虫系列23之selenium+腾讯OCR识别验证码登录微博且抓取数据里面,我们既是又搞selenium自动化,又 ...

  8. 计算机24点游戏音调,康复游戏系列24∣翻山越岭中辨识声调

    原标题:康复游戏系列24∣翻山越岭中辨识声调 点击标题下方「聋康网」即可快速关注! 于兰,赤峰市民族特殊教育学校教师.2004年毕业于呼伦贝尔学院:2014年通过"全国听障儿童康复专业技术人 ...

  9. Unity下FSM有限状态机详解

    FSM有限状态机详解 文章目录 FSM有限状态机详解 FSM的定义 FSM的适用性 FSM的设计分析 状态转换表的使用 状态和条件的标识符Id 条件基类的设计 FSMTrigger 状态基类的设计 F ...

  10. 我国首次倡导24小时饥饿警醒世人爱粮节粮-24小时饥饿-禁食-世界粮食日

    我国首次倡导24小时饥饿警醒世人爱粮节粮|24小时饥饿|禁食|世界粮食日 10月16日,合肥市蜀山区龙河路社区在辖区幼儿园开展爱惜粮食活动,让孩子们认识各种谷类.新华社发 昨天是"世界粮食日 ...

最新文章

  1. python 英语翻译 excel_python批量将excel内容进行翻译写入功能
  2. 【转载】通俗理解极大似然估计
  3. 智能手环功能模块设计_基于STM32实现智能手环设计
  4. Java中关于路径和使用exe4j打包成ext可执行程序的一些小总结
  5. “挖空三座山、装了几万台服务器”的绿色数据中心
  6. 【AI产品】听着AI为照片生成的专属轻音乐,你还会失眠吗
  7. CodeForces - 787D - Legacy(线段树优化建图+最短路)
  8. spring boot 集合mysql_Spring boot整合mysql和druid
  9. 训练日志 2019.1.25
  10. linux部署Oracle数据库--安装篇
  11. python绘图数字_绘制一个绘图,其中Yaxis文本数据(非数字)和Xaxis数字d
  12. python colormap_Python科学计算技巧积累八——colormap 和 contour map的绘制
  13. 利用MATLAB仿真最小发射功率下WSN的连通性和覆盖率
  14. 计算机应用与医学信息基础知识,第一篇医学信息基础知识.PDF
  15. oracle 修改用户信息表,Oracle批量修改用户表table的表空间 | 学步园
  16. 周 7 福利日:中奖名单公布
  17. BT源代码学习心得(九):客户端源代码分析(图形界面浅析) -- 转贴自 wolfenstein (NeverSayNever)
  18. 区块链开发工程师和人工智能算法工程师,哪个会在未来 5 年收入更高?
  19. SAP PS 第7节 物资采购类别、wbs bom及第三方采购
  20. 安全合规/法案--29--《网络安全法》原文及解读

热门文章

  1. Knockout 新版应用开发教程之visible绑定
  2. linux 魔兽 qq
  3. 绩效考核如何才能突破上司的主观偏见局限?
  4. 解决MySQL命令行无法连接问题错误ERROR1045(28000)
  5. 智能卡技术和身份认证
  6. python 如何建立图形用户界面_python(五)图形用户界面easyGUI入门
  7. 伺服驱动器接线怎么画_百格拉伺服驱动器维修常见故障现象及处理方法
  8. hssfcolor 不建议使用_POI导出Excel经典实现
  9. python 遍历文件夹 提取文件内信息 存为新文件名_python获取遍历文件名称并分别保存为XLSX和CSV格式...
  10. mfc编辑框显示数据_Excel表格技巧—Excel表格中怎么给数据分等级