使用SignalTap II 有时无法显示reg和wire值解决.doc_第1页
使用SignalTap II 有时无法显示reg和wire值解决.doc_第2页
使用SignalTap II 有时无法显示reg和wire值解决.doc_第3页
使用SignalTap II 有时无法显示reg和wire值解决.doc_第4页
使用SignalTap II 有时无法显示reg和wire值解决.doc_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

写Verilog时,虽然每个module都会先用ModelSim或Quartus II自带的simulator仿真过,但真的将每个module合并时,一些不可预期的“run-time”问题可能才一一浮现,这时得靠SignalTap II来帮忙debug。写Verilog时,虽然每个module都会先用ModelSim或Quartus II自带的simulator仿真过,但真的将每个module合并时,一些不可预期的“run-time”问题可能才一一浮现,这时得靠SignalTap II来帮忙debug。使用环境:Quartus II 8.0 + DE2-70 (Cyclone II EP2C70F896C6N)实际使用SignalTap II时,会发现有些reg与wire可以观察,有些又无法观察,本文整理出完整的reg与wire观察方法。观察regSSignalTapII_register_not_preserve.v / Verilog1. module SignalTapII_register_not_preserve (2. input iCLK,3. input iRST_N4. );5.6. reg 3:0 cnt;7.8. always(posedge iCLK, negedge iRST_N) begin9. if(!iRST_N)10. cnt = 4h0;11. else12. cnt = cnt + 4h1;13. end14.15. endmodule这是个很简单的计数器,我故意让cnt不做output,而想用SignalTap II去观察cnt这个reg的值。cnt都是0,显然不合理,表示SignalTap II无法capture cnt这个reg的值。为什么会这样呢?若我们将SignalTap II拿掉,重新用Quartus II编译,观察其compilation report,显示register为0。观察RTL Viewer的合成结果,真的没有register!这证明了一件事情,Quartus II在合成时,发现cnt并没有需要output,而自动最佳化不合成cnt,导致SignalTap II无法观察reg,不过有时为了debug方便,我们就是想观察这种reg,有办法让Quartus II暂时不要启动最佳化吗?使用Synthesis Attribute避免最佳化SignalTapII_register_preserve.v / Verilog1. module SignalTapII_register_preserve (2. input iCLK,3. input iRST_N4. )5.6. reg 3:0 cnt/*synthesis noprune*/;7.8. always(posedge iCLK, negedge iRST_N) begin9. if(!iRST_N)10. cnt = 4h0;11. else12. cnt = cnt + 4h1;13. end14.15. endmodule6行reg3:0 cnt/*synthesis noprune*/;多了/*synthesis noprune*/这个synthesis attribute,指示Quartus II不要对cnt做最佳化,保留此register以供SignalTap II观察,注意必须写在分号前面,不能如下写在分号后面。reg3:0 cnt;/*synthesis noprune*/ /错!编译后,SignalTap II就能顺利的观察到cnt的值!重点是不需改top module的interface,只需对想观察的reg加上synthesis attribute即可。Quartus II也支援Verilog 2001的語法1. module SignalTapII_register_preserve (2. input iCLK,3. input iRST_N4. );5.6. / Verilog 20017. /(*noprune*) reg 3:0 cnt;8.9. always(posedge iCLK, negedge iRST_N) begin10. if(!iRST_N)11. cnt = 4h0;12. else13. cnt = cnt + 4h1;14. end15.16. endmodule7行(*noprune*)reg3:0 cnt;这是Verilog 2001的语法,Quartus II 8.0也能看得懂。若希望整个module的reg都不被最佳化,可将synthesis attribute放在module。1. module SignalTapII_register_preserve (2. input iCLK,3. input iRST_N4. )/*synthesis noprune*/;5.6. reg 3:0 cnt;7.8. always(posedge iCLK, negedge iRST_N) begin9. if(!iRST_N)10. cnt = 4h0;11. else12. cnt = cnt + 4h1;13. end14.15. endmodule1行moduleSignalTapII_register_preserve (inputiCLK,inputiRST_N/);)/*synthesis noprune*/;moduleSignalTapII_register_preserve (inputiCLK,inputiRST_N)/*synthesis preserve*/;观察 wire 同样的,在 SignalTapII 观察 wire 时,有时也会因为被 QuartusII 优化掉而无法用 SignalTapII 观察。 SignalTapII_wire_not_keep.v / Verilog moduleSignalTapII_wire_not_k观察wire同样的,在SignalTap II观察wire时,有时也会因为被Quartus II优化掉而无法用SignalTap II观察。SignalTapII_wire_not_keep.v / Verilog1. module SignalTapII_wire_not_keep (2. input iCLK,3. input iRST_N,4. output 3:0 oCNT5. );6.7. wire 3:0 Cnt;8. reg 3:0 cnt;9.10. assign Cnt = cnt;11. assign oCNT = Cnt;12.13. always(posedge iCLK, negedge iRST_N) begin14. if(!iRST_N)15. cnt = 4h0;16. else17. cnt = cnt + 4h1;18. end19.20. endmodule7行wire3:0 Cnt;假设我想用SignalTap II去观察Cnt这个wire。Cnt都是0,显然不合理,表示SignalTap II无法capture cnt这个wire的值。为什么会这样呢?因为Cnt这个wire已经被Quartus II优化不见了!不过有时为了debug方便,我们就是想观察这种wire,有办法让Quartus II暂时不要启动最佳化吗?SignalTapII_wire_keep.v / Verilog1. module SignalTapII_wire_keep (2. input iCLK,3. input iRST_N,4. output 3:0 oCNT5. );6.7. wire 3:0 Cnt/*synthesis keep*/;8. reg 3:0 cnt;9.10. assign Cnt = cnt;11. assign oCNT = Cnt;12.13. always(posedge iCLK, negedge iRST_N) begin14. if(!iRST_N)15. cnt = 4h0;16. else17. cnt = cnt + 4h1;18. end19.20. endmodule加大编辑框|缩小编辑框7行wire3:0 Cnt/*synthesis keep*/;Quartus II也支援Verilog 2001的語法1. module SignalTapII_wire_keep (2. input iCLK,3. input iRST_N,4. output 3:0 oCNT5. );6.7. / Verilog 20018. (*keep*) wire 3:0 Cnt;9. reg 3:0 cnt;10.11. assign Cnt = cnt;12. assign oCNT = Cnt;13.14. always(posedge iCLK, negedge iRST_N) begin15. if(!iRST_N)16. cnt = 4h0;17. else18. cnt = cnt + 4h1;19. end20.21. endmodule8行(*keep*)wire3:0 Cnt;这是Verilog 2001的语法,Quartus II 8.0也能看得懂。结语关于避免Quartus II优化reg,/*synthesis noprune*/与/*synthesis preserve*/还是有些差异,程序写到很大时,可能一时很难决定要用哪一个attribute,可以交替试试看,反正1/2的机会,总会对一个。会使用synthesis attribute之后,总算解掉长久以来,无法用SignalTap II观察reg与wire的老问题。多了/*synthesis keep*/这个synthesis attribute,指示Quartus II不要对Cnt做最佳化,保留此wire以供SignalTap II观察,注意必须写在分号前面,不能如下写在分号后面。wire3:0 Cnt;/*synthesis keep*/错编译后,SignalTap II就能顺利的观察到Cnt的值!重点是不需改top module的interface,只需对想观察的wire加上synthesis attribute即可。将/*synthesis noprune*/放在module,这样整个module的reg将不被最佳化,不用再一一指定。另外一个与reg相关的Synthesis Attribute:/*synthesis preser

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论