当前位置: 首页 > news >正文

Verilog刷题笔记60

题目:
Exams/2013 q2bfsm
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 top_module (input clk,input resetn,    // active-low synchronous resetinput x,input y,output f,output g
); parameter s0=0,s1=1,s2=2,s3=3,s4=4,s5=5,s6=6,s7=7,s8=8;reg [3:0]state,next_state;always@(posedge clk)beginif(!resetn)state=s0;elsestate=next_state;endalways@(*)begincase(state)s0:next_state=s8;s8:next_state=s1;s1:next_state=x?s2:s1;s2:next_state=x?s2:s3;s3:next_state=x?s4:s1;s4:next_state=y?s6:s5;s5:next_state=y?s6:s7;s6:next_state=s6;s7:next_state=s7;endcaseendassign f=(state==s8);assign g=(state==s4)|(state==s5)|(state==s6);endmodule

结果正确:
在这里插入图片描述

注意点:
专门用一个状态,来表示f置为1 只有一个时钟周期。

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • 计算机网络-PIM-SM组播实验
  • C++:病毒系列回归记3/3 (Doge智能系统已上线)
  • 如何使用查询路由构建更先进的 RAG
  • 宠物掉毛、有异味怎么办?怎么选择宠物空气净化器?
  • OpManager Plus简单说明以及在Linux下的安装
  • 四、控制结构
  • 网络协议的基础知识
  • 链表(静态/动态创建,遍历,计数,查找,在节点的前/后方插入新节点,头插法,尾插法)
  • 基于x86 平台opencv的图像采集和seetaface6的人脸检测功能
  • :class的用法及应用
  • java后端请求与响应总结
  • C++入门基础知识31
  • Vue解决父子组件传值,子组件改变值后父组件的值也改变的问题
  • WPF—Triggers触发器
  • Linux驱动开发基础(SR501人体红外模块)
  • “寒冬”下的金三银四跳槽季来了,帮你客观分析一下局面
  • 【RocksDB】TransactionDB源码分析
  • 【每日笔记】【Go学习笔记】2019-01-10 codis proxy处理流程
  • flask接收请求并推入栈
  • Javascript 原型链
  • select2 取值 遍历 设置默认值
  • spring boot 整合mybatis 无法输出sql的问题
  • vue总结
  • 简单基于spring的redis配置(单机和集群模式)
  • 力扣(LeetCode)22
  • 盘点那些不知名却常用的 Git 操作
  • 普通函数和构造函数的区别
  • 前端每日实战:61# 视频演示如何用纯 CSS 创作一只咖啡壶
  • 设计模式走一遍---观察者模式
  • 携程小程序初体验
  • 再谈express与koa的对比
  • 最简单的无缝轮播
  • ​批处理文件中的errorlevel用法
  • ​探讨元宇宙和VR虚拟现实之间的区别​
  • # 详解 JS 中的事件循环、宏/微任务、Primise对象、定时器函数,以及其在工作中的应用和注意事项
  • #HarmonyOS:Web组件的使用
  • (HAL)STM32F103C6T8——软件模拟I2C驱动0.96寸OLED屏幕
  • (Matalb时序预测)PSO-BP粒子群算法优化BP神经网络的多维时序回归预测
  • (超详细)2-YOLOV5改进-添加SimAM注意力机制
  • .\OBJ\test1.axf: Error: L6230W: Ignoring --entry command. Cannot find argumen 'Reset_Handler'
  • .Net 6.0--通用帮助类--FileHelper
  • .NET BackgroundWorker
  • .Net 高效开发之不可错过的实用工具
  • .NET/C# 在代码中测量代码执行耗时的建议(比较系统性能计数器和系统时间)
  • .net6 core Worker Service项目,使用Exchange Web Services (EWS) 分页获取电子邮件收件箱列表,邮件信息字段
  • .net下的富文本编辑器FCKeditor的配置方法
  • .NET运行机制
  • //TODO 注释的作用
  • /bin/bash^M: bad interpreter: No such file or directory
  • /var/spool/postfix/maildrop 下有大量文件
  • ::
  • @ConfigurationProperties注解对数据的自动封装
  • @manytomany 保存后数据被删除_[Windows] 数据恢复软件RStudio v8.14.179675 便携特别版...
  • @Resource和@Autowired的区别
  • @RestController注解的使用