码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • [HDLBits] Exams/2013 q2afsm


    Consider the FSM described by the state diagram shown below:

    Exams 2013q2.png

    This FSM acts as an arbiter circuit, which controls access to some type of resource by three requesting devices. Each device makes its request for the resource by setting a signal r[i] = 1, where r[i] is either r[1], r[2], or r[3]. Each r[i] is an input signal to the FSM, and represents one of the three devices. The FSM stays in state A as long as there are no requests. When one or more request occurs, then the FSM decides which device receives a grant to use the resource and changes to a state that sets that device’s g[i] signal to 1. Each g[i] is an output from the FSM. There is a priority system, in that device 1 has a higher priority than device 2, and device 3 has the lowest priority. Hence, for example, device 3 will only receive a grant if it is the only device making a request when the FSM is in state A. Once a device, i, is given a grant by the FSM, that device continues to receive the grant as long as its request, r[i] = 1.

    Write complete Verilog code that represents this FSM. Use separate always blocks for the state table and the state flip-flops, as done in lectures. Describe the FSM outputs, g[i], using either continuous assignment statement(s) or an always block (at your discretion). Assign any state codes that you wish to use.

    1. module top_module (
    2. input clk,
    3. input resetn, // active-low synchronous reset
    4. input [3:1] r, // request
    5. output [3:1] g // grant
    6. );
    7. parameter free=0,e1=1,e2=2,e3=3;
    8. reg [1:0] state,next;
    9. always@(*) begin
    10. case(state)
    11. free:begin
    12. if(r==3'b000)
    13. next<=free;
    14. else if(r[1])
    15. next<=e1;
    16. else if(r[2])
    17. next<=e2;
    18. else
    19. next<=e3;
    20. end
    21. e1:begin
    22. if(r[1])
    23. next<=e1;
    24. else
    25. next<=free;
    26. end
    27. e2:begin
    28. if(r[2])
    29. next<=e2;
    30. else
    31. next<=free;
    32. end
    33. e3:begin
    34. if(r[3])
    35. next<=e3;
    36. else
    37. next<=free;
    38. end
    39. endcase
    40. end
    41. always@(posedge clk) begin
    42. if(!resetn)
    43. state<=free;
    44. else
    45. state<=next;
    46. end
    47. assign g[1]=state==e1;
    48. assign g[2]=state==e2;
    49. assign g[3]=state==e3;
    50. endmodule

     

  • 相关阅读:
    【数据结构】二叉树--堆排序
    kettle从入门到精通 第六十六课 ETL之kettle kettle阻塞教程,轻松获取最后一行数据,so easy
    Python爬虫之Js逆向案例(9)-企ming科技之webpack
    计算机算法分析与设计(24)---分支限界章节复习
    本周内容整理
    un-app部署h5项目到普通云服务器--域名解析--OOS对象存储
    数据库理论知识及相关发展方向
    MySQL练习题15道
    【CSRF-01】跨站请求伪造漏洞基础原理及攻防
    [附源码]Python计算机毕业设计Django网上电影购票系统
  • 原文地址:https://blog.csdn.net/m0_66480474/article/details/133866312
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号