文章目录

  • 前言
  • 原题复现
  • 题目解析
  • 状态转移图
  • 设计文件

前言

今天补一个状态机的题目,也是这个系列的题目之一,但是由于之前对题目有点疑惑,今天得到博友反馈,让我明白了这个题目的意思,记录一下。
原题链接

原题复现

Consider a finite state machine that is used to control some type of motor. The FSM has inputs x and y, which come from the motor, and produces outputs f and g, which control the motor. There is also a clock input called clk and a reset input called resetn.

The FSM has to work as follows. As long as the reset input is asserted, the FSM stays in a beginning state, called state A. When the reset signal is de-asserted, then after the next clock edge the FSM has to set the output f to 1 for one clock cycle. Then, the FSM has to monitor the x input. When x has produced the values 1, 0, 1 in three successive clock cycles, then g should be set to 1 on the following clock cycle. While maintaining g = 1 the FSM has to monitor the y input. If y has the value 1 within at most two clock cycles, then the FSM should maintain g = 1 permanently (that is, until reset). But if y does not become 1 within two clock cycles, then the FSM should set g = 0 permanently (until reset).

(The original exam question asked for a state diagram only. But here, implement the FSM.)

Module Declarationmodule top_module (input clk,input resetn,    // active-low synchronous resetinput x,input y,output f,output g
);

题目解析

当时没有明白的还是这一句话:
While maintaining g = 1 the FSM has to monitor the y input. If y has the value 1 within at most two clock cycles, then the FSM should maintain g = 1 permanently (that is, until reset). But if y does not become 1 within two clock cycles, then the FSM should set g = 0 permanently (until reset).
更确切的是这句话:
While maintaining g = 1 the FSM has to monitor the y input. If y has the value 1 within at most two clock cycles, then the FSM should maintain g = 1 permanently (that is, until reset).
是接下来的两个时钟周期内,有一个y为1就可以了,之后的输出永久为1,如果没有一个为1,则永久为0.
根据题目,给出状态转移图:

状态转移图

设计文件

module top_module (input clk,input resetn,    // active-low synchronous resetinput x,input y,output f,output g
); parameter A = 4'd0, S1 = 4'd1, S2 = 4'd2, S3 = 4'd3, S4 = 4'd4;parameter G_OUT= 4'd5, FOREVER_ONE = 4'd6, FOREVER_ZERO = 4'd7;parameter F_OUT = 4'd8;reg [3:0] current_state;reg [3:0] next_state;always@(posedge clk)beginif(resetn == 1'b0)begincurrent_state <= A;endelse begincurrent_state <= next_state;endendalways@(*)begincase(current_state)A:beginnext_state = F_OUT;endF_OUT:beginnext_state = S1;endS1:beginnext_state = x ? S2 : S1;endS2:beginnext_state = x ? S2 : S3;endS3:beginnext_state = x ? G_OUT: S1;end  G_OUT:beginnext_state = y ? FOREVER_ONE : S4;endS4:beginnext_state = y ? FOREVER_ONE : FOREVER_ZERO;endFOREVER_ONE:beginnext_state = FOREVER_ONE;endFOREVER_ZERO:beginnext_state = FOREVER_ZERO;enddefault:beginnext_state = A;endendcaseendassign f = (current_state == F_OUT);assign g = (current_state == S4 || current_state == G_OUT || current_state == FOREVER_ONE);endmodule

HDLBits 系列(44)状态机补录相关推荐

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

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

  2. 山西计算机网络技术专升本分数线_2020山西成考专升本招生补录第一批公告!附补录院校专业缺额表!...

    ☞回复[成绩]查询2020年成人高考成绩 ☞回复[录取]查询20成考录取结果 ☞回复[补录]查询最新院校缺额信息 ☞加入学历备考交流群 550985358   专升本第一阶段补录通知与院校缺额信息  ...

  3. 某银行存储瘫痪、缺失6个小时数据,只能人工补录

    某银行存储瘫痪.缺失6个小时数据,只能人工补录:因容量扩容操作触发光纤桥接器固件程序缺陷,造成大量磁盘在短时间内出现故障导致 转自@云头条 国内某银行生产中心存储设备发生故障,导致包括核心业务系统在内 ...

  4. 福大计算机专硕扩招,【今日话题】福州大学数计学院研究生又又又扩招?什么是拟录取补录?...

    原标题:[今日话题]福州大学数计学院研究生又又又扩招?什么是拟录取补录? 今天,三研福大收到了一位考生的私聊,告知我们补录上了计算机专业的研究生,并且收到了研招网发出的全日制研究生录取通知. 根据内部 ...

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

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

  6. 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 ...

  7. 【SMTP 补录 Apache服务】

    [补录,续] 1.[配置空壳邮件接受][mta] [前置:在/etc/named.rfc1912.zones 添加一个可以接受邮件的域hxl.org(与你数据库中写的向对应),这个域的所在ip就是你机 ...

  8. 计算机考研补录,考研补录是什么意思 需要考试吗

    考研补录是一些院校在第一次招生的时候因为填该学校的人少,没有招满,然后进行的第二次录取,正常情况,任何研究生考试都要有复试这个程序,补录也需要复试的.至于具体怎么操作,由各学校的招生单位决定. 考研补 ...

  9. TMS物流运输管理系统、智慧物流、智能运输、运单管理、预开单、补录运单、提货管理、库存管理、签收管理、短驳管理、车辆配载、送货管理、回单管理、退货管理、中转管理、承运商、路由、车线、司机、油卡、车辆

    TMS物流运输管理系统.智慧物流.智能运输.运单管理.预开单.补录运单.提货管理.库存管理.签收管理.短驳管理.车辆配载.送货管理.回单管理.退货管理.中转管理.承运商.路由.车线.司机.油卡.车辆, ...

最新文章

  1. Leetcode(20210412-20210418 第一周 每日一题)
  2. 如何找到SAP support package名称
  3. [转]常用Delphi开发资料网址
  4. 医生c语言测试卷b卷的答案,合肥工业大学C语言期中测试题_B卷
  5. 开源 | 近期遥感航空影像的检索、检测、跟踪、计数、分类相关工作
  6. Android 常用数据操作封装类案例
  7. ASP.NET的TreeView和Menu控件分别绑定siteMap和xml文件并应用母版
  8. 函数指针 回调函数 面向对象风格的C语言
  9. Pentaho BIServer 5.0.1 CE 免登录设置
  10. 巴斯勒相机的相机控制类析构函数多次调用的问题
  11. 4.2 NI-USRP驱动安装与检测
  12. 【一起学数据结构与算法分析】第二篇:字谜游戏
  13. 无刷直流电机(BLDC)建模与仿真
  14. 什么品牌台灯最舒服?盘点2023最好的台灯品牌
  15. Text-CNN 文本分类
  16. Stimulsoft Dashboards.WEB 23.1.8 完美Patch
  17. keyston api与代码router映射
  18. 2021-12-19 老杨博客推荐\TCP像串口的多程编写的一个弱鸡版本类MQTT的TCP实现\字典值查键\微PYTHON与PYTHON的JSON区别\以及一个ESP32领导多个ESP8266组网模式
  19. Android中图像变换Matrix的原理、代码验证和应用(一)
  20. 刚高考完有些迷茫不知道做些什么?谈一谈我的看法

热门文章

  1. CMenu类的使用方法
  2. linux下文件系统不丢数据扩容方法
  3. sql server 2000 数据库。 怎样用sql语句,在没有主键的情况下删除数据库中多条......
  4. moss得log文件不断增长的解决办法
  5. linux 中FTP服务器的架设
  6. c global 拦截 ajax,@RestControllerAdvice 全局拦截异常(示例代码)
  7. android 设置按钮高度,如何在本机android中设置按钮的高度
  8. java中继承和多态的实验,Java中的继承和多态
  9. 子对象是什么java_面向对象编程(什么是对象)——java
  10. matlab贝塞尔滤波器设计_DSP之窗函数法设计高通滤波器(MATLAB实现)