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

垡头做网站的公司创新产品设计方案

垡头做网站的公司,创新产品设计方案,网站建设首先要学会什么,手机网站建设哪里好写在前面 在自己准备写一些简单的verilog教程之前#xff0c;参考了许多资料----Asic-World网站的这套verilog教程即是其一。这套教程写得极好#xff0c;奈何没有中文#xff0c;在下只好斗胆翻译过来#xff08;加点自己的理解#xff09;分享给大家。 这是网站原文参考了许多资料----Asic-World网站的这套verilog教程即是其一。这套教程写得极好奈何没有中文在下只好斗胆翻译过来加点自己的理解分享给大家。 这是网站原文Verilog Tutorial 这是系列导航Verilog教程系列文章导航 有限状态机FSM简介 状态机FSM是许多数字设计的核心。计数器就是 FSM 的一种简单形式。当我学习Verilog时我曾经想知道“如何在Verilog中编码FSM”和“编码它的最佳方法是什么”。接下来我将尝试回答这两个问题。 状态机类型 根据状态机的输出类型分类有两种类型的状态机。第一种是 Moore 状态机其输出仅是当前状态的函数第二种是 Mealy 状态机其输出是当前状态和输入的函数。 Moore 状态机 Mealy 状态机 状态机还可以根据所使用的状态编码进行分类。编码类型也是决定FSM的速度和复杂度的关键因素。二进制编码、格雷码、独热码是最常见的几种 FSM 状态编码类型。 状态机建模 编码 FSM 时需要记住的一件事组合逻辑和时序逻辑应该位于两个不同的always块中。在上两图中下一状态逻辑next state logic始终是组合逻辑而状态逻辑state logic和输出逻辑output logic则是时序逻辑。任何到下一个状态逻辑的异步信号在馈送到 FSM 之前都必须进行同步化处理。你应该尽量将状态机FSM 保存在单独的 Verilog 文件中。 使用parameter或define 等常量声明来定义 FSM 的状态可使代码更具可读性且更易于管理。 示例仲裁器 接下来将以仲裁器作为案例看看该如何实现一个完整的FSM。 FSM 代码应包含三个部分 状态编码部分组合逻辑部分时序逻辑部分 状态编码 状态编码有许多方式其中最常用的是 二进制码Binary Encoding独热码One Hot Encoding格雷码Gray Encoding 独热码One Hot Encoding parameter [4:0] IDLE 5b0_0001; parameter [4:0] GNT0 5b0_0010; parameter [4:0] GNT1 5b0_0100; parameter [4:0] GNT2 5b0_1000; parameter [4:0] GNT3 5b1_0000; 二进制码Binary Encoding parameter [2:0] IDLE 3b000; parameter [2:0] GNT0 3b001; parameter [2:0] GNT1 3b010; parameter [2:0] GNT2 3b011; parameter [2:0] GNT3 3b100; 格雷码Gray Encoding parameter [2:0] IDLE 3b000; parameter [2:0] GNT0 3b001; parameter [2:0] GNT1 3b011; parameter [2:0] GNT2 3b010; parameter [2:0] GNT3 3b110; 组合逻辑部分 这一部分可以使用函数、assign 语句或者always块来实现。 always (state or req_0 or req_1 or req_2 or req_3) begin next_state 0;case(state)IDLE : if (req_0 1b1) beginnext_state GNT0;end else if (req_1 1b1) beginnext_state GNT1;end else if (req_2 1b1) beginnext_state GNT2;end else if (req_3 1b1) beginnext_state GNT3;end else beginnext_state IDLE;end GNT0 : if (req_0 1b0) beginnext_state IDLE;end else beginnext_state GNT0;endGNT1 : if (req_1 1b0) beginnext_state IDLE;end else beginnext_state GNT1;endGNT2 : if (req_2 1b0) beginnext_state IDLE;end else beginnext_state GNT2;endGNT3 : if (req_3 1b0) beginnext_state IDLE;end else beginnext_state GNT3;enddefault : next_state IDLE;endcase end 时序逻辑部分 这一部分只能使用边沿敏感逻辑例如带posedge clock或者negedge clock的always块来实现。 always (posedge clock) begin : OUTPUT_LOGICif (reset 1b1) begingnt_0 #1 1b0;gnt_1 #1 1b0;gnt_2 #1 1b0;gnt_3 #1 1b0;state #1 IDLE;end else beginstate #1 next_state;case(state)IDLE : begingnt_0 #1 1b0;gnt_1 #1 1b0;gnt_2 #1 1b0;gnt_3 #1 1b0;endGNT0 : begingnt_0 #1 1b1;endGNT1 : begingnt_1 #1 1b1;endGNT2 : begingnt_2 #1 1b1;endGNT3 : begingnt_3 #1 1b1;enddefault : beginstate #1 IDLE;endendcaseend end 使用二进制编码的完整FSM代码 module fsm_full( clock , // Clock reset , // Active high reset req_0 , // Active high request from agent 0 req_1 , // Active high request from agent 1 req_2 , // Active high request from agent 2 req_3 , // Active high request from agent 3 gnt_0 , // Active high grant to agent 0 gnt_1 , // Active high grant to agent 1 gnt_2 , // Active high grant to agent 2 gnt_3 // Active high grant to agent 3 ); // Port declaration here input clock ; // Clock input reset ; // Active high reset input req_0 ; // Active high request from agent 0 input req_1 ; // Active high request from agent 1 input req_2 ; // Active high request from agent 2 input req_3 ; // Active high request from agent 3 output gnt_0 ; // Active high grant to agent 0 output gnt_1 ; // Active high grant to agent 1 output gnt_2 ; // Active high grant to agent 2 output gnt_3 ; // Active high grant to agent // Internal Variables reg gnt_0 ; // Active high grant to agent 0 reg gnt_1 ; // Active high grant to agent 1 reg gnt_2 ; // Active high grant to agent 2 reg gnt_3 ; // Active high grant to agent parameter [2:0] IDLE 3b000; parameter [2:0] GNT0 3b001; parameter [2:0] GNT1 3b010; parameter [2:0] GNT2 3b011; parameter [2:0] GNT3 3b100;reg [2:0] state, next_state;always (state or req_0 or req_1 or req_2 or req_3) begin next_state 0;case(state)IDLE : if (req_0 1b1) beginnext_state GNT0;end else if (req_1 1b1) beginnext_state GNT1;end else if (req_2 1b1) beginnext_state GNT2;end else if (req_3 1b1) beginnext_state GNT3;end else beginnext_state IDLE;end GNT0 : if (req_0 1b0) beginnext_state IDLE;end else beginnext_state GNT0;endGNT1 : if (req_1 1b0) beginnext_state IDLE;end else beginnext_state GNT1;endGNT2 : if (req_2 1b0) beginnext_state IDLE;end else beginnext_state GNT2;endGNT3 : if (req_3 1b0) beginnext_state IDLE;end else beginnext_state GNT3;enddefault : next_state IDLE;endcase endalways (posedge clock) begin : OUTPUT_LOGICif (reset) begingnt_0 #1 1b0;gnt_1 #1 1b0;gnt_2 #1 1b0;gnt_3 #1 1b0;state #1 IDLE;end else beginstate #1 next_state;case(state)IDLE : begingnt_0 #1 1b0;gnt_1 #1 1b0;gnt_2 #1 1b0;gnt_3 #1 1b0;endGNT0 : begingnt_0 #1 1b1;endGNT1 : begingnt_1 #1 1b1;endGNT2 : begingnt_2 #1 1b1;endGNT3 : begingnt_3 #1 1b1;enddefault : beginstate #1 IDLE;endendcaseend endendmodule 测试脚本 include fsm_full.vmodule fsm_full_tb(); reg clock , reset ; reg req_0 , req_1 , req_2 , req_3; wire gnt_0 , gnt_1 , gnt_2 , gnt_3 ;initial begin$display(Time\t R0 R1 R2 R3 G0 G1 G2 G3);$monitor(%g\t %b %b %b %b %b %b %b %b, $time, req_0, req_1, req_2, req_3, gnt_0, gnt_1, gnt_2, gnt_3);clock 0;reset 0;req_0 0;req_1 0;req_2 0;req_3 0;#10 reset 1;#10 reset 0;#10 req_0 1;#20 req_0 0;#10 req_1 1;#20 req_1 0;#10 req_2 1;#20 req_2 0;#10 req_3 1;#20 req_3 0;#10 $finish; endalways#2 clock ~clock;fsm_full U_fsm_full( clock , // Clock reset , // Active high reset req_0 , // Active high request from agent 0 req_1 , // Active high request from agent 1 req_2 , // Active high request from agent 2 req_3 , // Active high request from agent 3 gnt_0 , // Active high grant to agent 0 gnt_1 , // Active high grant to agent 1 gnt_2 , // Active high grant to agent 2 gnt_3 // Active high grant to agent 3 );endmodule 仿真结果 您有任何问题都可以在评论区和我交流本文由 孤独的单刀 原创首发于CSDN平台博客主页wuzhikai.blog.csdn.net您的支持是我持续创作的最大动力如果本文对您有帮助还请多多点赞、评论和收藏⭐
http://www.w-s-a.com/news/914007/

相关文章:

  • 佘山做网站谷歌云做网站
  • 免费发布信息网站大全666做p2p网站费用
  • 北京 网站建设咨询顾问公司网络公司有几家
  • 设计类网站如何用ps做网站首页
  • 品牌网站建设的关键事项设计网有哪些
  • 网站没收录徐州建设工程审图中心网站
  • 网站建设记账做什么科目erp系统有哪些软件
  • 泰拳图片做网站用哪里有做空包网站的
  • 查外链网站重庆做网站微信的公司
  • 有没有外包活的网站如何做网站快捷键的元素
  • 公司网站赏析网站制作2019趋势
  • 企业进行网站建设的方式有( )推广引流违法吗
  • 按营销型网站要求重做网站 费用点金网站建设
  • 深圳做网站互联网服务
  • 网站sem托管wordpress安装无法连接数据库
  • 深圳网站建设开发公司哪家好微信小程序商家入口
  • 江门站排名优化建立什么网站赚钱
  • 科普文章在那个网站做招聘网站代做
  • 监控设备东莞网站建设游戏网站域名
  • 对商家而言网站建设的好处网址导航怎么彻底删除
  • app设计网站模板企业展厅策划设计公司有哪些
  • wordpress销售主题手机网站关键词优化
  • 怎么查一个网站是什么程序做的三亚城乡建设局网站
  • 深圳分销网站设计公司做网站一般需要多久
  • 企业网站设计代码丹东seo排名公司
  • 企业网站建设定制开发服务网站建设说课ppt
  • 大连市城乡建设局网站网站免费网站入口
  • 做暧网站网站备案ps
  • 知名网站建设公司电话长子网站建设
  • 网站建设的意义与目的建立什么船籍港